I'm building an iOS with bilingual content, the user will be able to switch between languages at any point and the content will be updated to the selected language. What is the best way to keep track of all of my UIView components to facilitate the language switch?

The options I see are;

  1. Make each element that could possibly change a property of my ViewController;
  2. Give each element a tag and grab the elements with viewWithTag when required;
  3. Throw out the whole container view and rebuild it from scratch.

To be honest none of these 3 options sound ideal, are there others options I haven't thought of? What is considered the best way to keep track of multiple elements?

Thanks,

Edit 3 Mar 2014

More details.

The app will have two versions of all the dynamic content, French and English. Only one language will be displayed at a time, but the user will be able to switch languages at any time and all of the displayed content should be updated.

App description. The app is part of an instillation and will be run in kiosk mode with a landscape orientation. The left hand 2/3 of the screen will be a horizontal scroll view though which the the user can page though the content. When the user sees content that they wish to investigate further a vertical scrollview will slide up from the bottom and fill the right hand 1/3 of the screen. The user will then be able to page though details on the content. It is this dynamic detail content that I am currently working on changing according to language.

没有正确的解决方案

其他提示

What I'd do is subclass all "basic" components (UILabel, UIButton and others) and make them respond to a global, custom NSNotification sent by your controllers when the user switches a language, with the use of the global notification center ([NSNotificationCenter defaultCenter]). That way, anyone has a chance to update.

In a recent localisation attempt we just made every visible string an outlet and defined them as NSLocalizedString, then we have plist dictionaries for each language. It takes awhile to get all set up, but is relatively easy to maintain once it's there!

Not saying that's the best way, but that's what we did!

https://developer.apple.com/internationalization/

That link may help you! :)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top