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.
Related
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.
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
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/
I'm writing code that will allow my iphone-app to have a "configuration page".
A grouped, scrolling, UITableView... with cells that contain the needed textFields, switches, sliders, etc.
It is an ENOURMOUS amount of code. Is there an easier way?
Is there a way I could create a simple text-file, contain all my desired design choices and have my (reusable) code build the TableView for me?
Or... can I just do the whole thing quicker/easier in Interface Builder instead of code?
Basically there are two approaches here :
you rely on what Apple gives you and implement a Bundle Settings (basically a dictionary that describes how the settings screen should look like), and then , your settings will be in the "Settings" application of the iPhone.
The drawback here is that what apple provides is quite limited and you won't be able to implement some of the most complicated settings you can see in "standard" (pre-installed) apple application settings.
That's why many developers are switching to "inapp" settings thanks to open source FWK or they reimplement everythingh from scratch but it can be a lot of code as you said.
You reimplement your own UIViewController for settings or you rely on some framework that will provide you the UIViewController to extend from and ease your implementation.
There are 2 good frameworks for that (Jesse cited one of them, but there's another one )
InAppSettings ( http://inscopeapps.com/blog/inappsettings-10/ )
InAppSettingsKit ( http://inappsettingskit.com/ )
A comparison of the two framework can be found here : http://inscopeapps.com/blog/inappsettings-vs-inappsettingskit/
(ok that's from one of the two authors but at least this gives an idea ;)
If you can live with the limitations of the standard application preferences in iPhone, you can actually create this using a settings bundle which only needs a plist and optionally a localized strings file.
You can check out Apple documentations for this:
http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ApplicationSettings/ApplicationSettings.html
Claus
If you're looking for a ready made and reusable solution, you can check
http://www.inappsettingskit.com/
It's open source too, so it's useful as a base.
I never found an easy and efficient way to build complicated table view by using Interface Builder, so I think programming the settings view is more preferable.
If you're talking about using a text file or plist, you may want to mimic the Settings Bundle design of Settings app.
Load the plist data upon the app launch.
I've built something like what you're looking for. Going off Claus's answer as well, it basically just duplicates the interface of the Settings application using the same settings.plist file as the settings app. The only difference is that it's a view controller that you can put inside the app. There's a surprisingly small amount of coding involved, it was just a lot of looking at the settings app to see exactly how things were laid out.
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.