Error when localize ios app to support multiple languge - ios

I have two questions
Have any tutorial for localizing iOS app to support multiple language with app not using storyboard?
I doing my app without storyboard, I localized it by created Base.lproj folder in my project direction, copy .xib to it, and added language in Project->Info->Localization.(I tested successfully on demo) but with my app when I build and run on simulator my app doesn't update according to setting language on simulator, it only update when I rebuild. Anyone could give me a reason or doubtful questions?

When you localize resources in your Xcode project, you don't need to copy anything: Xcode does everything for you. If you start copying things here and there, you might get lost, and files might not even get copied to your app bundle.
What you need to do is:
1/ Reference all languages in your Xcode project
2/ Create a new "Strings" file in your project using Xcode, call it "Localizable.strings", and create localized versions of it through Xcode, using the "Localization" pane in the File inspector
3/ Once you have created multiple versions of your Strings file, enter a sample string that you will test in your app, like:
"HELLO_STR" = "Hello, world";
in your English version, and
"HELLO_STR" = "Bonjour tout le monde";
in your French version.
Then in your application startup code, add this line:
NSLog(#"%#", NSLocalizedString(#"HELLO_STR", nil));
The message logged in your console should now correspond to your device or simulator language setting.
4/ You now need to add all localized strings to your Localizable.strings files.
5/ As for the XIBs, it works exactly like the Storyboards: you can ask Xcode to create a localizable version of all your XIBs. They are copied and bundled by Xcode in much the same way as the strings file we already built in steps 1-4. It is better to do that once you have "finished" designing your interfaces, because any subsequent modification to one localized XIB version will have to be repeated in all other localized versions.
Good luck.

Related

Xcode 10 - Unable to Localize UINavigation Controller Title

I have an app that I want to translate to Spanish. The app is very simple and uses a basic UINavigation Controller. The title is set in the main story board:
To add Spanish I did the followings:
Added Spanish in the project Localizations
My first question to you all is why is showing 4 files in English and 3 Files in Spanish, when I actually have 2 files for English and 2 Files for Spanish
I enabled location to the view controller
I added string file to the project as well. This is for labels and dynamic text within the views, and this is working as expected.
Edited the Main.strings (Spanish)
When running the app, I edited the scheme, and set the application Language to Spanish.
When the app launched and got to the main screen, I still see Welcome instead of "Bienvenidos" What am I missing?
Other things you should know, when adding localization I enabled and disabled this feature a few times for the storyboard trying different options. Also, when testing the app, I change the settings language to Spanish, I deleted and installed the app multiple times as well.
I'm using Xcode 10.1, Project Format is Xcode 9.3-compatible, iOS deployment target is 12.1
Hope someone can help.
Hope this helps someone else. With Xcode 10 the recommended way to do any localization is by selecting your project and perform an export for localization, just go to Editor > Export For Localization
Once you exported the project, make any changes to the .xliff files, images, etc.
In the .xliff file, each translation should have a <source>, <target> and <note> tag. In my case, many tags are missing. I manually added them, did the translation and import the translation into my project.
To import the localization just select your project and go to Editor > Import Localizations. Now everything should work as expected.
This video from WWDC helped me resolve my issue
https://developer.apple.com/videos/play/wwdc2018/404/
Hope this helps
For your first question, you probably have also localized your LaunchScreen.storyboard file. So you should have 3 localized files in total, except that for your Main.storyboard you have checked all three checkboxes (Base, English and Spanish) and since English is your development language, it counts for two.
As for your second question, if you're running in the simulator, just editing the scheme should be fine. Since you told that you enabled and disabled localization for your project something might have broken with Xcode. I've been there as well when I tried to remove a localization. Try to clean you project (Product -> Clean Build Folder) before running the app or even start the project from the scratch (if possible) without this adding/removing flow. Hope this helps.

iOS: Localization gone wrong

I'm starting to get confused..I've wanted to finally add my translation file for all strings to my app according to ray wenderlich's tutorial. But somehow now everything got messed up. I removed now every localization again, which deleted my strings file, the storyboard etc. And now I have no localization language set in the project settings and I've copied all files back from the trash.
But my localized string (NSLocalizedString(..)) somehow don't load..or load something else. I've changed some of them to check if my strings file in the project explorer is actually used but it still uses the old strings and I have no idea from where..I've checked the project folder and there aren't any other files.
How can I set up everything again that it works? How can I set the strings file it should use? And how should I set up then the localization, with or without base language?
Edit: And in the simulator I cannot get my app running..it's showing only a black screen. Whereas on my iphone it still works (if I use my iphone from Xcode).
I guess I've deleted all my languages in project settings and now I cannot add any localization anymore :-(
Here's what I would try:
Check your project folder for any leftover .lproj folders / .strings file and delete
Clean / Build
Start localization from scratch following SmoothLocalize's Tutorial
This should delete all old files and create a new default localizable.strings, and then you can add more languages.

Adding localized files to a new IOS 7 app

I'm starting to studying app localizations and I'm stuck at the very beginning.. I've created a new project called LocalizedStrings2:
I click the plus button to add Italian Language and it offers me to localize 2 InfoPlist.strings files:
Is this correct? BTW, I add the italian language:
Then I've wrote the following code in the English InfoPlist.strings file:
"ERR_MSG" = "Error Message!"
The following line has been entered in the Italian version of the file:
"ERR_MSG" = "Messaggio d'errore!"
When I compile I receive the following error (I have the same error even if the two files are empty:
Any hint or good reference for up-to-date How To Localize my IOS App documentation?
Thanks in advance for any help!
Gianni
I was facing the same problem for many days. Then I figured it out…
Just put a ; at the end of the line and it's fixed! :D
Recommendation
I don't think you should have two English references to your file in the UI. Change one to italian and verify that the files are in the proper location in your finder folder.
I would then consider removing the file references from the project and re-add them. I've noticed some peculiar behaviors when using localization for older versions of the SDK in Xcode 5+. BTW - If you are planning to support a deployment target of iOS5 you will need to remove the Base localization setting and just create the localization folders manually (inside the project folder in Finder). After you re-add the files I would check the Build Phases > Copy Bundle Resources > search for plist to verify that ProjectName/(localization).lproj is found.
NOTE
Please check out the updated documentation and let me know if that is a sufficient answer.
Internationalizing Your App
I guess the second InfoPlist.strings file derives trom your tests.
Check out the "Supporting Files-Folder" in your apps test target.

Xcode 4.4 changes to localization - how do I NOT localize main storyboard?

I'm localizing an app for the first time, and only need to localize my "Localizable.strings" file. To set that up I created the file, then selected it and pressed the "Make localized..." button and it let me add an English localization (I haven't added any other languages yet).
To my surprise, with Xcode 4.4, doing that also automatically localized these files, moving them into the "en.lproj" folder:
InfoPlist.strings
MainStoryboard.storyboard
I don't need or want to localize the storyboard file, as there's nothing in it that's language based... and as far as I know, I don't need to localize InfoPlist.strings either (unless I decide to localize the app name?).
So, how do I unlocalize a file?
I see there's an option for "Use base internationalization" which from my understanding would use a base main storyboard rather than localizing it. That sounds like what I need, but according to the Xcode 4.4 release notes that won't work on iOS projects:
The Use Base Internationalization setting in the project editor works
only on Mac products for deployment on OS X v.10.8 and later. Xcode
must also be running on OS X v.10.8 or later. This setting is not
supported on iOS projects. 11712855
https://developer.apple.com/library/mac/#releasenotes/DeveloperTools/RN-Xcode/_index.html
Thanks for any help.
If you select a file and look at the info for that file. Under the "General" tap there is a section for localization with a +/- for the various languages. Just remove all the languages from there and it will no longer be localized.

Remove an iOS app localization

In Bombr 1.2 I added a half-assed French localization, over time adding more strings to localize I've decided to drop the French localization. In Bombr 1.2.1 I removed the reference to fr.lproj/Localizable.strings from the Xcode project but the file still exists. Now that 1.2.1 is on the app store it still says that French is a supported language.
Will removing the fr.lproj folder and resubmitting correctly display the supported languages (this is my hunch), or is it possibly that iTunes Connect will not allow you to drop support for a language?
(I took a year of French in high school for fun, but not enough to translate my own app.)
Building on the answer given by #vanya, select your project from the list and delete the language under in the "localization" section.
If you want to remove app metadata localization, there's a delete menu on iTunesConnect
try to look at the info.plist which defines localizations and I guess some work in iTunesConnect should be done as well, but before approving an app
To remove the localization from Xcode (I'm using 4.2 on Snow Leopard) click on the file/folder in the sidebar, "Localizable.strings" and open the File Inspector (keyboard shortcut cmd-opt-1 or View > Utilities > Show File Inspector in the menu bar). You'll see a Localization pane with your localizations listed. Select the one you want to remove and click the minus sign to delete it.
So I landed on this question, but with some specific criteria:
I want to remove the base development language (English)
I want to keep the localized language (French)
None of the above answers worked and I couldn't find anything better on Stack Overflow. Eventually I found this gem: XCode: Remove localizations on build.
I develop in English, so the entire base of the app is in the English localisation. I then translated it into Finnish for the first release, but the intention was to only release the Finnish content and not the English.
Setting up a small script during a final Build phase works wonders to strip unwanted localisations:
#Remove english
rm -r "${TARGET_BUILD_DIR}/${PRODUCT_NAME}.app/en.lproj"
# Remove base (iOS 9)
rm -r "${TARGET_BUILD_DIR}/${PRODUCT_NAME}.app/Base.lproj"
Then I had some runtime errors because some Storyboard files were localized and located in the Base.lproj folder. I worked around this by doing the following:
Un-localized those Storyboards (unchecked all languages) and then "Moved to trash"
Dragged the Storyboards from the trash back into the project. (Basically moving the Storyboards from Base.lproj folder – which the script would delete – to the project folder.)
Note: none of these Storyboards were actually localized (the .strings files were all empty). All the translations were properly set in code using NSLocalizedString.

Resources