Setting language on iPhone application - iphone

I am working on an application which I am planning to release both in English and Spanish languages. With this I mean, I would like it to have two separate apps in the App Store, one being displayed with English title, and the other one with Spanish title (and each with contents in their respective language).
This means that the language in the app would be static, that is, that actually the app would not be internationalized, in the sense that the app would not display the language according to the user's locale settings, but according to either English or Spanish depending on the app bought.
I initially thought of using a constants file with constants strings of all the labels, button titles, etc. and having an identical separate project for each language, and changing this constants file on each project, but of course, this involves some hassle regarding maintenance.
The other approach I am thinking of, is actually performing the whole internationalization process (NSLocale, localization files, etc), and somewhat at the app startup skip the user's locale, and set either language programmatically (here, I would only need to know is how to skip such default i18n process to set a specific language. In this case, I would see the advantage of having only one local project, and the possibilty of setting the language on each build, for a different language app.
Could you please provide advice regarding which approach or best practice to follow?? Does this make sense, or is there another approach that I should follow instead in order to have the two separate, fixed language apps?
Thank you very much in advance!
Best regards

Duplicate: Best way to make an iPhone application multi-lingual
Short version: include a language file for each language. Apple'll take care of the rest - when the user changes their iPhone's language, your app will switch too (assuming a translation is available).

if you really want to have two separate apps in the App Store, you could do something like
Making multiple versions of an iPhone application
to have them both be built from a single Xcode project and make maintenance as easy as possible.
why not just have a single app version that includes both languages and automatically chooses the user's preferred language? if your goal is that bilingual people should pay you separately for two copies, then you'll need two separate apps like you suggest, I guess.

Localize your application for English and Spanish and put the following lines of code in main.m before the call to UIApplicationMain:
NSArray *languages = [NSArray arrayWithObject:#"es"];
[[NSUserDefaults standardUserDefaults] setObject:languages forKey:#"AppleLanguages"];
[languages release];
where the language code is either "es" or en".
This will put the preferred language (es or en in your case) in the application's preferences (in the property list file ../your app's UUID/Library/Preferences/yourcompany's Internetadress.your app's name.plist) and override the language set in Settings.
This makes the app use the localized strings and use the localized XIBs. However, for some reason it does not work for localizing the app's icon and bundle display name. Adding a line for setting the locale (the key seems to be "AppleLocale") does not help. The current locale remains the one set in Settings, not the one set programmatically.

The line
[languages release];
shouldn't be there.

Localizing the strings and the XIBs suffices. Duplicate the target following http://www.iphonedevsdk.com/forum/iphone-sdk-development/8036-lite-game-duplicate-xcode-project.html and set Icon file and Bundle display name in the copy's plist file.

Related

How to add an unsupported interface language to my iPhone app?

I have an iPhone app with interface languages in Toki Pona and Dothraki, which do not have ISO 639-3 codes. According to the ISO 639-3 standard, you can use the range qaa-qtz to represent languages for local use, which I have done (Toki Pona = qtp, Dothraki = qdt), but still get the warning from XCode "Unrecognized Locale".
It seems like I might be able to extend the main bundle class, but looking over the documentation, nothing seems to relate to adding non-ISO languages. I'm also aware of the text "If necessary, you can use a language or locale code that is not known to the NSBundle class or Core Foundation bundle functions. For example, you could create your own language designators for a language that is not yet listed in the ISO conventions or available as a language in Xcode." at the end of https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPInternational/LanguageandLocaleIDs/LanguageandLocaleIDs.html
In any case, I mostly want to get rid of this warning. Any help would be greatly appreciated!
https://forums.swift.org/t/proposal-ns-locale-identifiers-etc-should-have-custom-types/9367/8
have a look at the above link.
Check if the languages are added as Localizations
I believe I have a solution however slightly complicated one. You would need to create a setting option within the app to use those made up languages and to load them manually from a file when a user sets them. For example, let's say your app consists of one label and the user sets the option to the made-up language you would call a method to set the language and the text on that label would update accordingly. I don't know whether this makes sense to you?? Basically, if the user uses the made-up languages that would override any system localization they have. It is doable it would just take time to implement it.

adding languages for localization to iPhone - is that possible?

Compared to Android iPhone does not support many languages, even though the MAC seems to do so ( simply because I learned that the possibility of adding these languages in xCode is for MAC Apps and not for iOS).
Now I added the Localizable.strings file for languages that are not available in the language list of the iPhone settings for languages.
Is there a way using the standard approach like:
[onOffSC setTitle:NSLocalizedString(#"On","Off") forSegmentAtIndex:0];
if I just put a selection menu in my app ?
Otherwise I would have to add a special logic - lets say MYNSLocalizedString, checking first if the user wants to select a non supported language, getting this some other way (probably putting these translations into a NSDictionary) and otherwise calling the standard NSLocalizedString.
I guess I would have to put a language selection menu in the app anyways - but can the calls to NSLocalizedString be used or do I have to add a meta-method MYNSLocalizedString like mentioned?
Or is there any other good solution for this ?
Many thanks!
I think better would be to use the language which is set in Settings, instead of user selecting from menu. Refer to this tutorial might help you understand How Localization is done.
http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial
For localization of your iPhone app:
Use the approach described here...
http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial

Difference between NSLocalizedString and AMLocalizedString

What is the difference in using macros NSLocalizedString and AMLocalizedString?
NSLocalizedString is part of the localization solution by Apple. AMLocalizedString is a custom localization implementation by Aggressive Mediocrity.
I recommend sticking to NSLocalizedString unless you really know that you need more features and that they make sense. For example, I think that switching the language inside the app at runtime (which the AM solution can do) is a misfeature that is more likely to confuse the user. Imagine you'd have one app in French, another in German, the next in English. Where do you change that? With the usual Apple localization, the user knows how and where to change it: in the iPhone language settings. But then, maybe there is an important and valid use-case for in-app runtime language switching, in which case NSLocalizedString won't suffice.

How to localize an iphone app for different languages?

Can anyone explain me how to localize an iPhone app ? I am getting confused with the XCode localization concept.
First you may define in your project settings the languages you want to manage. That's not a needed work but it's great to start there.
Then for each of your XIB you want to localize, click on it, go to the property panel and add wanted languages. The unique XIB file will be then dispatched into many files, one for each language. Then just adapt each one as wanted.
It's the same way of doing for images, sounds, or any resource.
For the Strings you may have writen in your code, add a "Localizable.strings" file into your project and add into it some keys like :
"Goodbye_Code" = "AdiĆ³s"
and in your code, where you had writen #"Goodbye", replace by :
NSLocalizedString(#"Goodbye_Code", #"Some description : I'm saying goodye to the user that is leaving the app");
In the end, remember that your app may have a default language setting. If a localization is not created, the one that correspond to that default language will be used in place.
You can check those links for further information :
http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial
http://www.icanlocalize.com/site/tutorials/iphone-applications-localization-guide/

Localization issue in iphone

I need to make an application in which the user can toggle between two languages on triggering a click event on a button.
The problem here is that I have seen examples in which, if we want to load our localized nib file, then we need to change the language from the settings options and we can get the proper nib file loaded according to language selected.
I want to do this within my application, meaning I don't want to go to the settings menu and change the language and then reload the application.
I just want the above effect within my application (that is, through a button click event the app should be able to toggle between two languages).
Is it possible, and does Apple allow it?
Nobody here can tell you whether Apple will allow it, but if your app is well designed and there's a good reason for this departure from the usual way of doing things, you've probably got a good shot.
There's nothing to prevent you from loading a nib file localized for a different region. I'd probably avoid trying to use Apple's automatic mechanism, though. Just name your nib files using some pattern and load the appropriate one.
If you want your life to easy, you will take advantage of the Localization built into the operating system. Otherwise, you will have write your own methods to load localized strings or nib files.
There is no reason for Apple to reject an app that shows localized text based on an in-app setting. I work to help developers localize apps and, although I don't suggest this approach, they have done it and I've never heard of a rejection from Apple.
What you won't be able to do is use Apple's built-in tools, which rely on the system settings to determine a user's language and push the text from a Localizable.strings file. But it honestly won't take you too long to implement a similar system yourself using functions akin to gettext.
You essentially need to implement the same basic logic as any localization system:
1) Surround your in-app texts in a function that will display the proper language based on the user's chosen settings
2) Export your source texts (probably English into file
3) Translate the English strings into each language in a separate file
The function you write can follow the lines of gettext, which has examples in many programming languages. If the settings is "French" grab the equivalent string from the French file. If the setting is English, just print the English.
You won't be able to use Apple's tools, but you CAN do it on your own and Apple won't really care as far as I know. However, if you choose to localize into an Apple-supported language, follow this app localization tutorial for iOS using the standard Localizable.strings method.