Coder Social home page Coder Social logo

yonaskolb / l10n-swift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from decybel07/l10n-swift

0.0 3.0 0.0 10.6 MB

Localization of the application with ability to change language "on the fly" and support for plural form in any language.

License: MIT License

Swift 93.36% Ruby 4.22% Objective-C 2.43%

l10n-swift's Introduction

L10n-swift

Build Status CocoaPods Version Language Swift3 CocoaPods Platform CocoaPods License Docs percent Pod method Compatible Codacy Badge codebeat badge Mentioned in Awesome-swift

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

Overview

Change language Simple translator Plurals

๐ŸŒŸ Features

  • Change the language of your apps "on the fly".
  • IBInspectable for Xcode Interface Builder (Cocoa - coming soon).
  • Support for user-defined Localizable file names.
  • Support for formats: *.plist, *.json, *.stringsdict, *.strings.
  • Support for grouping localization keys.
  • Support for plural forms in any language.
  • Use .l10n() to localized any string, date, int and double.
  • Use more than one languages at the same time.

๐Ÿ’ป Demo

pod try L10n-swift

โš ๏ธ Requirements

  • iOS 9.0+ | macOS 10.10+ | tvOS 9.0+ | watchOS 2.0+
  • Swift 3.0+

๐Ÿ‘ฅ Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

๐Ÿ“— Installation

Core Extension IBInspectable
L10n-swift โœ”๏ธ โœ”๏ธ โœ”๏ธ
L10n-swift/Core โœ”๏ธ
L10n-swift/Extension โœ”๏ธ โœ”๏ธ
L10n-swift/IBInspectable โœ”๏ธ โœ”๏ธ
pod 'L10n-swift', '~> 5.0'
github "Decybel07/L10n-swift", ~> 5.0
.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:

"HelloWorld".l10n()

Get localized number

Add .l10() following any Int, Double or NSNumber object 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 number format for the current language:

Date().l10n()

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

Get plural

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

"numberOfApples".l10n(arg: 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

Sample .plist and .stringsdict file

More about .plist format you can read on wiki

More about .stringsdict format you can read on wiki

.json

Sample .json file

More about .json format you can read on wiki

.strings

Sample .strings file

More about .strings format you can read on wiki.

๐Ÿ“™ FAQ

๐Ÿค“ Author

Adrian Bobrowski (Decybel07), [email protected]

๐Ÿ”‘ License

L10n-swift is available under the MIT license. See the LICENSE file for more info.

l10n-swift's People

Contributors

decybel07 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.