Swift 国际化和本地化框架 Localize-Swift

码农软件 · 软件分类 · 其他(Others) · 2019-07-18 16:29:31

软件介绍

Localize-Swift 是一个简单的用于 Swift 应用的国际化和本地化框架,提供了清晰的语法和应用内的多语言切换。

特性

  • 可保留你应用内已经使用的 Localizable.strings 文件

  • 允许用户直接修改应用的语言而无需更改设备语言

  • 使用 .Localized() 替代 NSLocalizedString(key,comment) - 更具 Swifty 语法风格

  • 通过新的 python 脚本 genstrings 来生成你的字符串,可识别 .Localized().

使用方法

在每个 Swift 文件中引入 Localize 用来包含本地化的文本

If Carthage -

import Localize

If CocoaPods -

import Localize_Swift

Add .Localized() following any String object you want translated:

textLabel.text = "Hello World".Localized()

To get an array of available localizations:

Localize.availableLanguages()

To change the current language:

Localize.setCurrentLanguage("fr")

To update the UI in the viewcontroller where a language change can take place, observe LCLLanguageChangeNotification :

NSNotificationCenter.defaultCenter().addObserver(self, selector: "setText", name: LCLLanguageChangeNotification, object: nil)

To reset back to the default app language:

Localize.resetCurrentLanaguageToDefault()

本文地址:https://codercto.com/soft/d/10414.html

Programming PHP

Programming PHP

Rasmus Lerdorf、Kevin Tatroe、Peter MacIntyre / O'Reilly Media / 2006-5-5 / USD 39.99

Programming PHP, 2nd Edition, is the authoritative guide to PHP 5 and is filled with the unique knowledge of the creator of PHP (Rasmus Lerdorf) and other PHP experts. When it comes to creating websit......一起来看看 《Programming PHP》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换