I have a swift app where I now want to add translations for some of the strings used in the app using NSLocalizedString.
In order to do this, I added a file named Localizable.strings to the project and pressed the "localize" button in the file inspector in order to add multiple languages to it. However only english appeared in the localization list, and I seem to be unable to add more.
Having looked around at SO and just googling around, many of the articles on how to do this mention that I should add more languages to my project under build settings. But the only setting I can change under Localization is one named "Localized String Macro Names", and there is no option to add languages there. There is also no "Use Base Internationalization" marker to check.
I have also tried to click on my project, then Editor -> Add Localization, but there all the languages are greyed out and I am unable to chose any of them.
I therefore suppose that you are supposed to do this differently in the latest version of xcode (10.1 atm). Can anyone help me figure out how you are supposed to do it?
It's about the project settings. Take a look at the image:
Under the Localizations you add new languages. After you add the language here you select which files you want to localize.
// update
Click on the top right button shown in the screen below and select your project under the PROJECT tab.
You just selected the wrong settings. The picture that you attached is actually under TARGET settings -> Build Settings, rather than project settings.
See the picture below to select "project settings" under xcode 10:
Xcode 10, project settings
In Xcode 7
I have created a Localizable.string and in Inspector I can only see two languages - how do I add more?
Thanks
Ok, I found the solution:
In Project settings under "info" you can add additions languages.
Select Name project in PROJECT, Info, Localizations, and press "+" to add language.
After, you can select the Resource File.
Then, you can modify the Localizable.strings(new-language) created with your translations and Build to verify possible errors.
I have finished my first game project with Spritebuilder and its time for localisation. But, when I try to add a new localisation, even though I follow all the correct steps, no language is added in Xcode and no localised project folder are created after I click finish (see attached photo).
Hint: If I try to add the language again the list with the resource files is empty...
Any ideas?
Faced similar issue with SpriteBuilder, if you prefer Xcode's string format. Try this answer to restore this capability
I deleted the Localizations in Xcode, then I cannot add any Localizations back
I am trying to follow this tutorial and am encountering this error. If somebody could help me it would be much, much appreciated.
Thanks.
That header is probably not in your project navigator in xcode, You need to find the file in finder and drag it into xcode and place it in your project navigator
A few options I can suggest:
Add the framework part of the path #import <SMTPSend/NSData+Base64Additions> (also if this is a framework, you should probably use these enclosures: <.../file.h> instead of quotes)
Add the frameworks path to your build settings ( Framework Search Paths )
Make sure the framework is in the Link Binary With Libraries section
Remove the framework reference from the project organizer pane (cmd+1), then drag it back in (refreshes the path for the file)
Clean/Clean Build Folder/Rebuild
Hope one of those helps!
I just updated to Xcode 4.
Normally when localizing apps we add "Localizable.String" file to the project, and then navigate to "Get Info" menu and click the "Make It Localized" button.
However, in Xcode 4, there is no "Get Info" menu.
When I try to add a language it only effects the "InfoPlist.String" file (which can only localize the app's name).
How may I add localization to my app in Xcode 4?
It's simple once you understand it.
If you want to accomplish this with Xcode 5.x and iOS 7 or Xcode 6.x and iOS 8, check out "How to localize my app with Xcode 5?" instead.
I liked SNR's link, but his answer was a bit short.
Also, I see that this question is a bit old, and my answer may be different from older versions of Xcode. (I used Xcode v. 4.3.3)
However, i have updated my answer to work with both Xcode 4.3.5 and below + 4.4 and above (and Xcode 5.x and 6.x here: How to localize my app with Xcode 5?).
To begin you should add a new "Strings File" in the iOS Resource category.
Next, create the file as "Localizable.strings".
When the file is created, select it and open File Inspector .
EDIT: Things have changed (a bit) with the new Xcode 4.4, 4.5 (and above) (for iOS 6 support).
If you'r Not using Xcode 4.4 or above, joust skip this step.
{ The Xcode 4.4, 4.5 (and above) way:
Click the "Make localized" button
Now head over to your Main Project page.
And click the "+" button under Localization, and select the languages you want to support.
(I'll select German / Deutsch)
Now a window will appear asking you what files you want to localize, make sure Only the "Localizable.strings" file is selected and click Finish.
}
{ The Xcode 4.3.5 and below way:
Click the "+" button under Localization, and select the languages you want to support.
(I'll select German / Deutsch)
}
.
.
.
.
You should now see that you have two files under the "Localizable.strings" file.
Next, add your localization strings inside both of the localization files.
Now here comes the coding part.
Here i'll simply declare a UILabel and set it's text to the Localizable file string.
Declare:
IBOutlet UILabel *testLabel;
And Inside ViewDidLoad i'll set the text using NSLocalizedString:
[testLabel setText:NSLocalizedString(#"TEST", nil)];
To finish up, just connect our testLabel in "Interface Builder".
Now you should be able to run the Project and see the localized string.
And if you change the language, you should see the localized string change as well.
Select the file you want to localize and klick on the file inspector in the utilities section.
There is a section Localization
You can view the file info (and add localizations) when you select the file and open the "File Inspector" via the main menu's "View" -> "Utilities" -> "File Inspector".
first you need to add new Localizable.string file and select it and go to View" -> "Utilities" -> "File Inspector click on + button to add language in localization section.
also check it XCode 4, Adding localization
the way of Localization in xcode4 has changed! right click the localizable.strings, and to add support for another language, simply click on the ‘+’ in that ‘Localization’ pane on the right.
You can take advanced of the User Defined Runtime Attributes:
http://cupobjc.blogspot.com.es/2014/04/interfaz-builder-localization.html
First define a new category for UILabel:
#import "UILabel+Localized.h"
#implementation UILabel (Localized)
-(void) setTextLocalized:(NSString *)aText{
[self setText:NSLocalizedString(aText, nil)];
}
#end
Then in the interface builder, User Defined Runtime Attributes :
textLocalized String your string to localized
And you don't need to declare the IBOutlet,
and don't need code this in the ViewDidLoad [testLabel setText:NSLocalizedString(#"TEST", nil)];
If you want a dynamic way of switching languages inside your app AND using a Pods based solution check out:
https://github.com/nullic/DPLocalizationManager
Install with: pod 'DPLocalization', '~> 1.2'
It supports the same standard localization files but also uses dynamic linking using User Defined runtime attributes and also inside code such as viewDidLoad.
Some examples in the example project:
self.startup.text = DPLocalizedString(#"TITLE", nil);
self.label.autolocalizationKey = #"LABEL_TEXT";
[self.label updateAutolocalizationArguments:#[#"Hello", #1234567890, [NSDate date]]];
self.autolocalizationKey = #"TITLE";
Download the git project that includes example project showing several examples.
Or you could use TraductoPro to automate this process for you and save a lot oftime. It is a Mac app that integrates well with Xcode.