1

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,

user1949873
  • 460
  • 7
  • 17

2 Answers2

2

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.

Satheesh
  • 10,998
  • 6
  • 50
  • 93
  • Thank you for the tutorials, I have up-voted your answer. However, I still need to understand if I duplicate my views would it cause me any problem? I find it a lot easier than **creating an outlet for each label**!! So, if I link my button to my views it wouldn't need the user to restart the app or anything like that. **My main question is** how to make my **French** button call my **localized** `PickerView`? – user1949873 Apr 25 '13 at 15:37
  • Hey duplicating all your views would just increase your app size and one more thing you will be having only one outlet for all labels and UIControls. The text setting part will only change according to the language selected. So if you want a picker view with french elements just do this, change the apps language to french using LocalizatonSystem class given in the second tutorial(I believe it is setLanguage or something) then in your pickerViewTitleForRow in the text setting part use AMLocalizedString(@"YOUR KEY",@"comment"); So this will work for both english and french. – Satheesh Apr 26 '13 at 03:40
  • Can you post code for your button event and picker event, I may help you better. – Satheesh Apr 26 '13 at 03:41
1

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.

Divyam shukla
  • 2,038
  • 14
  • 18