- Simple approach to localize strings/images.
- Change app language in the app.
- iOS 9.0+
- Xcode 8.0+
- Swift 3.0+
All logic is in Localizable.swift file. Just copy this file to your project.
- Create Localizable.strings file
- In Localizable.strings file tap Localize button and select english language.
- In project file add supported languages.
- Recommendation: do not localize storyboards or xibs. Make it simpler. Put all your localized strings in Localizable.strings file.
- Reproduce step 2 for needed languages.
-
Recommendation: do not localize storyboards/xibs. Always set strings from code.
-
Extend enum Language with appropriate languages used in the project
enum Language: String {
case english = "en"
case arabic = "ar"
case ukrainian = "uk"
//...
"main_page_language".localized
"flag".localizedImage
To change language just set Language case to Language.language static property. It will change app language and semantic if need. To enable changes it will restart the app within instantiating initial view controller from Main storyboard.
- Important: use appropriate properties described above.
Language.language = Language.english
Roman Sorochak - iOS developer - roman.sorochak@gmail.com
Localizable is released under the MIT license. See LICENSE for details.