Localizable string not found in strings table in iOS 9 - ios

I work in a company that has an app in production with a localization bug in iOS 9 only. The app shows the key of the localized strings, not the values. Apparently, it can't found the corresponding string in the table. On iOS 8, the app works fine.
I don't know the source code well, but I made sure the file Localization.strings is there, in the right bundle, with the correct target. I'm pretty confident the resource is there, because of tests I made and mostly because the strings are there in iOS 8!
I looked for changes in APIs in iOS 9 but couldn't find anything related to my issue. I also ran the plutil command on all the .strings files and I got OK for all of them.
Any clue as to where to look?

It turns out the app was using multiple Localization.strings file for specific localizations (tweaking the bundle and Localization system). Deleting all those files (with duplicated names) and replacing it with another system (a plist file, mainly) made it work correctly.
It seems obvious there was a conflicting name issue here, but I'm still puzzled by the fact that it worked with older iOS (8 and under).

Related

How to change localisation from storyboard to strings file

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.

Xcode 9.2 crashes exporting or importing xliff

I can see that this is a recurring problem with all sorts of Xcode versions. I'm using the latest non-beta build (9.2 9C40b).
I have already localized in Spanish. Doing that involved successful exports and imports of xliff files, with same Xcode. So what changed?
I am now trying to localize to another language. This is a showstopper. Any hints? I have looked through all the posts about previous versions crashing, and have not found anything that works.
(And before you mention it, I am done and over with genstrings. If it exists anymore.)
I've discovered that large .xliff files (more than about 6,500 lines or 1,200 <trans-unit> elements) cause Xcode 10.1 to crash consistently near the end of an import operation.
The work-around is to manually split the .xliff file into two distinct .xliff files, each containing a subset of the <file> elements in the original file. You can then import the two resulting .xliff files into Xcode separately without crashing.
Do not translate "bundle name"
I wanted to translate to Greek Language and every time I was importing xliff files, Xcode was crashing.
I realized that the problem was, that I was also translating "bundle name".
If you did the same mistake, open xliff file, find:
<trans-unit id="CFBundleName">
<source>NameOfYourApp</source>
and delete the line
<target>...</target>
After that everything worked perfect for me!
Here's a workaround. Select your project icon in the Project Navigator. Select Info at top (as opposed to Build Settings). Under Localizations, click the + button and add your new language.
Xcode will create the new .strings files and fill them up with pre-existing translations. (If there are any.) Strangely, for me, some of the new .strings files were filled in with English, some with Spanish.
In any case, you have the new .strings files and can manually paste in the translations for the new language. If your app doesn't have too much user-facing text, this isn't onerous.
But really, with this problem going back to Xcode 4 (!) one would think it would be fixed by now.
it's a late answer I know, and I'm using Xcode Version 10.1 (10B61) already.
In my scenario, I added Chinese Hong Kong (zh-HK) language under Project > Info > Localization and exported successfully then sent to the agency for translations. After few days they sent to me Chinese translated text within. At that point, everything seems correct for me by eye. But I've tried 10 times to import file and it crashes 10 times without exception! Which makes me sick. I use to checked to see the difference between 2 document via Apple's File Merge App. I understand that agency geniuses added few missing <\target> tags. Hmmm, that means while exporting Xcode didn't add for some translations <\target> tag. Interesting...
I removed those unnecessarily translated tags and checked everything was equal in 2 documents except translations of the words to the Chinese language.
Tried to import again. Then BOOM! It works like a charm! I was surprised by this. It's so weird that Xcode never shows me a descriptive message about my mistake. Probably, It's just a parse error for Xcode.
Whatever, I hope this will work for someone else.
Best.

iOS App Localization: Storybords Translation

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.

Xcode 6: iOS doesn't use storyboard localizations

since I upgraded my Xcode project to Xcode 6, my storyboard localizations don't work.
I have:
A base localization as storyboard file (which is basically English)
Four string files: English, German, French and Japanese
Until Xcode 5 those worked without any problems.
But since Xcode 6 I have the following situation:
The application only uses the labels used in the base file when running on a device/simulator
BUT my Localizable.strings file, which I have in different languages for all non-storyboard related localizations, works perfect. (So in the end I have a mixture of languages while running on a device)
Since Xcode 6 there is the possibility to see the localizations as a preview screen in the assistant editor. Everything works there.
So: the only thing that doesn't work is the localization of the storyboard while running
Does anyone else have the same problem and is there a solution?
Update: With Xcode 6.1 GM the localization on the actual device is correct now but the simulator is English only, even if I choose another language in the simulator.
I am experiencing the samen problem. I have been struggling for hours getting my localized storyboard to work in Xcode 6.0, until I read your question. Then I tried the second GM of Xcode 6.1. There, my UILabels were localized properly on the device (not in the simulator). However, my UITextView did not get localized, which took me another 30 minutes to figure out.
Hopefully, this will be fixed soon.
I thought I had the same problem as I couldn't see any of my translated texts appearing in the simulator. I tried using a dummy new project and it worked which made me not so sure about what the problem was.
Then I decided to use a dedicated editor for the translation. After exporting, translating the files via the editor and importing them, I could see the correct texts in the iOS simulator. So I guess that it was the way I edited them manually which caused the issue.
FYI, the tool I used is https://poeditor.com
I've been experiencing the same issue. The solution is: you need to clean (shift-cmd-k) a project first, then you build and run it.
Try to switch localization files to “interface builder storyboard” instead of “localizable strings”. For some reason in my project Storyboard.storyboard works, but Storyboard.strings doesn’t. Probably xcode bug.

NSLocalizedString returns text that is defined nowhere

OK, I am officially flabbergasted. I started an IOS project some time ago, and juggled around with localization a bit at the start, which became a bit of a mess, because I did not know how to do that properly yet.
Now I have decided to do the localization from scratch, and therefore threw away all the .strings files, and created a proper multi-language structure. I started with empty Localizable.strings files, and run the app to see whether I cleaned up everything properly. With empty Localizable.string files, I assumed my "NSLocalizedString" calls would simply return the key as text. They don't. They still return the old text that I had in the old .strings files.
Just to be sure, I put an NSLog statement under one of the NSLocalizedString calls, as such:
NSString *text = NSLocalizedString( key, nil );
NSLog(#"key=%# text=%#", key, text);
Then I search my whole harddisk for the text that was returned. No file on my harddisk contains the string that NSLocalizedString returns. And it is a completely different string than the key, so it cannot be constructed by NSLocalizedString either.
Anybody knows how this can happen? Is the old info cached somewhere by XCode? How can I persuade the tool to use the new Localizable.strings files? Obviously, I have already 'clean'ed and rebuilt the whole project.
Try to delete the app from the phone, then clean your project and install the app afresh.
If it still doesn't work, check you haven't somehow messed up with the Build Rules (Xcode 4 -> select your target -> tab "Build Rules") There, check if you don't have too many "CopyStringsFile" rules that aren't using "CopyStringsFile". If so you can remove them all but one.
If you are testing on the simulator, try resetting the simulator using the "Reset content and settings..." option in the "iOS Simulator" application menu.
When you redeploy a new build of the app, even after a clean build, it often doesn't clear out the cached content of the previously built version.
Did you also clean build folder? command + option + shift + k or go to product, press option, there will be a clean build folder, usually, resources file are cached, any resources file replacement (file with same file name but different object) might not be detected by XCode
Also, deleting app / resetting simulator does help. Deleted files sometime don't get removed when you redeploy.

Resources