I have a big project with lots of text stored both in labels in storyboard and variables. I know how to localize text in labels, but have no idea how to localize string variables. Can you explain that or give a link to the guide. I'm using Xcode version 6.2
相关问题
- “Zero out” sensitive String data in Swift
- SwiftUI: UIImage (QRCode) does not load after call
- Get the NSRange for the visible text after scroll
- UIPanGestureRecognizer is not working in iOS 13
- What does a Firebase observer actually do?
相关文章
- 现在使用swift开发ios应用好还是swift?
- Visual Studio Code, MAC OS X, OmniSharp server is
- Using if let syntax in switch statement
- xcode 4 garbage collection removed?
- IntelliJ IDEA can't open projects or add SDK o
- Automator: How do I use the Choose from List actio
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
In code, you use
NSLocalizedString()
with your base language:The comment can be left empty "" but it is useful for the translator (even if this is you) to know where the string comes from.
Xcode automatically creates a file
Localizable.strings
in your project in a subfolder for the language. The file contains entries like that:You can translate the strings in that file with a text editor of your choice.
A better way to work with translations is to select the project target in Xcode, then choose from the menu
Editor->Export For Localization...
This will create a folder in a location of your choice containing a language file in xliff format, i.e. for german:
de.xliff
xliff
is a standardized (XML) format. It is somewhat hard to edit that file in a simple text editor. I use iXLIFF for that. It is a very small application for the Mac and makes translations a breeze.After translating the xliff file go to Xcode
Editor->Import Localizations...
and choose the xliff file. Xcode will tell you when something is missing.