Swift Localization: Genstrings
Asked Answered
V

1

7

I'm trying to prepare my app to be passed off to translators for localization, but I'm running into some issues. I added the file "Localizable.strings" to my project, and I have "Use Base Internationalization" checked.

Looking at my app in Xcode, however, I don't see any "Base.lproj" or "en.lproj" or .lproj files for any language, though when I open my app in Finder I can see an "en.lproj" and an "es.lproj" folder.

I'm guessing this may be the reason that the genstrings utility isn't working properly for me. I have many calls in my code like self.navigationItem.title = NSLocalizedString(...), but when I execute genstrings *.swift, nothing changes in Localizable.strings, and I still can't see any .lproj folders.

Vonvona answered 30/8, 2015 at 16:14 Comment(4)
You're not supposed to be using genstrings directly; you should select your Project in Xcode, then Editor -> Export for Localization...Hooker
@Hooker so if I just have all the calls to NSLocalizedString in my files, then export it that's it? When I exported it now, I got an "en.xliff", presumably because I haven't added more languages, but no localizable.strings, which I thought was what is passed off to translators.Vonvona
You can pass the .xliff file off to translators instead. And yes, you need to add languages in your project inspector before being able to export XLIFF files for other languages.Hooker
For change language "on the fly" you can use cocoapods.org/pods/L10n-swift.Petrel
I
0

Xcode doesn't automatically add those files you generated into your build path, you have to manually add them. Also, genstrings generate Localizable.strings file that you can then localize. To generate the lproj files you were talking about, you have to localize your Main.storyboard file.

Instinct answered 15/7, 2017 at 1:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.