IOS app internationalization (Implementation does not follow the system language, without restarting the app, code switching Stroyboard, xib, pictures, other resources)

Source: Internet
Author: User

After a perverted demand, to switch program language within the program to achieve internationalization.

Can look at this first, more detailed.

http://blog.csdn.net/xwren362922604/article/details/17190061

After reading the question came,

1, the project inside a large number of xib or storyboard inside the UI set the text, how to enable them to dynamically load the language "non-set system language Restart"

2, a simple idea when the code triggers the switching language to send a notification to let the Viewcontroller in memory refresh the text of the UI. [In the project so all VC every add not exhausted]

All next can be perfected.

1, toggle the language, reload the window's root view. According to different languages. "Search the Internet for storyboard internationalization"

You will find that after you operate Xcode added three files to main storyboard

This is the rationale here. Base and the language you added.
You right-click the show in Finder on these files.

See those three folders. Lproj here is the resource file for the corresponding language. You switch the language is to get the current language eg:en spelling path en.lproj

[[NSBundle mainbundle] pathforresource: userlanguage ofType:@ "Lproj"];

Obtained by Path

NSBundle

familiar with it. Inside this thing is the resource file that our program needs. It's actually the Xx.lproj folder.

Initialization

[Uistoryboard storyboardwithname:@ "Main" bundle: bundle];

We are more accustomed to the following parameters of the taste nil.

There's a problem with that. In fact, the real main is placed in the base folder. The program jumped. Let's get rid of base. Never delete the base file directly. So directly to the main. Storyboard deleted it.

Over here

Point file. Right column. Remove the base ditch. No warning.

Look again

It's ok now. In two folders respectively.

Legacy Issue: If you support many languages, the program will become very large. There is a solution to the exchange of

2, write a VC base class. Registration and removal notifications. For automatically refreshing the UI within the VC. You can add the number group variable "Blok" in the base class

In SUBVC, note here to prevent circular references. _weak

In SUPERVC

Traversal execution.

Implement automatic refresh

You can download the project here:

git clone [email protected]: Githhhh/test_local_two.git

Done

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.