Skip to content

Change language in the app. Simple approach to localize strings/images. Written in Swift.

License

Notifications You must be signed in to change notification settings

romansorochak/Localizable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Localizable

  • Simple approach to localize strings/images.
  • Change app language in the app.

Demo

Contents

Requirements

  • iOS 9.0+
  • Xcode 8.0+
  • Swift 3.0+

Installation

All logic is in Localizable.swift file. Just copy this file to your project.

Usage

Localize your project

  1. Create Localizable.strings file

  1. In Localizable.strings file tap Localize button and select english language.

  1. In project file add supported languages.

  1. Recommendation: do not localize storyboards or xibs. Make it simpler. Put all your localized strings in Localizable.strings file.

  1. Reproduce step 2 for needed languages.

Localization

  1. Recommendation: do not localize storyboards/xibs. Always set strings from code.

  2. Extend enum Language with appropriate languages used in the project

enum Language: String {
    
    case english = "en"
    case arabic = "ar"
    case ukrainian = "uk"
    //...

Get appropriate localized string

"main_page_language".localized

Get appropriate localized image

"flag".localizedImage

Change language in the app

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

Author

Roman Sorochak - iOS developer - roman.sorochak@gmail.com

License

Localizable is released under the MIT license. See LICENSE for details.

About

Change language in the app. Simple approach to localize strings/images. Written in Swift.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages