• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Abedalkareem/LanguageManager-iOS: A Language manager to handle changing app lang ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

Abedalkareem/LanguageManager-iOS

开源软件地址:

https://github.com/Abedalkareem/LanguageManager-iOS

开源编程语言:

Swift 92.0%

开源软件介绍:


A Language manager to handle changing app language without restarting the app.


ScreenShots

LanguageManager-SwiftUI

For SwiftUI please visit the LanguageManager-SwiftUI

Usage

Youtube: iOS - Support multiple languages (Localization).
Watch the video

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, add this line with the string you used in the UILabel inside the storyboard
"Hello !" = "Hello !";
and for Arabic file :
"Hello !" = "مرحبا !";


After that in the `didFinishLaunchingWithOptions` method inside the `AppDelegate.swift` file, set your default language that your app will run first time
LanguageManager.shared.defaultLanguage = .en // you can use .deviceLanguage to keep the device default language.

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
    LanguageManager.shared.setLanguage(language: selectedLanguage)
    { title -> UIViewController in
      let storyboard = UIStoryboard(name: "Main", bundle: nil)
      // the view controller that you want to show after changing the language
      return storyboard.instantiateInitialViewController()!
    } animation: { view in
      // do custom animation
      view.transform = CGAffineTransform(scaleX: 2, y: 2)
      view.alpha = 0
    }
  }

If you have an image and you want to change the direction of the image depending on the language, you can use image direction property, the property can be one of the following values:

-fixed: if the image must not change the direction depending on the language, you need to set the value as 0.

-leftToRight: if the image must change the direction depending on the language and the image is left to right image then you need to set the value as 1.

-rightToLeft: if the image must change the direction depending on the language and the image is right to left image then you need to set the value as 2.

Please check the example project to see how it works.

Installation

LanguageManager-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"

You can also use Swift Package Manager.

Support me


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap