IOS project internationalization, that is, you do not need to go to the iOS system Settings interface to select the corresponding language, but in your own project to set.

Let’s take a look at a little demo I wrote and see how it works.




The first step is to add the language you need in the project configuration. Click the plus sign as shown in the picture to select the language you need to add (blue is your current development language by default). In other words, I added Chinese and Spanish by myself.




After adding it, you’ll notice that there are two more files under the original mainStoryBoard




Next we need to export these two files because they are the language files for Chinese and Spanish respectively.




To select a language, go to Editor->Export For Localization.. Export the XLIFF translation file




Translation of two different languages in two XLIFF files for example, Chinese is translated as follows




Then guide the translated document into the project




The basic configuration of the project is fine so far

When it comes to the code, I refer to the encapsulated class, LanguageManger, select the language list, save the current language shorthand code, and reload the program. I’ve posted some of the core code here. I’ll post the demo address below if I don’t understand.




If you want to import the languageUtil folder directly into your project, you can.

When the project is loaded, it will read the language code from the local, and it will find the corresponding language file according to the different language code. After you switch in the project, it will load the program again (that is, load the project again according to the current language code).

Finally, paste the project address: international Demo

Thanks for reading, first time blog, we make progress together