iOS lproj folder nesting - ios

I'm in the process of adding French Localization for an iOS app. After turning on the French localization via the localization settings in the project properites, I ended up with a project structure that doesn't appear correct.
The "fr.lproj" folder is nested under the "en.lproj" folder and appears as follows:
/Resources/en.lproj/
...
InfoPlist.strings
Localizable.strings
..
/Resources/en.lproj/fr.lproj
...
InfoPlist.strings
Localizable.strings
..
For all the other locations where a .lproj folder exists, the "en.lproj" and "fr.lproj" folders are at the same level. However, for this location it's not. I've tried moving the fr.lproj to the same level however it causes the project to have errors. I do not see a place to edit this location after moving.

If you change the localization of the project, I think (not sure) you change the default language of the project.
If you just want to test the French localization texts, you can leave the project language setting to English. But you have to change the language setting in the emulator or on your test device to french and then restart your app. The device language setting is stored, so you only need to restart your app the first time you change the language.

Related

How to Localize Location Permission Dialog alert? [duplicate]

I've completed translating my app to Turkish using Base Localization. However, I also need to translate NSLocationWhenInUseUsageDescription key in my Info.plist file. I did exactly what I did for everything else:
Went to File inspector and checked Turkish:
Then I went to the new strings resource and completed my translation by adding this key to the localization file:
"NSLocationWhenInUseUsageDescription" = "[my Turkish description of location permissions]";
Saved, compiled, even deleted app from device and rebuilt, but no avail. When my app asks for location permissions, the explanation underneath is still the English one (I've tried including the English translation as well under Base translation file, but it didn't change anything).
Everything else is Turkish, translated just fine. It's just the location permission that doesn't translate. I've also seen How to localise a string inside the iOS info.plist file? and added the "Localized resources can be mixed" = YES key (of course, as CFBundleAllowMixedLocalizations, not literally that sentence) to my original plist but that also didn't change anything.
How can I solve the problem?
Here's what ended up working for me in Xcode 7.1.
First, go to project directory and manually create two InfoPlist.strings files, the first inside the en.lproj folder and the second inside the fr.lproj folder.
Both files should have the following content :
NSLocationWhenInUseUsageDescription = "YOUR TEXT HERE";
Since the files won't show up automatically in Xcode, you have to manually add both to the project bundle, this can be achieve via right-clicking the project name in Xcode and choosing the Add files to X option, then selecting the files you just created.
Also if you want to test the result & make sure things work, changing the Application Language in Edit Scheme > Run > Options isn't enough.
You need to change the simulator or the device language via Settings > General > Language & Region > iPhone Language
I've started over. Removed the translations, cleaned the project, and tried again. It worked. I have no idea why it didn't initially though.
My problem seems to be case sensitive:
My InfoPlist.strings had a lower "i" in finder and Xcode (infoPlist), but needs to be upper.
I changed file name and reference in the source Xcode Project and it works
(or deleted and re-create with the right name).

Strange folder structure when adding language

My app is Base language English.
I have added German, and Xcode generated automatically a folder structure that doesn't correspond to what the documentation says. (cf screenshots from Xcode and Finder).
When I run genstrings, it only generates stuff for the english strings (the german remains empty).
I manually copy then the English strings into the German strings, but Export ignores the German strings in the cliff file
What am I missing?
Two things:
First, the de.lproj folder should be at the same level as the en.lproj folder, not a subdirectory of it. Second, you can choose when exporting to XLIFF if you want to export existing translations or the development language only. You may not be seeing that option since the folder layout is currently incorrect.

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.

zh-Hant.lproj folder in project changes to zh-hant.lproj in .app bundle

While testing localization for my app I discovered that Xcode changes the traditional Chinese .lproj folder name from zh-Hant.lproj to zh-hant.lproj (notice lower case 'h') in the app bundle. Since the correct form for traditional Chinese is zh-Hant.lproj, localization won't work when the user changes their device's language to traditional Chinese therefore I have to manually load localizations when this language is set.
quick summary
folder name as seen in project:zh-Hant.lproj
folder name as seen in bundle/.app file after building:zh-hant.lproj
Why do you suppose Xcode is changing the name of this folder and of course, the most obvious question: how can I resolve it?
Thanks!
Thanks for the suggestions! I'm writing a framework which has its own localizations and turns out the app which was integrating my framework had its own localizations too, where traditional Chinese was set to zh-hant therefore even thought Xcode placed the framework's .strings file and app's .strings file in the same folder (framework's is called FrameworkLocalizable.strings while app uses default Localizable.strings), I guess Xcode has to decide which .lproj folder name to use when creating the folder for the bundle and the app's name wins.
It should be ZH_Hant or ZH_Hans - underscore.

Localization for new Files in older Project breaks App

Good evening
I want to add a new year, a new volume as plist-file to my existing app. The app is localized for 4 languages, so the new file has to be localized also. The languages were "English", "German", "French" and "Italian".
But when I do this, Xcode creates a directory "de.lproj" next to the existing "German.lproj", same behaviour for French and Italian, but not English. The older localized files are now in a directory "German.lproj", the newly generated plist in a folder called "de.lproj".
Then the app will no longer recognize the localized strings, exept the english version.
How can I add a new localized file to this project without breaking the rest?
Regards
You should use Localization Suite to manage your translations. This way, you can let loc-suite to scan changes in your original .plist file and tell you which ones are translated and which ones are not. Loc-suite can also update your localized .plist file and remove dead entries.
This question is slightly off topic at stackoverflow though.
Finally I solved the problem like this:
Make a backup of each localized file (plist and strings files) in the Finder and collect them in a folder for each language.
In Xcode, remove every localization for these files so that the only remaining language is English.
In Finder, delete the old lproj directories in the project folder except English.lproj.
In Xcode, add the formerly deleted localizations for each file. Copy the contents of the files into the newly generated localized files.
Maybe this can help somebody.

Resources