Review the multilingual support (i18n) of the ios app in 3 minutes

Let's translate the English app into Japanese

The default language for ios is English. Make sure that project> info> Localizations is set to English as shown below. スクリーンショット 2020-12-19 17.09.32.png

Let's set Japanese i18n. Press the + button to add ja. スクリーンショット 2020-12-19 17.13.39.png

Create a string file called Localizable.strings. スクリーンショット 2020-12-19 17.17.06.png

Normal files cannot be used for i18n, so press alt + cmd + 1 and press the localize button. Screenshot 2020-12-19 17.31.44.png

A dialog will appearScreenshot 2020-12-19 17.34.28.png Let's select japanese.

Make sure japanese and english are selected. スクリーンショット 2020-12-19 17.30.50.png The following 2 files are created. Localizable.strings (Japanese) Localizable.strings (English)

At this point, ios will automatically support i18n to some extent. For example, words such as "cancel" and "save" will be i18n compatible.

Supports i18 for solid words in source code

If there is a word in the source code that you want to support i18n, create a definition for each language as shown below and support it with NSLocalizedString.


// Localizable.string(Japanese)
"Hello" = "Hello";
"Buy" = "Buy this book";
"Register" = "Register for a new account";

// Localizable.string(English)
"Hello" = "Hello";
"Buy" = "Buy this book";
"Register" = "Register for a new account";

let buttonTitle = NSLocalizedString("bear", comment: "The name of the animal") print(buttonTitle)

Supports StoryBoard for i18

A multilingual file corresponding to each Storyboard should be generated. For Main.storyboard Main.strings(Japanese) Should have been made. Example


// Main.strings (Japanese)
"uZq-Aj-erb.text" = "Every Wednesday";
"uZq-Aj-erb.text" = "Wednesday";

If you rewrite the wording in it to Japanese, multilingualization will end

reference

https://www.hackingwithswift.com/example-code/uikit/how-to-localize-your-ios-app

Recommended Posts

Review the multilingual support (i18n) of the ios app in 3 minutes
The story of AppClip support in Anyca
Understand the characteristics of Scala in 5 minutes (Introduction to Scala)
Implement customer support chat in your iOS app in an hour using the Zendesk Chat SDK
iOS app development: Timer app (9. Customize the color of the progress bar)
I thought about the strategy of introducing Combine in iOS development
Order of processing in the program
Change the save destination of the image to S3 in the Rails app. Part 2
Get the result of POST in Java
The identity of params [: id] in rails
The story of writing Java in Emacs
Write the movement of Rakefile in the runbook
TECH CAMP (Engineer career change) Review of learning contents in the 6th week
TECH CAMP (Engineer career change) Review of learning contents in the 4th week
[Order method] Set the order of data in Rails
iOS app development: Timer app (6. Creation of setting screen)
The story of low-level string comparison in Java
[Java] Handling of JavaBeans in the method chain
The story of making ordinary Othello in Java
iOS app development: Timer app (8. Implementation of progress bar)
About the idea of anonymous classes in Java
The story of learning Java in the first programming
Measure the size of a folder in Java
SKStoreReviewController implementation memo in Swift UI of iOS14
The basics of the App Store "automatic renewal subscription"
How to add sound in the app (swift)
Feel the passage of time even in Java
A quick review of Java learned in class
Support out of support in docker environment using centos6
Get your version number in the Android app
Import files of the same hierarchy in Java
Understand in 3 minutes! A very rough explanation of the difference between session and cookie