[#32] Bugfix - Plurals does not work
L10n-swift is a simple framework that improves localization in swift app, providing cleaner syntax and in-app language switching.
Localizable
*.plist
*.json
*.stringsdict
*.strings
NonLocalized
DoubleLength
Accented
Bounded
ForcedRightToLeft
.l10n()
pod try L10n-swift
pod 'L10n-swift', '~> 5.10'
github "Decybel07/L10n-swift", ~> 5.10
.Package(url: "https://github.com/Decybel07/L10n-swift.git", majorVersion: 5)
Import L10n_swift at the top of each Swift file that will use framework.
import L10n_swift
Add .l10() following any String object you want localized:
.l10()
String
"hello.world".l10n()
Add .l10() following number you want localized. Using the number format for the current language:
12.l10n() 24.l10n(minIntegerDigits: 4) 1.61803.l10n() 2.71828.l10n(fractionDigits: 2) 3.14.l10n { formatter in formatter.numberStyle = .currency }
Add .l10() following any Date object you want localized using the date format for the current language:
Date
Date().l10n() Date().l10n { formatter in formatter.dateStyle = .medium }
Add .l10nPlural(CVarArg...) following any String object you want translated with plurals:
.l10nPlural(CVarArg...)
"numberOfApples".l10nPlural(2)
More about plurals, you can read on wiki
Add observer for notification L10nLanguageChanged. This notification is called when language has been changed.
L10nLanguageChanged
NotificationCenter.default.addObserver( self, selector: #selector(self.yourFunction), name: .L10nLanguageChanged, object: nil )
L10n.shared.language = "en" L10n.shared.language = "en-GB"
At runtime, you can switch the language at any time by setting the language property.
L10n.shared.language
L10n.shared.locale
L10n.supportedLanguages
A list of all the languages contained in the main bundle.
L10n.preferredLanguage
A preferred language contained in the main bundle.
More about .plist format you can read on wiki.
More about .stringsdict format you can read on wiki.
More about .json format you can read on wiki.
More about .strings format you can read on wiki.
Adrian Bobrowski (Decybel07), adrian071993@gmail.com
L10n-swift is available under the MIT license. See the LICENSE file for more info.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
L10n-swift is a simple framework that improves localization in swift app, providing cleaner syntax and in-app language switching.
Overview
🌟 Features
Localizable
file names.*.plist
,*.json
,*.stringsdict
,*.strings
.NonLocalized
,DoubleLength
,Accented
,Bounded
,ForcedRightToLeft
..l10n()
to localize any string, date and numbers.💻 Demo
⚠️ Requirements
👥 Communication
📗 Installation
CocoaPods
Carthage
Swift Package Manager
📘 Usage
Import L10n_swift at the top of each Swift file that will use framework.
Get localized text
Add
.l10()
following anyString
object you want localized:Get localized number
Add
.l10()
following number you want localized. Using the number format for the current language:Get localized date
Add
.l10()
following anyDate
object you want localized using the date format for the current language:Get plural
Add
.l10nPlural(CVarArg...)
following anyString
object you want translated with plurals:More about plurals, you can read on wiki
Observe language changed
Add observer for notification
L10nLanguageChanged
. This notification is called when language has been changed.Set language
At runtime, you can switch the language at any time by setting the language property.
Get current language
Get locale for current language
Get list of supported languages
A list of all the languages contained in the main bundle.
Get preferred language
A preferred language contained in the main bundle.
Supported formats
.plist, .stringsdict
More about .plist format you can read on wiki.
More about .stringsdict format you can read on wiki.
.json
More about .json format you can read on wiki.
.strings
More about .strings format you can read on wiki.
📙 FAQ
🤓 Author
Adrian Bobrowski (Decybel07), adrian071993@gmail.com
🔑 License
L10n-swift is available under the MIT license. See the LICENSE file for more info.