Latest 1.0.3
Homepage https://github.com/mostafataghipour/mtpLocaleManager
License MIT
Platforms ios 8.0
Frameworks UIKit
Authors

CI Status
Version
License
Platform

mtpLocaleManger is a locale manager for iOS:

  • Change locale at runtime
  • Supports multiple language
  • Change locale according to system locale
  • Easy to use

multi-language app

Requirements

  • iOS 8.0+
  • Xcode 9+

Installation

mtpLocaleManager is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'mtpLocaleManager'

Usage

  1. Add as many languages as you need to the project
    we have the Base language resource structure by default. Let’s add new language support.
    Select your project file in Project Navigator, and select your project in the project and targets list. Open Info tab, and click “+” button under Localizations section. Then choose a language you want to support from the dropdown list shown.

    mtpLocaleManager

    XCode opens a dialog showing resources to be added for the new language. Pressing the Finish button will generate these files under the new language project folder

    mtpLocaleManager

  2. Any time you need to change the locale of the application using the following code
    LocaleManager.shared.currentLocale  = Locale(identifier: /* your desired language*/ "fa") 

thats it, now run your app and enjoy it

Notification

There is a notification that fired when locale did changed

override func viewDidLoad() {
    super.viewDidLoad()
    NotificationCenter.default.addObserver(self, selector: #selector(localeDidChanged(notification:)), name: NSNotification.Name.LocaleDidChange, object: nil)
}

@objc func localeDidChanged(notification:Notification)  {
    if let locale=notification.object as? String{
        print(locale)
    }
}

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Author

Mostafa Taghipour, [email protected]

License

mtpThemeManager is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "mtpLocaleManager",
    "version": "1.0.3",
    "summary": "A locale manager to change the locale at runtime and have a multi-language app",
    "description": "mtpLocaleManager is the best choice for you if you want to change the locale at runtime and have a multi-language app",
    "homepage": "https://github.com/mostafataghipour/mtpLocaleManager",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Mostafa Taghipour": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mostafataghipour/mtpLocaleManager.git",
        "tag": "1.0.3"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "mtpLocaleManager/Classes/**/*",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This