helkarli
helkarli

Reputation: 131

iOS Localization only partly working

I localized my app for German and English language. Except for some empty translations the format of the strings should be ok, since I get no error from xCode. plutil -lint <name of the strings file>.strings says that all localized files are OK.

I switched the Application Language in the Scheme of my target to German. Depending on the build/run either the InfoPlist.strings or the Localizable.strings get translated. Either the app (Localizable.strings) is or the Shortcuts and NS...UsageDescriptions (InfoPlist.strings) are in German.

I already tried a lot in the Simulator and on different devices with different iOS versions. I cleaned the build, cleaned the build folder, deleted the DerivedData folder. I also deleted the app. I made sure the .strings files are added to the target. I changed the encoding to UTF-16 and back to UTF-8. No success either. Unfortunately nothing seems to work.

I imported and exported the strings from .xliff files. Maybe it has something to do with that. Before I was working with the import / export the translations were working just fine.

It seems so random. What am I missing?

Upvotes: 1

Views: 562

Answers (1)

helkarli
helkarli

Reputation: 131

I spent some more time on the issue and found the answer to my problem - I think. When importing the edited and exported .xliff files from xCode to xCode the InfoPlist.strings got updated. The import added double quotes to every key.

Before the import

ShortCutSearchTitle = "Suche"; //working

After the import

"ShortCutSearchTitle" = "Suche"; //not working

I removed the double quotes and the strings were properly translated on the device. Maybe a clean build is needed but it even worked instantly on the device. I do not know to this point why the app itself (Localizable.strings) would show the wrong translations some times. Maybe this was a cached files thing or any of the other things I tried out.

In the simulator on the other hand I needed to

  1. delete the app
  2. reset the simulator
  3. change the device language
  4. build and run the app

in order to show the InfoPlist.strings translated. It seems that the InfoPlist.strings is cached until the simulator is reset. I thought changing the Application Language in the Scheme (Product / Scheme / Edit Scheme / Run) would also affect the InfoPlist.strings, but it did not. Only changing the simulator language would present the 'usage' alerts and the custom translated InfoPlist.strings in the correct language.

I am happy to have found the 'error'? with the double quotes, but I am also worried I might have to change the double quotes after every import manually now.

Upvotes: 2

Related Questions