Home

Awesome

<p align="center"> <img width="75%" src="https://raw.githubusercontent.com/Decybel07/L10n-swift/master/Images/Logo.png" alt="L10n-swift"/> </p>

Build Status CocoaPods Version Language Swift4 CocoaPods License Pod method Compatible Mentioned in Awesome-swift

<!--[![Docs percent](https://img.shields.io/cocoapods/metrics/doc-percent/L10n-swift.svg)](http://cocoadocs.org/docsets/L10n-swift/)--> <!--[![codecov](https://codecov.io/gh/Decybel07/L10n-swift/branch/master/graph/badge.svg)](https://codecov.io/gh/Decybel07/L10n-swift)--> <!--[![Codacy Badge](https://api.codacy.com/project/badge/Grade/3063467ecae74021b7666787333eac54)](https://www.codacy.com/app/Decybel07/L10n-swift/dashboard)--> <!--[![codebeat badge](https://codebeat.co/badges/5f83f891-8cd6-4b12-9340-562a74c51442)](https://codebeat.co/projects/github-com-decybel07-l10n-swift-master)-->

L10n-swift is a simple framework that improves localization in swift app, providing cleaner syntax and in-app language switching.

Overview

<p align="center"> <table><tr> <td><img src="https://raw.githubusercontent.com/Decybel07/L10n-swift/master/Images/language720.gif" alt="Change language"/></td> <td><img src="https://raw.githubusercontent.com/Decybel07/L10n-swift/master/Images/translator720.gif" alt="Simple translator"/></td> <td><img src="https://raw.githubusercontent.com/Decybel07/L10n-swift/master/Images/plurals720.gif" alt="Plurals"/></td> </tr></table> </p>

🌟 Features

💻 Demo

pod try L10n-swift

⚠️ Requirements

👥 Communication

📗 Installation

CoreExtensionIBInspectable
L10n-swift✔️✔️✔️
L10n-swift/Core✔️
L10n-swift/Extension✔️✔️
L10n-swift/IBInspectable✔️✔️

CocoaPods

pod 'L10n-swift', '~> 5.10'

Carthage

github "Decybel07/L10n-swift", ~> 5.10

Swift Package Manager

.Package(url: "https://github.com/Decybel07/L10n-swift.git", majorVersion: 5)

📘 Usage

Import L10n_swift at the top of each Swift file that will use framework.

import L10n_swift

Get localized text

Add .l10() following any String object you want localized:

"hello.world".l10n()

Get localized number

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
}

Get localized date

Add .l10() following any Date object you want localized using the date format for the current language:

Date().l10n()

Date().l10n { formatter in
    formatter.dateStyle = .medium
}

Get plural

Add .l10nPlural(CVarArg...) following any String object you want translated with plurals:

"numberOfApples".l10nPlural(2)

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.

NotificationCenter.default.addObserver(
    self, selector: #selector(self.yourFunction), name: .L10nLanguageChanged, object: nil
)

Set language

L10n.shared.language = "en"
L10n.shared.language = "en-GB"

At runtime, you can switch the language at any time by setting the language property.

Get current language

L10n.shared.language

Get locale for current language

L10n.shared.locale

Get list of supported languages

L10n.supportedLanguages

A list of all the languages contained in the main bundle.

Get preferred language

L10n.preferredLanguage

A preferred language contained in the main bundle.

Supported formats

.plist, .stringsdict

<img src="https://raw.githubusercontent.com/Decybel07/L10n-swift/master/Images/sample_plist_file.png" alt="Sample .plist and .stringsdict file" width="597" style="max-width:100%;"/>

More about .plist format you can read on wiki.

More about .stringsdict format you can read on wiki.

.json

<img src="https://raw.githubusercontent.com/Decybel07/L10n-swift/master/Images/sample_json_file.png" alt="Sample .json file" width="554" style="max-width:100%;"/>

More about .json format you can read on wiki.

.strings

<img src="https://raw.githubusercontent.com/Decybel07/L10n-swift/master/Images/sample_strings_file.png" alt="Sample .strings file" width="544" style="max-width:100%;"/>

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.