Localization for new Files in older Project breaks App - ios

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.

Related

Xcode 10 - How to refresh localization of a Siri shortcut intent definition file?

I have an intent definition file for a Siri shortcut. When I click on localize Xcode does very well create a localization file, each string beeing used is present with an ID.
But how do I refresh this if I added a new intent in the same file or just added a new possible response to the same file?
I currently only found two ways:
Delete localization and set up new again (which makes you loose all translated strings in all languages besides default).
Export all translations for the whole app and reimport (which leads to problems if your complete app is not yet ready for new localization export/import).
So, does anybody know a way to refresh the auto-localization of an intents definition file?
I ran into the same problem lately, and I managed to fix it with a simple workaround and two small, quick and dirty scripts:
Be sure to have your old localizations .strings files in your git repository
Uncheck all your .intendefinition localizations (and delete them)
Check back all your localizations, it will recreate the .strings files, but without your old translations (hopefully, they are safe in git)
DO NOT COMMIT THEM (yet)
For each .strings file run my little script this way: {script-path}/update-modified-strings-file.sh {project-path}/xx.lproj/YourIntents.strings
Check if everything is ok
Commit
Live long and prosper...
Please be sure to put both scripts in the same directory:
Shell script to call: https://gist.github.com/letatas/221ea3d04e70996d026362de57c1b084
Swift script called by the first: https://gist.github.com/letatas/9a58ad4f0a979b19579334bd80516f4a
The first script checks out the old version of the strings with your existing translations, the second merges the new file containing new entries with the old existing translations.
Hope this helps.
I wish Apple would fix with this.
In the meantime, the easiest way of dealing with it that I've found is this...
Add support for a new language in your project. For example, add Australian English. Then you'll get a new .strings file with all the new keys in it with the values from your intents definition.
Paste the contents of that into your existing English version and delete support for that new language.
If you want to get the new keys merged into your existing localised .strings files then you can use this https://github.com/Flinesoft/BartyCrouch Once it's installed you can run bartycrouch update and it'll sync the changes into all your .strings files.
I have the same question, i played around with this exact thing tonight. From what i can see, i have to remove all localized files and recreate them, just like you said...

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.

Resource files are not displaying in Localization

Only one Resource file is displaying When i'm adding Localizable.strings file for any language. My steps are,
Selected My main app's project file in xcode and found info option is there
in info - Localization - + option
Note: there is only one resource file (InfoPlist.strings) is available to add Language.
3- then Finish, but there is no Localizable.strings file is displaying in xcode but there is InfoPlist.strings file displaying.
But if i do these same steps in sample app which is working fine , I can able to select Multiple resource files And also I can see many Localizable.strings & InfoPlist.strings
in xcode.
Like:
Localizable.strings (English)
Localizable.strings (Spanish)
InfoPlist.Strings (English)
InfoPlist.Strings (Spanish)
Can anyone please tell me the solution to add multiple resource files when localizing any language?
If you want to make your app to support multiple languages, then you'll need to add .strings files to your project, make sure that you should name it "Localizable.strings" only, and need to put in particular language folder,
See this question and my answer there,
Localized filename should always be named Localizable.strings, and that file is within the particular language folder, for English, en.lproj and for French fr.lproj like wise.
Localizable.strings file should be inside the Base.lproj folder.

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.

iOS Localization how to add an existed folder with localization files

How to add an existed folder with localization files.
I have an existed project with english as base, then have en.lproj.
And I have other localization files in file system names with ja.lproj.
However, If i directly import folder ja.lproj to xcode, seems not work, in project tab, it shows 0 files localized, and while start app, it will crash.
I know it may work, I choose one english version file, add plus in file inspector, then will add another lang version, however, it's not convenient, and new file will locate in en.lproj sub-folder, it's strange.
anybody can help me ?
Thanks a lot!
I don't think you would be able to do that with folders. Although you can do that with files. Just define different versions of the same file for different languages. Like this:

Resources