SwitUI iOS localization language is not changing

Viewed 108

I localized my app in Xcode 13.2.1 into two languages as shown on picture below - EN texts are hardcoded, CZ texts are in Localizable file (imported from xcloc file).

enter image description here

App is constantly appearing in CZ in Simulator even if I set EN language in Run scheme. The only way I found so far to change appearence to EN is to remove CZ localization from the app at all. Any hint, please? Thanks.

enter image description here

1 Answers

Here's how I was able to fix it:

  1. Select the Localizable.strings file in the project navigator.
  2. In the File Inspector, you'll see "English" being unchecked, you need to mark it checked.
  3. By default, Xcode will copy an existing non-English localization for English, so we need to replace it with the original English translation. Luckily, it's possible to just extract it from the .xloc package.
  4. Select menu Product - Export Localizations, make sure English is checked and run the export.
  5. Open the directory of export in Finder, locate the en.xloc file. Right click on it and choose "Show package contents".
  6. Inside the package, go to Source Contents/%TargetName%/en.lproj.
  7. Inside, you'll see the Localizable.strings file. Copy it into your project, replacing the file that Xcode generated previously.
  8. Rebuild the app.

After doing all that, English localization should be back.

Related