NSLocalizedString always fall back to english - iphone

I have a project with english and french translation. Everything used to work perfectly fine.
Now for some reason the language always fallback to english.
I tried to delete the English.lproj and French.lproj folders, regenerate them with genstrings : still same issue
I also tried to delete the app from the device, clean the target and deploy again, no results.
The language of the device didn't change since it has always been set to french.
P.S: My problem is very similar to this one, except that my project used to work fine :
iPhone: NSLocalizedString reading from English .strings file even when another lang is set
Does anybody have any idea of what i could do ?
Thanks for your help,
Vincent

There are several details that you need to follow, including where in the project you drag the localized files.
Have a look at this tutorial for a step-by-step explanation:
http://www.icanlocalize.com/site/tutorials/iphone-applications-localization-guide/

Related

Xcode cannot find my Localizable.stringsdict file

I am trying to add pluralizable localization to my Xcode project, using Xcode 11.2.1
I followed the steps in this tutorial: https://medium.com/#vitaliikuznetsov/plurals-localization-using-stringsdict-in-ios-a910aab8c28c , which is a pretty basic instruction on how these things work. Mine, however, did not work, SO, I tried the following:
0) Actually running the tutorial code to make sure it works on my copy of Xcode. It does.
1) Copying the example Localizable.stringsdict from the tutorial into my program, and using
the keys from said tutorial in my calls, in case I had made a bad Localizable.stringsdict
or was calling it wrong. This failed.
2) Creating the Localizable.stringsdict as a property list, as some older questions suggested, instead of a Stringsdict file when creating it new, and copying the known 'good xml' of the example plist into it. This failed.
3) I tried removing all localized content from the project, and re-adding the strings file and the stringsdict file. Now it can't find either of them.
Clearly I must be missing some configuration, some step, some way of saying HEY XCODE LOCALIZE THESE. When I look at the 'Localizations' tab in the Project, there is only 1 file localized, for "Base"
Yesterday, I succeeded to localize Swift App using this tutorial.
Please try to follow this tutorial. Thanks
Number 4 was the clue here. My project has a lot of targets. Add your stringsdict file to the targets it needs to be added to. Derp.
I added the dict file to the proper target and everything works fine.
Always check the obvious stuff first.
Open your localized stringdict file, then in the right inspector click on Identity and Type you will see localization block with a button, click on it and project will recognize your file now

Xcode Localization is driving me nuts! Not loading Storyboard

It's been 2 days this issue is driving me nuts.
I'm trying to localize my iOS app but for the life of me I can't get it to work. It works easy enough when I try on a blank project but not on my current project.
I've added the languages in the Localizations using "+", I've localized the storyboard but when I check on simulator or device I still see the english version. And in fact it's not even the English one because if I change the Maintsoryboard (english) I don't see the changes in the device ... I still see the initial texts.
I've tried reseting the simulator, deleted the app, etc. No luck.
I've reverted to a backup tried adding everything again. No luck.
Can someone please help? I know it's not much to go on, but I don't know what to explain to help you help me. So please let me know if I'm missing some info.
FYI, when I look into the app's folder in Developer, I initially don't have a en.lproj when it seems I should have one by default?
It looks like you already figured this out, but I think what probably happened is that originally you had "MainStoryboard.storyboard" as an unlocalized resource. This means that when you build your app, you get a "MainStoryboard.storyboardc" as an unlocalized resource. When you change your storyboard to be localized, you get a "Base.lproj/MainStoryboard.storyboardc" in your bundle resources.
There are several copies of your app when you're building in Xcode. There's the copy on your device or in the simulator, and there's also a copy in your derived data folder in Xcode. When you do an incremental build of your application, the copy in the derived data folder in Xcode is a merge of your new content and your old content. So, when you modify a resource in Xcode, and rebuild, you get the newest resource. However when you rename or delete resources, the old copy is still left in the build directory until you perform a clean operation.
This means that your build product probably had both "MainStoryboard.storyboardc" and "Base.lproj/MainStoryboard.storyboardc". When NSBundle loads resources, it prefers unlocalized content, and would load the old "MainStoryboard.storyboardc".
Be absolutely sure you don't have typos in Main.strings file, e.g. double quotes and semicolons. If you have any typos, device simply ignores localized strings and applies base internationalization.
Blind shot: check that the strings file is UTF-16 (little endian if I remember correctly) and it doesn't have syntax errors (missing ; or quote). Also run a project clean before building after changes in strings files.
Try selecting all of the various .strings, .xib, and .storyboard files that are being localized.
In the File Inspector, make sure that all of the needed localizations are checked for each file.
After adding localization, English was unchecked on several files. Some views were thus localizing into unintended languages. Checking English fixed the problem.
What I faced is only typo error like
"zu0-GQ-ymP.text" = "Meeting End Time;
just make sure and check each strings in Main.strings must be like below
"zu0-GQ-ymP.text" = "Meeting End Time";
Hint : if it is typo error it will not work in particular localization.
this is true - AyAz, thanks! It should be noted, XCode will not always fail to compile if some issues in the strings file (esp for localized Storyboard). you can quickly check the syntax-coloring on the file in xcode or run a strings linter on the strings files to ensure no typos -- in my case it was failing due to a double-quote symbol, which is used in the target localized language as part of their normal alphabet. XCode continued on without warnings/errors, but the screen kept showing English...

iPhone localization issue

We recently added localization support to my app and added Hungarian translation. It was working fine. But then we found that some characters were not proper so I sent the ".strings" file to translator and replaced the old file with updated file.
Now, the localized string appears in alertbox but all screen/form/NIB displays English only.
I have no clue what went wrong in this process. It's kinda urgent and unfortunately my coder is not much responsive.
I am a programmer but not much familier with Objective C. If I can get some help from expert fellas, I might be able to solve it.
Thanks a bunch!
I am not sure what was wrong exactly but I first restored that .string file with old version, opened it from Xcode and then replaced the content. One difference I observed was, there were two empty lines at EOF in old file, which was missing in new file, not sure if that caused the issue.
Thanks everyone!

English localized files doesn't load

Localizable.strings for english language didn't load. It previously worked but not only I can see are the keys of the strings. On the other hand Czech strings are loaded fine. I am also aware there at least two threads about this topic, however, they didn't help me.
Summary:
I have two localized strings in cs.lproj and en.proj directories
Only Czech one is loaded.
The English one was previously loaded too but now only I can see are just keys.
I have tried to clean my project.
I have tried to uninstall an app from device.
I have tried to save Localized.strings as UTF-8 as well as UTF-16 as recommended.
I have tried points 4-6 at once.
The solution: My project contained another Localizable.strings file for english language. It was inside ShareKit library. I didn't know it as I took this project over previous programmer. So I removed the file, now it works fine. Sorry for bothering you. May it can help someone other - simply search your project for Localizable.strings duplicates.
You should look inside the app package to see if your Localizable.strings file is included. To do this, right click on YourApp.app -> Show Package Contents. Look for the en.lproj folder and see if the Localizable.strings file is there. If it is, then check that its content is correct.
Otherwise, there might either be an error in the english translation file, or XCode is acting up (I had this problem a few times - doing a clean build, restarting XCode and them a new build seemed to fix it).

Why doesn't my file move into "en.lproj" but instead into a new "English.lproj" after "Make file Localizable" in Xcode?

This is a bit confusing:
First I used genstrings, which created me a Localizable.strings file inside an en.lproj folder (also exists on the file system like that).
Then I had a JSON file which I wanted to localize, so I opened the info-pane for that file and choose "Make File Localizable". Xcode then created an English.lproj folder on the file system and also a group called like this. It then moved my file into there.
So now I ended up having en.lproj and English.lproj for basically the same thing: English stuff.
I'm not happy with this situation. Can / should I do anything about it? How can I fix that?
Also, can someone point out what's the difference between using "English.lproj" vs. "en.lproj"? I bet there is a difference.
It's an Xcode bug. Just move everything in the English.lproj folder to en.lproj folder. I haven't checked with Xcode 4.1, but previous versions of Xcode wouldn't allow you to add new localizations if you delete the English.lproj folder, so don't delete it.
You could manually edit your project file to avoid the problem as this post suggest, but I've never really found doing so to be worth it.
Some background -- prior to Max OS X 10.4 the legacy (but more user-readable) names such as “English”, “Spanish”, etc., were used, but the Apple internationalization documentation states that these values are now deprecated:
In addition to the ISO language designators, the bundle routines
also recognize several legacy language designators. These designators
let you specify a language by a user-readable name, instead of by a
two or three character code. Designators included names such as
English, French, German, Japanese, Chinese, Spanish, Italian, Swedish,
and Portuguese among others. Although these names are still recognized
and processed by the NSBundle class and Core Foundation bundle
functions, their use is deprecated and support for them in future
versions of Mac OS X or iPhone OS is not guaranteed. Use the codes
described in “Language Designations” and “Regional Designations”
instead.
You should use ISO-639-1 (two-letter) or ISO-639-2 (three-letter) language codes codes for localization purposes of all languages other than English. XCode still uses “English” instead of “en” as their default localization.
See http://eschatologist.net/blog/?p=224 for info.