Several localizations yet still showing English only - ios

I decided to merge several of my projects into one project using the same code base and use different targets for the different versions of my application.
My application is translated to 7 languages with English as default. The other languages are: Swedish, Dutch, German, French, Polish and Spanish. The translations worked like a charm before. I am using the NSLocalizedString and have my Localizable.strings which is translated.
However, now that I merged my projects together, and also added the InfoPlist.strings file, the application incists on using the default texts (English). When I start the application and get the "share location" question, I get the question in the localized language (So the OS does get the localization), but the rest of the application is still in English.
The files are correctly translation and have no errors. I have tested several languages, but all are in English.
If I set the CFBundleDevelopmentRegion to e.g. Swedish, the whole app is in Swedish instead. So the localizations work, but the app ignores the system setting.
Am I missing something?

I found the answer to my problem. I have several strings files, one for my app translation, and one for each target called InfoPlist.strings which contains just CFBundleDisplayName and CFBundleName for localized app name. These cannot be included into the Localizable.strings since these are different for each target.
I removed the InfoPlist.strings files from my project and now the app is localized again.

Related

Localization in Xcode not working. Changes in Main.strings aren't applied

I'm trying to translate iOS application into three languages (English, Polish, Serbian). Currently it is in Slovene. But I have problems with localization. I have set localization in Project/Info for all languages. Now I have four Main.strings files for each language. I have inserted the appropriate translations for each language. The translations are for UI elements that are located in Storyboard. Before I ran my application I have edited scheme and set application language to Polish, but it did not translate the UI. It was still in Slovene. Did I forgot something ?

Should I have Localizable.strings Base or English?

Following Ray Wenderlich tutorial (https://www.raywenderlich.com/180356/ios-internationalization), the Localizable.strings is as following. Notice there is no Localizable.strings(Base)
But in some other tutorials, they would use Base instead of English, so did I in my project as follow.
My iPhone's preferred language order is English then Chinese and is currently set to English. But whenever I run the app, it goes to Chinese except when I explicitly edit scheme to ask Xcode to run it in English. Does that mean I should have Localizable.strings (English) instead of Localizable.strings (Base)?
Another question, I have Main.storyboard (Base) and Main.strings (Chinese (Simplified)) under Main.storyboard. But no matter what I do, the storyboard always shows up in Chinese version. What have I done wrong?
=== Update ===
I played around with it (simply remove and recreate, nothing changed), and then magically the localization works as expected: The app default to English, which is my system language, and switches to Chinese when I edit scheme. However, now my storyboard is stuck with (Base) version no matter what I do.
I am no expert on this, but as I understand the Base file is a fallback if your app doesn't have a Localizable.strings file for the user's device language.
So if you have English and Chinese as localization files, but your preferred languages are German and Japanese, the system will check the Base file for strings.
In your case you have Chinese and the base files. English is not found, so it takes the other preferred language (Chinese). Therefore the base strings are not used -- the app defaults to the Chinese localization.
To solve the problem, you need to make an English strings file in addition to your base strings.

Default language not working in iOS app

I have such problem:
I have localized my app for two languages - English and Polish, with English being set as the Base one.
I set developmentRegion to "en" (also tried "English") in both info.plist and project.pbxproj files.
My translated texts are contained within localized Main.strings and Localizable.strings files.
So everything should be fine, yet when I set any language other than Polish or English the app does not fall back to the Base (English) one, instead stays on the last used, supported language. (i.e. Polish if I recently changed from Polish to lets say French).
Can anyone help me ?
Ok I see now. I thought that whatever unsupported language I would set in system settings, my app would always revert to English (Base).
That's not true.
When selected language is not supported then the app is taking the language that is the highest on "Preferred languages" list in system settings. Only if none of these preferred languages is supported, then the base one is selected.

Does my Base Internationalization storyboard have to correspond to a fallback language for all unlocalized languages and strings?

I've looked through some internationalization documentation and videos on apple developer, but I never found an explicit answer to that question. In Apple's tutorials I see the Base.lproj folder alongside en.lproj and zh.lproj -- the example translation (localization) is from English to Chinese. But they tell me that there's a file en.lproj/myStoryboard.strings, and that is confusing. I can't see the point in creating an English localization for the storyboard (that is already in English).
So my questions are if the user will ever see the strings in the Base.lproj/myStoryboard.storyboard?
Do the strings in that file have to be the default strings that are shown to the user if the system cannot find the user's preferred language folder in my bundle?
Can I explicitly say "never use Base.lproj/myStoryboard.storyboard, always fall back on en.lproj/myStoryboard.strings"?
In other words:
Let's say I want my app to display in English whenever the user's language isn't available, but that my Base.lproj/myStoryboard.storyboard is in Swedish. Do I then have to localize the Base Storyboard to sv.lproj/myStoryboard.strings and translate all strings in the Base storyboard to English to accomplish this?
In my case, XCode 5 didn't create a en.lproj/myStoryboard.strings, there's only the original storyboard in the Base.lproj folder. Maybe it's an old XCode issue?
Try to remove that file and see if your app gets along with Base.lproj for default, English strings.
Your Info.plist file should have an entry Localization native development region, which points to the lproj folder to be used in case the required string doesn't exist in the preferred language.
I'm not sure about this, but I think you have to use en and UI with a Base.lproj would automatically fallback to Base.lproj.
Does that help you in any way?
So my questions are if the user will ever see the strings in the Base.lproj/myStoryboard.storyboard?
It is the default to use those strings for the development region localization, which is typically English. If there was a matching strings file for english, it would supersede the strings in the storyboard. This is typically redundant, so it isn't normally used. If you really want all of your languages to be handled identically, you can do this.
Do the strings in that file have to be the default strings that are shown to the user if the system cannot find the user's preferred language folder in my bundle?
These are unrelated concepts. The strings embedded in the storyboard are equivalent to having ones in en.lproj. After that, language fallback works the same as without Base.lproj.
Can I explicitly say "never use Base.lproj/myStoryboard.storyboard, always fall back on en.lproj/myStoryboard.strings"?
If you have en.lproj/myStoryboard.strings, and english is the development language, they will always superseded the strings embedded in Base.lproj/myStoryboard.storyboard for English. Including when English isn't the preferred language, but ends up being chosen as the fallback language.

How to use a language other than english, but still use NSLocalizedString with english?

I couldn't find any similar questions, so here we go:
I am working on an iOS app that for the first release will only be in french, but we plan to release an english version as well in the future. At this point, I thought it was a good idea to use NSLocalizedString for all the text, so that the app will be ready when the english language will be required. However, I would really like to use english as the key value in my code:
aString = NSLocalizedString(#"Yes", #"Text for positive answer");
instead of
aString = NSLocalizedString(#"Oui", #"Text for positive answer");
Then I want to run genstrings, and localize the .strings file in french (and give it to the translators). But if I do it like that, how can I get rid of the "original" english .strings file? Am I totally wrong here, and do I have to use french for now in my code?
If you are developing the app in English and localizing it into French, I wonder why you would want to actively prevent the app from running in English. If some users in your target market (France only, I imagine?) prefer to run their iOS device in English language, why deny them their preferred language? Or is it because you won't be doing QA of the English version and therefore don't wish to expose it yet?
In any case, I believe that you can restrict the list of supported languages by simply editing your project metadata. In XCode the list of supporting languages is shown on this page -- simply remove English and I believe that your English localizations, even if they are present in your project, won't be used (I haven't tested this but I doubt it would delete your existing English files, it should just remove them from the application's supported languages list)
You can do your whole project in english, keep english words for keys in the localizable.strings files, but keep only the fr.lproj folder, and in the plist set the supported languages only to french.

Resources