Experiencing An Issue With Localizable.strings in an iOS iPad App - iphone

This is the first time that I have attempted to add some localization into an app using Localizable.strings files and I am experiencing an unexpected issue with it. For clarity, these are the steps I have gone through.
File >> New >> New File and added a Resources file of Strings type.
Named the file 'Localizable.strings'
Clicked into the Localizable.strings file and added Spanish through the Localization section. (I have confirmed in my project folder that I have the en and es folders).
Started to add my KEYS in the Localizable.strings (English) file and then add the Spanish translation into the Spanish file.
As an example, this is one of the localizations I am trying to add.
"CAMERA_ERROR" = "The device does not have a camera";
I am added the exact same string in the Spanish .strings file, but changing the text to suit Spanish. Within my app code I am using the following:
NSString *cameraError = NSLocalizedString(#"CAMERA_ERROR", nil);
Everything seems fine up until this point, but this is where it gets weird and I get confused. If I run the app on one of my iMacs it works fine and depending on what language I set the simulator to it displays the correct English or Spanish string.
However, when I run the exact same app on this MacBook Pro it doesn't display the string, it instead takes the "KEY" title and displays that. So instead of showing the message as "The device does not have a camera" it shows it as "CAMERA_ERROR". The code is exactly the same as it is the same project cloned from a git repo.
Can anyone shed any light on this? Any setting on the MacBook that could be different?

Try doing the following on your MacBook Pro:
clean the project;
remove the app from the simulator/device;
rebuild the app.
This should fix it.

Related

iOS App doesn't work in other language

My iOS-App was first German and English. As it was just a fault, I removed the English localization. Somehow if I change the language in the iOS Simulator to english not it loads the old storyboard that doesn't even exist anymore. I cleaned the folder and there is now only a base storyboard. Although I cleaned the Project the App is still crashing after start (because it's loading an old storyboard of prior App version (I removed english localization in 1.1, and now in 1.2 it still loads the 1.0 storyboard).
This is really weird, how can I achieve that the App ALWAYS uses the same storyboard, no matter which language? I already removed the english localization!
Thanks very much!
From my understanding based on a previous experience, if you are localizing an application you need to keep the English one. Because it will default to English if the device is not set in the language that you are supporting.
(Have you notice in the setting app how english is always the second choice and that you can't change the order like on the desktop to default to something else before english)
So if you are planning on supporting only 1 language remove all localization into your application. Because other wise it would default to a non-existing asset and crash.
That would be my best guest for a try.
Have you delete the application on your device after all those change and a clean up may be necessary. I've notice that file, (especially not code file) that get deleted have a tendency to lay around the executable.
And if you get file (1) b.xml and (2) fr.lproj/b.xml even if the device if in french the french one (2) won't get used. The system will see (1) first and think there is no localization for that file.
As for "losing" your German Xib. If you take a copy out of your de.lproj (and put that copy up a directory in the file system it should work)

Which file contains Localization info in an iPhone Xcode project?

I am working on a iPhone app and trying to add a German localization. And we are using TFS for version control.
I have added the German strings file all right, but every time I restart Xcode, the Localizable.strings(German) is gone. The file still exists on disk, but just not included in the project. I believe it's because some controlling file is read-only. I have to find this file and explicitly check it out. I cannot checkout/check-in the whole project because the guy integrate the code will be mad.
It's the xxxxx.xcodeproj folder.

IPhone sdk: Internationalization doesnt works

Recently I have made intenationalization support for my project.
But there occurs strange thing - when I'm running my application both on the device and emulator shows only 'default' language.
I've done following things:
Used NSLocalizedString everywhere
added InfoPlist.strings (another language)
May be I'm missing something ?
Thanks.
You should store your localized strings in Localizable.strings. Localized InfoPlist.strings is used to change the name of your app for example.

Adding localizable files to project on Xcode 4

I'm developing an App that needs Localization.
I've followed these steps:
I've created the es.lproj, it.lproj, en.lproj folders in the root of the project with finder.
I've created the Localizable.strings file in each folder with the key pair values corresponding to the target language.
I've imported with Add Files To option from Xcode.
When I test the App in the iphone simulator all works fine. I configure the iphone to any localizaed language and the app is translated properly.
But when I run the App in the device, only shows the strings in english.
I've made a test following these steps.
From Xcode 4 right button over Supporting Files Folder, New File.
Create Localizable.strings file
In file inspector, section Localization. I've added the rest of languages. Creating the file like a folder with all Localizable files in the tree.
In the root folder of the project, the xcode created a folder for each language.
After editing every file, I've executed in simulator and all works fine. I've tested in 3 different devices and the only language is English.
In the Project -> Info -> localization I've added every language.
In the Build Phases I've observed that only is referenced the Localizable.string file in the en.lproj folder. I've tried to add the rest of files, but only accepts one more Localizable file. I've tested in device with the "extra" added language but doesn't works.
Can someone help me please?
Thanks in advance.
Try this: Remove the app from the device, clean project, make sure that the files appear in Build Phases>Copy Bundle Resources and run again.
Are you sure you are testing properly on your device ? I just tried making a simple localization test, just a Hello world in different languages, and when i
I used Xcode 4 and followed the same steps as you. Changed my device language, reloaded the app, and there it was.
You might need to do a clean install in order for this to work. Do the clean install after you changed your device language to "something you haven't seen yet" ;]
Maybe this tutorial can help you : Localization Tutorial with XCode
Have you tried to delete the app from the device and then reinstalling?
EDIT: I have checked in a project of mine and the names I see are: English.lproj, French.lproj, etc.
Don't know if this could make a difference, but you could try it. Also, you can go to the app binary for the iPhone with the Finder and select Show package content to inspect its content and make sure the localization files are there This could help to pin down the problem...
If it can be run in the simulator ok, but the device has a problem with the localization, then the link provided here by Nils Munch has the answer. In troubleshooting it says "Unlike the iPhone simulator, the iPhone only recognizes strings files that are formatted UTF-16. Always test your localizations on the device, as the simulator and the device do not always behave the same way."
I think the problem here might be the file is UTF-8. The simulator can handle that but the device can't.

Why is my iPhone application not using the proper localization?

I have an iPhone application that initially had only English and German localizations. I just added a French localization, but when I change the user language to French it still shows the German strings.
What could be causing this odd behavior?
Are you testing this on the simulator or the device?
Often the localized folders (.lproj) directories aren't copied into the bundles during a clean build as they should - even with a 'Clean & Clean all targets'.
Ensure this happens correctly by deleting the app from the simulator (easiest way is to 'press and hold' on the app icon in the simulator, then delete). Also, ensure the simulator doesn't keep hold of the old app data by manually deleting the app.bundle dir from the iPhone simulator directory using Finder.
Build, clean, run. Should work properly then.
If not, make sure the fr.lproj exists in the bundle after the build.