change langue on the fly IOS - ios

I would like to make a button in the app , i want my app support Chinese and English. lot of the sample on the web require restart the app to take effect. is there any way to change the language in the App without restart the App ?

Ive done something like this in my application.
saved my button or item text in different language other that english in NSUserDefaults
then in application load it check "Lang" keny value in NSUserDefaults.
if other than "eng" , it load that language.
if u put button or list with ability to select and change lang key in NSUserDefaults then the
only think u should do is to change all item text base on list or array u made in ur
application per language.

Related

Development Language IT on Xcode

Hello everyone I wanted to have information ...
I changed the development language on Xcode EN -> IT
Now I wanted to know if these changes will remain even when I publish the app on the app store or if they remain only during development
My app is for Italy only and I wanted to know if I can avoid entering Locale(identifier: "it") for each date display, now that I have set the development language to Italian.
You will want to go to File > New File > Strings File, name it Localizable.strings, this is important.
Open the attribute inspector. Click Localize..., select your language.
In your file, for each piece of text you want to show in your app, come up with an identifier/key for it, then write as follows:
"welcome_message" = "Welcome to my app!"; // This would be in your English file.
Then do the same thing for each language you want to support, but just change the phrase itself in each file, and keep the same key/identifier.
Then when you want to use that phrase in your app, replace whichever String with NSLocalizedString("welcome_message", comment: "")
No need to set Locale(identifier:String) in your files. The app will look for the device's set language and use the corresponding Localizable.strings file.

How can i change localization of app from inside app without restarting it?

I've come across with the problem where language settings is in app, that user can change it at anytime, but..
when i change it with using this code e.g
[[NSUserDefaults standardUserDefaults] setObject:#[#"de", #"en", #"it"] forKey:#"AppleLanguages"];
it do not effect until restarting the application becuase bundle is already loaded in appDelegate, right?
so i tried this solution
https://stackoverflow.com/a/20257557/2839104
but already loaded viewControllers do not effected, so...
how can i update app language without restarting it and without changing NSLog usages with something else? is there any way for it?
I would appreciate any comments.
You have to implement a class that will loads each localizable.string corresponding to the languages available in the project.
Then you create a viewController to allow selecting a new language.
When user select a language, you'll have to reload the language labels and notify each controllers that it has to refresh itself.
I made this inside some of my applications.
I created a macro to add my viewController as delegate to the languageManager.

Localization for a very simple app.. How to connect a button?

I have a very simple app which only contains a PickerView, UILocalNotification, UIAlertview and less than 8 views. What I want is:
I have a main view which contains two buttons one says English and the other says French.
What in my mind is:
When the user hits English it'll take him to the Project I have right now,
However, when the User hits French it'll take him to a duplicated views that I'd simply and manually change and translate it's labels into French.
** Now my question is ** how do I translate the PickerView, LocalNotification and the AlertView? and how to connect the French button to these translations?
From what I've googled and read here in SO is that I can get the strings out and list them into Localizable.strings but I still don't know how to make my french button ask for these strings? Also, is there an easier and simpler way? any idea?
Thanks,
Kindly try this for doing localization
http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial
For buttons use something like this
[self.yourButton setTitle:NSLocalizedString(#"YOUR_KEY", #"Comment") forState:UIControlStateNormal];
Do not duplicate your views and view controller just for the sake of localization, considering that for both languages have the same layout and everything only thing that would change is the language. So add English strings and French strings to your project and use NSLocalizedString to get these values.
Note:NSLocalizedString works with device language only so if you want to change the app's language manually try this. I have used AMLocalizedString in many of my projects and they work fine.
Hi as you want to make it localized only at App basis not at device basis hence NSLocalisedString will not work you have to manage it so you have to take two different files and you have to fetch the string value on the basis of selected language. In similar manner as LocalisedString works as in localization there are multiple .strings file created for languages and it works in a way to select default language of the device and shows the text from the localised file.

UIWebView localication

I'm developing multi languages application and intent to have DONE button localized. This button is appear in UIWebView when user clicked on dropdown ("select" tag) with multiselect:
By default, this is always in English. However, if you set CFBundleAllowMixedLocalizations to YES in .plist file, you will be able to get it in current SYSTEM language:
Here, DONE is written in Chinese, when text in select in Arabic. It is because current system languages (i.e. set in Settings) is Chinese, but inside app I selected Arabic so app is using Arabic bundle with Arabic strings file.
I wonder, is any possibility to localize "DONE" button to current Application's language, but not system language?
Don't use "Application's language". Simply use the system language, like all other applications do.
I'm sure it's possible to somehow achieve it, but you're simply taking the wrong approach to localization.

How to localize the app name?

I wrote a game with cocos2d and translated all the image and text in the
game in two different language.
When the app launches, I load different resource according to the locale of
the device and this worked all OK.
Then when I upload this app for review, I first named it say "test".
Then in the localization part I add a language "Japanese".
But I found that in the "Japanese meta data part", I can edit a lot of
things except the "app name" which is "test". But I want my app to show
different names according to the locale of the device also.
Can somebody tell me how to get this work? Thanks in advance...
You can create a file called InfoPlist.strings in each of your language specific directories, and set a language specific value for CFBundleDisplayName.

Resources