I have searched now quite a bit on Stackoverflow for an answer, but I can't seem to find an adequate one.
So, I am localizing an App with XCode. Everything works fine, I have localized a storyboard and everything. The last part which needs to be localized are the labels and buttons in XIB Files. Here I have the following Problem:
XCode Offers me to create localized Xib Files for every language or to create strings files. Both options are fine with me, but none seems to work. One answer to a similar question stated that this does not work my design. If so, why does XCode give me the option to do it in the first place? And, what is a good and easy solution for this?
And I am using Swift, not sure if that really matters, I just thought I mention it.
There is a known issue with recent versions of Xcode where the simulator would not correctly pass the language information to the app, so it seemed as if localization was not working. If that is your problem, there are two workarounds:
try your app on a device and confirm switching the language brings up your localized strings.
force the language via your build scheme (Product => Scheme => Edit Scheme... => Run => Application Language)
Related
TLDR: Xcode generated storyboards for each language, however I want the "old"(?) *.strings files. How?
I am currently in the process of localising my storyboards. After I enabled everything, Xcode generated another storyboard alongside the original (english) one for me to localise. I was surprised, I expected a Localizable.strings file, like the apple documentation still states as of April 3, 2021:
For storyboard and XIB interfaces, select the user interface files (files with a .storyboard or .xib filename extension). Xcode adds a strings file to the localization folder that contains the text to translate, as well as comments that describe the user interface components. For example, if you add German to an iOS app that uses storyboards, LaunchScreen.storyboard becomes a group containing a LaunchScreen.storyboard (Base) and LaunchScreen.strings (German) file.
I searched around the internet, in apple developer forums, watched both WWDC18 and 19 talks about localisation in Xcode, but did not find a single mention of translated storyboards.
After the initial translation, which works great due to the simplicity of just filling everything in, it gets frustrating however, since every layout change needs to be repeated for every language. This can't be intended, there must be a better way, right? Sadly, I didn't find anything. Even a hint to a piece of documentation regarding these storyboard copies would be greatly appreciated. Thanks!
There are some screenshots of the possibility to convert these two formats via a dropdown, like the third picture in this post. However for me, there is no dropdown next to the language item when I click the storyboard, neither on the group, nor individual base or localised ones:
Is this a bug or am I missing something here? I am using macOS Big Sur 11.2.3 with Xcode 12.4 (12D4e).
Turns out, you need to use the Base Localization feature, the dropdown then appears and you can convert existing storyboards to *.strings files.
I am facing a very obscure issue.
I've got an app that needs to be localized in three Languages, English, French, German. There's multiple localization files as I've got multiple storyboards ( each storyboard has one for each language).
Everything works great and things translate properly except for ONE file in ONE storyboard in ONE language. So this specific storyboard I call "Authentication" works for all languages except for the German one.
I've checked. the file is:
included in all targets
is also found in Build Phases copy phase
has the correct name.
has the correct formatting (in fact i am not allowed to build at all if the formatting is not correct in this version of Xcode.)
I am out of ideas and resorting to asking here to see if theres anything i might be missing in my series of checks.
Thanks all
SOLVED.
The answer lies within my third point
has the correct formatting (in fact i am not allowed to build at all
if the formatting is not correct in this version of Xcode.)
Beware everyone. This might seem like it is the case but it does not apply to everything. If there's a syntactic error in the Localizable.strings file, xcode will let you know and refuse to build.
HOWEVER if there's a syntax error in the YourStoryboard.strings file, the process of building will go on UNHINDERED.
Since an issue in syntax was halting everything for Localizable.strings i was wrongfully assuming that such a check would take place for all translation files. It doesnt!
Hope this saves someone in the future
My storyboards appear to be translated when previewed in XCode but when I install the app on the device nothing is translated to other languages. Here is the checklist.
Storyboards are all translated:
I have some duplicates here - perhaps the reason it is not working:
And finally local file structure on my computer:
Question: how to verify correct file linking or any steps to find the issue of Storyboards not working on the iPhone or Simulator.
You need Base.storyboard and other should be ##language##.strings. Inside these files you will translate things corresponding to ID of the element.
You can check explicitly if the string is translated by calling something like:
NSLog(#"%#", NSLocalizedString("AWO-r7-rD4.text",nil));
You should put instead of "AWO-r7-rD4.text" one of the IDs from Localizable.strings for storyboard.
For comparison:
I have Auth.storyboard, and it can be nested to: Auth.storyboard(Base), Auth.string(English), Auth.String(French).
One stupid thing: Have you changed regional settings in simulator settings?
Hope it helps.
I'm trying to localize an ios app after it was launched.
We should be able to select the desired language on the startup screen.
The app is already localized and available for 13 languages.
The only solution I found is to set the locale and relaunch the app, but we can't really do that, as it's not user friendly, and Apple will probably reject it.
The project contains most of a thousand of xib files, so I can't change all the resources "manually" either.
Is there any solution to reload the UIApplication ? Or an other trick to change the locale on the fly (and allowed by Apple) ?
I found lots of threads which were talking about this, but none very interesting compared to the scale of the project.
I don't think there is a way to do what you want without coming up with a custom solution. I found a solution on StackOverflow here where a user created his own localization solution.
I was wondering if somebody could explain in the details how I can localize an iOS app using only 1 storyboard. I know how to localize by creating several storyboards(one storyboard for each used language), however I'd like to find out another solution.
Thanks.
The tutorial on raywenderlich.com uses two forms of localization together. The reason is he also checks the storyboard when turning on localisation in image 3:
.
So then what?
NSLocalizedString is very useful, any text set programatically can (and should) be localised using this method. Ray's tutorial is still very useful.
However, it's not very desirable to create a clone of the storyboard(s) to do translation, it's just not very maintainable in the long run.
And what about storyboards?
The magic happens using the Base Localization feature. Base localization uses the generated objectId's to 'map' different languages to the storyboard.
Do note that this feature is only available using SDK 6.0 and above. Running the app on a lower iOS version will not cause any errors, it'll simply won't work.
Go to your project, and select Base Localization, then add any other language.
Open your storyboard file and check the new language as well. Note the icon is not a storyboard icon, but a simple text file icon. That's a good thing; it won't copy the whole storyboard this time :).
Note how there is now another file 'under' the storyboard. Xcode automatically generates a file for every language you select.
You can se Localization feature for this. You need to add the Localizable.strings file for each supported language and use it for locaization.
You need to use : NSLocalizedString() for fetcing data corresponding to each key.
Check this tutorial for details.