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

MoathOthman/MOLH: Localization helper for iOS apps mainly focusing on the LTR/RT ...

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

开源软件名称(OpenSource Name):

MoathOthman/MOLH

开源软件地址(OpenSource Url):

https://github.com/MoathOthman/MOLH

开源编程语言(OpenSource Language):

Swift 98.3%

开源软件介绍(OpenSource Introduction):

MOLH

Localization helper for iOS apps mainly focusing on the LTR/RTL issue

Install

Add pod 'MOLH' to your podfile. (check https://cocoapods.org/ for more info about cocoapods)

You can install it through Swift package manager as well.

How To Use

import MOLH

Start

When you start the app

MOLH.shared.activate(true)

Make sure this method is called only once and not on every reset

or

MOLH.shared.activate(false) to not use swizzling and use subclassing from MOLH* UI classes.

To reset the language

MOLH.setLanguageTo(MOLHLanguage.currentAppleLanguage() == "en" ? "ar" : "en")
MOLH.reset()

Set default

Before .activate set

MOLHLanguage.setDefaultLanguage("ar")

using without swizzling (prefered)

you can choose to not use swizzling MOLH.shared.activate(false) , in that case you subclass MOLH-UI Subclasses , like MOLHTextField , this will give you more controlability as you can by-pass the tag requirement by using forceSwitchingRegardlessOfTag and set it to true.

Images

To make sure an image is flipped when switching to RTL or to LTR, you can use flipIfNeeded() function on image or UIImage().imageFlippedForRightToLeftLayoutDirection()

Fonts

Its better to have the app fonts in one place in your app, e.g. a FontManager. and there you can decide which font to use based on the chosen language, this would be the eaiser way.

Other Frameworks and bundles

Some controls such as ActionSheetDatePicker have locale property so you can set them appropriately e.g.

actionSheetDatePicker?.locale = Locale(identifier: MOLHLanguage.currentLocaleIdentifier())

Common Issues

Collection view content are flipped in a non readable way

use this line to solve it collectionView.semanticContentAttribute = .unspecified Thanks to didats

you may check this post.

uilabel/uitextfield are not reflecting

make sure to set the tag and make sure the .activate method is only called once and not on every reset

Author

Support the library

If you enjoy MOLH and I want to say thank you, you can (buy me a coffee)[https://www.buymeacoffee.com/moathothman]




鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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