Multilanguage App

Hi guys,

if anyone is curious on how to set up a multilanguage app, here is how I solved it:

Go to your project under the info page and look for the Localization section.
Here, you can add your language(s)

Next Step is creating a String Catalog File. Go to New File from Template and search for “string” and choose the String Catalog File

Name/Rename the file to Localizable.strings
Within your Localizable.strings File, you should now be able to see and press the “Localize” Button on the right hand side under the “Localization” section.

Afterwards, it should create a file for each language.
image

Within the Localization files, you can enter your strings, which should be translated, for e.g. if you want to translate Season from English to German, you need to write a line in each file.
English:
“Season” = “Season”;
German:
“Season” = “Saison”;

This will translate the string Season to the german version “Saison”. Pay attention for the ; at the end of each line/string combo.

Within your app entry point, you have to create an environment variable with .environment

ContentView()

.environment(\.locale, .init(identifier: Bundle.main.preferredLocalizations[0]))

This will take the first preferred language from the preferredLocalization.

If you have any additions or comments, feel free to ask :slight_smile:

Cheers
David

2 Likes

Great advice, but it seems that you manually populate your string catalog.
Xcode can detect your strings automatically which can then be translated.
Have a look:

2 Likes

Oh, great advice. That’s even better than populating it manually.

Thanks Wildsparrow :slight_smile:

1 Like