English always being loaded.

Hi!


In our project we use English as the base language, and we support 65 more languages. Recently something weird started happening in Xcode 7 and iOS 9. We noticed that when we added new languages all of sudden, iOS stopped loading the correct strings for the language currently set in the sim / device. Instead it always shows English.


What's funny about this, is that we were able to pinpoint the commit where this breaks. That is, if we go to the previous commits strings load correctly. If we go to the latest commit, strings for the current language won't load. The only changes from one commit to another reside in the Xcode project file.


Another funny thing is that when we select the Localizable.strings file and in the inspector we uncheck a couple of languages, say Turkish and Greek, strings load correctly. Check them again, and strings stop loading correctly.


I've been trying to figure out what's wrong for the last few days, and still can't understand what's the problem. It has lead me to think that's an Xcode / iOS bug. Any ideas of what could be wrong?


We are using NSLocalizedString, so we shouldn't need to do anything of what's described in this technical note (https://developer.apple.com/library/ios/technotes/tn2418/_index.html#//apple_ref/doc/uid/DTS40016588).


Also, I already run (plutil -lint Localizable.strings) in all Localizable.strings files, and there are no errors...


Thanks!

Two things to try:

  • Add code to get the

    localizations
    of your main bundle to see what it reports in the working and non-working cases.
  • Build a working and non-working app and compare them. In this situation you can ignore the executables and just focus on the resources within the app.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

In relation to the first thing to try, in the Simulator Version 9.0 (SimulatorApp-620 CoreSimulator-179), the language is set to Spanish (the general one, that is, not the one from Spain, not the one from Mexico, and not the one from Latin America). The region is set to Argentina. The app was compiled with Xcode 7.0.1 (7A1001), and it also might be worth noting that we don't use base i18n. Also we have all .lproj folders in a custom location inside the project's directory to keep things tidy (rootDir > Resources > Localization). That is, we don't have them in the default location in which Xcode originally created them.


Here's a screenshot of a table that shows the localizations in the commit where strings were loading correctly vs the commit where they weren't: http://drp.mk/i/0WkkfqYP7k. Notice how the languages are exactly the same, except that some general ones were turned into specific ones (es -> es-ES, hy -> hy-AM, etc).


Here are some diffs of the relevant parts of the Xcode project:

http://drp.mk/i/qmQT4Fhrg

http://drp.mk/i/y6z4QPqpMt

http://drp.mk/i/JNNRv5n7v


About the second thing to try, I'll try to reproduce in an Xcode project starting from scatch and I'll post my findings here...


Thanks!

As for the second thing to try, I managed to reproduce in a fresh empty project with the following steps.

  1. Create a single view project.
  2. In the main storyboard add a label and set its text to "Hello World!"
  3. Add Spanish (Spain) to the project.
  4. In the corresponding strings file set the string to "¡Hola Mundo!".
  5. Set the sim language to Spanish and verify that the string appears in Spanish.
  6. Start adding all the languages you can, periodically veryfing that Spanish is still displayed.
  7. As you keep adding languages, and runing the app, the text will start displaying in English 😟. In my case I added more than 60 languages randomly in order to be able to see the problem


You can download the Xcode project from here: https://www.dropbox.com/sh/a9yy4ympc14i9dk/AADZ7XtRLDU7ZUYYEA0w96Fga?dl=0

You can download the Xcode project from here:

I ran your project and reproduced the problem. I really have no idea what’s going on here. Notably, when things fail NSBundle thinks your app is running Afrikaans, which makes no sense at all. I would expect

preferredLocalizations
to be the intersection of
localizations
and
preferredLanguages
but that’s not what’s happening here (see the debugger transcript pasted in below).

You should definitely file a bug about this. Please post your bug number, just for the record.

If you need a workaround you should also open a DTS tech support incident and one of my colleagues will help you out.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
(lldb) po [[NSBundle mainBundle] localizations]
<__NSCFArray 0x7f923c10ae70>(
af,
ar-QA,
ar-TD,
ar-TN,
ar,
as-IN,
as,
az-AZ,
az-Cyrl-AZ,
az-Cyrl,
Base,
ca,
cs,
da,
de,
el,
es,
fa,
fi,
fr,
ga-IE,
he,
hi,
hr,
hu-HU,
hu,
hy-AM,
id,
it,
ja,
ko,
lkt,
lt,
lv,
ms,
nb,
ne,
nl,
pl,
ps,
pt-BR,
pt-PT,
pt,
ro,
ru,
sk,
sl,
so,
sq,
sr,
sv-SE,
sv,
ta,
tg,
th-TH,
th,
tk,
tr,
uk,
ur-PK,
uz,
vi,
vun,
yo,
zh-Hans,
zh-Hant,
en
)

(lldb) po [NSLocale preferredLanguages]
<__NSCFArray 0x7f923a609000>(
es-US,
en-US
)

(lldb) po [[NSBundle mainBundle] preferredLocalizations]
<__NSCFArray 0x7f923c29b800>(
af
)

Thanks eskimo!


I had already created a bug report a few days ago, but since I got no answer I decided to post here. The report number is 22869789. I've added a link to this post there so that your colleagues can see more details.


Given that you could reproduce, is there any chance you could help us expedite the fix?


BTW, I also tested compiling both, our project and the sample project, in Xcode 7.1 beta (7B75), and the issue is fixed there. Can you please check in that version too?


Thanks!

Actually, spoke too soon. There are still language issues when compiling with Xcode 7.1 😟


In our project we have es-ES. When I set the simulator Spanish (Latin America), which we don't support, it should be selecting es-ES, but it's displaying French, that's the second language below Spanish in the preferred language section...

There are still language issues when compiling with Xcode 7.1

AFAICT this isn’t an Xcode bug but rather a bug in the OS. Certainly when I inspected the built binary everything looked fine.

You could confirm that, one way or the other, by building the same project with Xcode 6 and then testing that built binary on iOS 8 and iOS 9 (IIRC Xcode 6 won’t let you target iOS 9 but you can install the binary via iTunes).

Given that you could reproduce, is there any chance you could help us expedite the fix?

Alas, that’s not my call. However, I still think it’d be worthwhile open a TSI to see if there’s a reasonable workaround.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Ok thanks Eskimo!


I'll add updates to this topic as soon as I get news in bug report. The issue number is 22869789.

Same here, some of my customers reported that since iOS9 2 of my apps are running in english, although there are localizations for them.

I can reproduce it here with my own device:

NSArray *languages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];

NSLog(@"Languages: %@", languages);

shows "en-US" at the log, even though my device is definitely set to german. Same if I choose french, dutch or anything else.

Removing and reinstalling the app helps some times, some times not.


I have sent a TSI 2 days ago, but no answer until now.


Getting more than 100 support mails per day and it would be fine to get a solution asap.


Thanks,

Hanno

Hi!


Same problem here.


I found the solution for me:

Remove the key "Localization native development region" in the info.plist file. Source: http://stackoverflow.com/a/32733000


Greets!

Danke Thomas,

but that makes no effect.

Just tried to set this value to Germany, United States and also removed it completely. Makes no difference. Language code is always en-US.


Cheers.

Please check "Edit Scheme" -> "Run Debug" -> "Options" -> "Application Language / Region".


Cheers.

Thanks, Thomas.

But it appears also in en-US when I start the app without xcode on my test device. So, it's not depending on the debug options.


Prost! 🙂

What I found for myself where using iOS 9 they don't work, but iOS 8 they do (I thought it was Xcode, but it seems its iOS):


(lldb) po [[NSBundle mainBundle] localizedStringForKey:@"Event" value:@"" table:@"InformantCommon"]
2015-10-05 15:49:37.570 Informant[16125:14938518] Unable to load .strings file: CFBundle 0x7fefa2404100 </Users/akac/Library/Developer/CoreSimulator/Devices/9B2E40B5-7E2E-45C5-9C8A-E96044F37E4A/data/Containers/Bundle/Application/53B52216-15FA-4050-8564-69F65E664A1E/Informant.app> (executable, loaded) / InformantCommon: Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected character / at line 1" UserInfo={NSDebugDescription=Unexpected character / at line 1, kCFPropertyListOldStyleParsingError=Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected ';' or '=' after key at line 4801" UserInfo={NSDebugDescription=Unexpected ';' or '=' after key at line 4801}}
Event


So obviously something in my strings file is not as kosher as it should be. Would be nice if Xcode could identify this before I made the build.


One weird thing is I only have 2084 lines in my strings file - not 4801

ok, after seven days a very annoying answer of my TSI:

------

Based on your request Apple Developer Technical Support believes that your question is answered by the technical note linked here:

Technical Note TN2418

Language Identifiers in iOS 9

https://developer.apple.com/library/ios/technotes/tn2418/_index.html#//apple_ref/doc/uid/DTS40016588

------


That was known to me, Apple! And so this ist not the answer to my question. I guess they haven't read the question correctly.


I have written:

------

[[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"] gets me always „en-US“

instead of „de-DE“ what is the phone set.

------

So my problem is not that it’s „en-US“ instead of „en“, my problem is that it’s not given me the correct language setting of the device at all!


But anyway, I changed my apps and added a language chooser right after the first start and at the setup.

That's nonsense, but I had to do something to satisfy my users...


Cheers,

Hanno

English always being loaded.
 
 
Q