Reputation: 13
I am localizing my app for Denmark. I have the Localizable.Strings and the XIBs translated into Danish.
On iPhone a user can
My question is: for any of the above settings should the app show the 'Danish' version (which for my App will mean all text in UI and the database to be in Danish.) or should the 'Danish' version only come when user sets the language to 'Dansk'?
Upvotes: 1
Views: 2100
Reputation: 170319
Languages and locales are treated differently by Cocoa, because they are independent concepts. NSLocalizedString()
will obey the current language setting of the OS, where things like dates, times, and numbers are affected by the locale setting.
Why locales are handled separately from languages can be found in the Locales Programming Guide:
When you display data to a user it should be formatted according to the conventions of the user’s native country, region, or culture. Conversely, when users enter data, they may do so according to their own customs or preferences. Locale objects are used to provide information required to localize the presentation or interpretation of data. This information can include decimal separators, date formats, and units of measurement, as well as language and region information.
For example, by convention in the United States “7/4/76” represents the Bicentennial of the Declaration of Independence. However, in Great Britain, it represents the “7th of April, 1976”; in Thailand using the Thai Traditional Calendar it might represent “April 7th, 2519”; and in France it represents “7 avril 1976”. To take a more subtle example, in the United States“12.125” represents the decimal number twelve and one eighth, whereas in Germany it represents twelve thousand one hundred and twenty-five.
In the example given there, you might have a user who prefers to use English as their primary language, yet who lives in Germany and is used to a comma as a decimal separator, not a period.
The Internationalization Programming Topics guide has a lengthy discussion of all the issues involved and how to deal with them.
Upvotes: 2
Reputation: 12631
This is a great question.
The real issue it comes down to is, in Apple's opinion, as they did it, does NSLocalizedString tend to favour the 'Region Format' or the 'language' setting?
I have never been able to find a clear answer on this, I just let NSLocalizedString decide.
(Purely FWIW, I think follow the "language" setting.)
It's possible the following code snippets could help you.
// to ("usually") get the preferred language FROM THE SET WHICH we supplied in bundle
// [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]
// to ("often") get the preferred language REGARDLESS OF what we supplied
// [ [NSBundle preferredLocalizationsFromArray:[NSLocale ISOCountryCodes]] objectAtIndex:0]
// to ("fairly reliably") get the user's chosen language setting...
// [ [NSLocale preferredLanguages] objectAtIndex:0]
It may not help, but I hope it helps.
Upvotes: 3