I am expanding an existing iPhone app (4.x and up) with support for more languages: Estonian, Latvian and Lithuanian.
In my iPhone and in the simulator there is no support for these languages, and I am pretty sure that no special firmware exists for them either for use in those territories.
How can I best make an app that supports them?
I have come up with two solutions which I don't really like. Neither of them allows me to have more than one language in the app, since the user cannot choose the bundled languages from the Settings.app list. This means that one version must be submitted for each language.
Option 1: Abuse the en.lproj directory
For each targeted language (lt, lv, et) I put the strings files for that language into an en.lproj directory.
Pros: Uses a well-known mechanism. The app just thinks it is running English.
Cons: Wreaks havoc on my localization tools. Its confusing for future maintainers and therefore error prone. Requires a weird build setup.
Option 2: Abuse NSUserDefaults[AppleLanguages]
The AppleLanguages
object in NSUserDefaults contains a list of languages for the app to use. By setting it like this I can get the app to load for example Lithuanian from an lt.lproj directory:
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"lt", nil] forKey:@"AppleLanguages"];
(For historical reasons I am already doing a slightly more involved version of this to remove a deprecated translation in some versions of the app. Otherwise older installations would pick up the lproj dir even though I no longer bundle it with the app.)
Pros: Uses properly named lproj directories. Integrates well with localization tools. Simple setup. Only requires one line in main.m
to implement.
Cons: Even though the AppleLanguages
key is being used by a lot of people this solution uses it to load otherwise unsupported languages, so I fear I might be skating on thin ice.
Le Questions
- How do other apps normally support these "unsupported" languages?
- Is there a way to support them along with the normally supported languages?
- How do you feel about the
AppleLanguages
hack?