Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
674 views
in Technique[技术] by (71.8m points)

localization - How to localize label strings in iOS for a beginner?

Hi I'm very much stuck on the process of localization on iOS.

Here's what I do understand:

  • How to go to the project explorer and set base localizations for different countries
  • How to make a string file and set it to be localized to one of the particular countries chosen within base localization, such as simplified Chinese
  • key value pairs and how to correspond the word "HELLO WORLD" = " some other language"; with in the localized string file

However the app, which has a simple label, with the writing "hello world" when compiled doesn't change to Chinese in a Chinese simulator.

Here's where I think I'm going wrong:

I think I need to connect the strings on the screen to the strings contained within my localized strings file.

And do I make a separate string file for each language?

I'm looking to make a very very simple stub of an app containing nothing but a few labels which are translated into different languages, so I can learn how to make it connect and work so I can use it else where.

There is a storyboard for Chinese, do I have to do any work to that or is it left blank?

After hours of reading documents I seem to be going around in circles, I'm not impressed with Apples documentation on this issue think its missing something.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For localization, you need to do:

  1. Add different .strings file for each language
  2. Add the Key value for each language file
  3. Use:

NSLocalizedString(yourKey, nil);

or

[[NSBundle mainBundle] localizedStringForKey:(yourKey) value:@"" table:nil]

For getting the localized string of passed key.

Tutorials:

  1. Localization in iOS apps made simple
  2. iPhone Apps Localization Guide
  3. Preparing your iOS app for localization in Xcode

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...