Latest 1.0.0
Homepage https://github.com/Abedalkareem/LanguageManager-iOS
License MIT
Platforms ios 9.0
Authors

LanguageManager-iOS

Language manager used to handle change app language without restart the app

ScreenShots

LanguageManager-iOS

Usage

First of all, remember to add the Localizable.strings to your project, after adding the Localizable.strings file, select it then go to file inspector and below localization press localize, after that go to PROJECT > Localisation then add the languages you want to support (Arabic for example), dialog will appear to ask you which resource file you want to localize, select just the Localizable.strings file.
 
Now, go to your storyboard and add UILable and add text to it, for example "Hello !", then go to your Localizable.strings file expand it, you will find Localizable strings file for English and Arabic, for English put just this line with the string you put in the UILabel inside the storyboard
"Hello !" = "Hello !";
and for Arabic file :
"Hello !" = "مرحبا !";

After that in didFinishLaunchingWithOptions inside the AppDelegate.swift set your default language that your app will run first time

LanguageManger.shared.defaultLanguage = .en

If you want to change the language use the setLanguage(language:) method by passing to it the new language

@IBAction func changeLanguage(_ sender: UIButton) {

    let selectedLanguage:Languages = sender.tag == 1 ? .en : .ar

    // change the language
    LanguageManger.shared.setLanguage(language: selectedLanguage)

    // then you must to pop all view controllers and return to root view controller then re set the root view controller 
    UIApplication.topViewController!.dismiss(animated: true) {
        let delegate = UIApplication.shared.delegate as! AppDelegate
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        delegate.window?.rootViewController = storyboard.instantiateInitialViewController()
    }
}

*Note
The language manager help you to support multiple languages in your app, However, there are some cases that you want to handle it yourself like some UILable or UITextField didn’t change the direction, so you need to do that .
Example:

textAlignment = LanguageManger.shared.isRightToLeft ? .right : .left.

Installation

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

pod 'LanguageManager-iOS'

Or you can use Carthage.

github "Abedalkareem/LanguageManager-iOS"

Note

I’m going to be very happy if you give me a feedback or advice , thank you

License

The MIT License (MIT)

Copyright (c) 2017 Abedalkareem

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Latest podspec

{
    "name": "LanguageManager-iOS",
    "version": "1.0.0",
    "summary": "Language manager used to handle change app language",
    "description": "Language manager used to handle change app language without restart the app.",
    "homepage": "https://github.com/Abedalkareem/LanguageManager-iOS",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Abedalkareem": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Abedalkareem/LanguageManager-iOS.git",
        "tag": "1.0.0"
    },
    "swift_version": "4.2",
    "social_media_url": "https://twitter.com/AbedalkareemOmr",
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "LanguageManager-iOS/Classes/**/*"
}

Pin It on Pinterest

Share This