I can not make a localization in an iPhone app.
Here's what I did:
NSString *one = NSLocalizedString(#"Apple", #"Apple");
NSLog ("%#", one);
In info of application I added French. I moved the file Localizable.strings (UTF-16) to fr.lproj folder. The file contains:
/* Apple */
"Apple" = "Pomme";
I changed the language in iPhone Simulator to French, then I used Product -> Clean, and ran the project again, but it doesn't have any effect. I am getting "Apple".
What can the problem be? Maybe I'm creating Localizable.strings file incorrectly?
I think the problem is with Simulator, because when I added a French xib file I had the same problem, but I have no idea what is wrong with that.
I had learned Localizaation from this lecture and as far as i see your code is true. Firstjy delete simulator files from your directories (probably /Library/Application Support/iPhone Simulator is its path) and compile again
Related
Just spend another evening, trying to figure that out.
Here is what I am doing:
1) Creating a clean project with tabbed iOS application in XCode 6.3.1;
2) Under Project/Info/Localisations I am adding another localisation (Russian,German, doesn't matter)
3) In Main.strings file, changing corresponding strings, OR doing exactly the same by Exporting/Importing .xliff file.
4) Deleting app from simulator/device, cleaning project from Product/Clean, deleting derived app data from corresponding folder
5) Changing language in simulator/device
6) Making a run... Still English. Localised strings just wont pick up, no matter what.(even though they are looks just fine trough assistant editor)
What am I doing wrong? Is that suppose to be that complicated?
Try running on a device. Xcode 6.x had known issues with the Simulator not showing localizations.
Just got update from 6.3.1 to 7.0.1 XCode and the issue is fixed for me.
I am making exactly same steps and got Russian/German/English interface depending on the language I chose in simulator settings.
Guess that is it.
I was following one of Ray Wenderlich's tutorials on localization but I can't seem to get it working.
I've set my project up for localization in English and French and I have a locaziable.strings file for each:
The French file has the correct (well as far as Google translate goes) French versions of my string:
I'm setting the strings by calling the correct key from the localizable.strings file:
NSString* strTitle = [NSString stringWithFormat:NSLocalizedString(#"Title", Nil)];
And I have the simulator set to French (BTW: Whenever I do a language change the simulator crashes).
But it is not pulling from the correct localizable.strings file. It's still displaying in English:
Am I doing something wrong?
If you are using xcode 6.1.1 and iOS sdk 8.1,try this workaround.
It seems localization does not work with xCode 6.1 and 8.1 simulator.
Workaround:
Go to "edit schemes" >> "Run" (side bar) >> "Options" tab >> "Application Language"
Select the language you wish to run the app on the simulator.
I got this workaround from Workaround by natanavra
Thanks to him.
However I read on developer forum,that it is working in 6.2 beta version of Xcode. Hope it do.
Maybe you have run the app at some time where the file Localizable.strings already existed but has not been localized yet. If this is the case, this unlocalized file still resides in the resources folder in the application bundle in the simulator (when you build an run a new version of your app in the simulator or in the device, unused files will not be deleted). This can lead to problems.
Try to delete the app completely from the simulator and build an run again.
I have experienced similar issues (IB localization in my case) on device. So general answer would be
Device - Uninstall app and clean project by Shift+CMD+K
Simulator - Go iOS simulator > Reset Content and Settings and clean project by Shift+CMD+K
These problems are really annoying. Along with poor ability to update localized strings is localization one of the biggest drawback of iOS development.
Another problem that could cause localization not work is the encoding of the strings file. Localizable.strings's encoding must be UTF-16. The default encoding of text file in xcode is UTF-8, that cause me spending a whole day to check why the localization not work.
In Xcode 6.0 and later, Localization not work by changing language in Simulator not working.
You have to edit scheme before running your application.
Go to Edit Scheme -> Run -> Options, change language here.
Now, Run Your Application. It will Work.
For more details, check this answer : Changing language on iOS 8.1 simulator does not work
My problem for this was an incorrectly encoded character in the localization file.
Im using custom font in my application and have run into very weird issue. The font is available on the simulator but unavailable on an actual iPad.
1 I'm not confusing font name and file name. The file name is bitdust2.ttf whereas font name is BitDustTwo and this is how i call it and on simulator it is ok.
2 The is not a question of case sensitivity. The font is really unavailable on the device. I know that cause when i do this:
NSLog(#"%#", [UIFont familyNames]);
i see that on simulator my font is included in the familyNames array, but is missing on the iPad. What's wrong? Did you ever encounter such an issue?
(From above comment:) Verify that the font file "bitdust2.ttf" has been added to the target and is copied into the application bundle.
The simulator is, as titled, a simulator, and not a true emulator. The simulator runs the same named APIs, but since the simulator runs on OS X, not iOS, the simulator often has more functionality. For example, the media player classes on the simulator support more types of files (codecs) than on the device because OS X supports more codecs than iOS. On the simulator, you have more Fonts available than on the device.
Here's more details about embedding fonts in an iOS app:
There is a simple way to use custom fonts in iOS 4.
Add your font file (for example, Chalkduster.ttf) to Resources folder of the project in XCode.
Open info.plist and add a new key called UIAppFonts. The type of this key should be array.
Add your custom font name to this array including extension (Chalkduster.ttf).
Now you can use [UIFont fontWithName:#"Chalkduster" size:16] in your application.
It's important not to miss any steps. If you're still having problems, go to the Build Phases tab of your project in XCode and under the Copy Bundle Resources tab, ensure that your font file is included. If not, add it.
Check your device OS version as well as its support for iOs versions. The custom font you used must be compatible with iOS of your device.
Check this answer out. May be you need to have alternate custom font in case it is not supported.
I just had this same problem and after verifying everything was correct:
Font is added to proper key in info.plist "Fonts provided by application"
Font is added to project -> info under same key as the info.plist (this just means that i saved the plist)
Font file is added to the project
Font file is in the project folder
Project -> target -> Build Phases -> Copy bundle resources: contains my font file
File is checked off for being associated with target
I had to download the file again and re-add it.. when i did the file name was changed ... so i think the .ttf file was corrupted
You'll need to embed the font onto the app; instructions are here.
I tried to make the localization of the app name using CFBundleDisplayName.
I made the localized InfoPlist.strings according two different language.
In one strings file wrote:
CFBundleDisplayName="x11111"
and in another:
CFBundleDisplayName="y22222"
And in file info.plist, I added "Application requires iPhone environment" property, and set the boolean value to YES.
And in info.plist,the "Bundle display name" I used "x11111".
The localization worked ok on the simulator, but when tested on the device , it did not work.
On device, the name I used for 'Bundle display name' in info.plist can only be showed.
By the way, I use cocos2d for the project.
Anything I missed or did wrong?
If your localisation files were supplied to you, and you need to add them, be sure to add them correctly on per file basis. In Xcode, while you are adding files, pay attention how you add them. This is how they should look in Xcode Project Navigator.
I have added them by selecting all folders which didn't add them correctly to project.
Hi I've created my iPhone app for IOS 5.0 with Xcode 4.2. By default it is localized in English.
I would like to make the app appear on the app store with language "French".
From my understanding, I've to remove English language and add the French one, but this is causing some problems to me.
At first, each time I open my app in Xcode, english language is added by default, even if I have removed it previously.
Moreover, if I localize my Storyboard files in French, the file is moved to my fr folder in project, but this causes in "Copy Bundle Resources" a problem with the file that becomes red.
To make it work again, I've to remove the localization from the Storyboard files.
Can you please help me?