Latest 0.2.0
Homepage https://github.com/danielsaidi/SwiftLocalization
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

SwiftLocalization is a Swift library that can be used to handle localization in
iOS apps. It is currently limited to the functionality I need in my own apps. I
will extend it as those apps become more sophisticated over time.

Getting started

I have currently not had time to setup a demo that shows how you build a custom
tutorial on top of this library. For now, have a look at the code.

Global convenience functions

SwiftLocalization contains two global (and really simple) convenience functions:

  • translate(...) – translates a language key from Localizable.strings
  • translationExists(...) – checks if a certain language key is localized

These functions can be used instead of having to use NSLocalizedString(…) and
check for equality to determine whether or not a translation exists.

Localization services

SwiftLocalization contains a LocalizationService protocol and also provides a
default implementation. Using this protocol gives you a lot more flexibility in
how texts are translated and locales handled.

The default implementation – LocalizationServiceDefault – can translate texts.
It can also change the current locale of an app in real-time, without having to
restart the app.

IMPORTANT! For LocalizationServiceDefault to work, each Localizable.strings
file in the app must have a language key that indicates its locale, e.g.:

"locale": "en";

The name of this language key can be anything you like, but every file must use
the same name and use it when creating an instance of LocalizationServiceDefault.

Example

To run the demo project, clone the repo, and run pod install from the Example
directory before running the app. This project is currently empty and only used
to verify that the pod will compile properly.

Requirements

SwiftLocalization requires iOS 8 or later.

CocoaPods

SwiftLocalization is available via CocoaPods. To add it
to your project, simply add the following line to your Podfile:

pod "SwiftLocalization"

Author

Daniel Saidi, [email protected]

License

SwiftLocalization is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SwiftLocalization",
    "version": "0.2.0",
    "summary": "SwiftLocalization contains localization functionality for iOS.",
    "description": "SwiftLocalization is a Swift library that contains localization functionality for iOS.nIt contains a set of global convenience functions and a localization service that canntranslate language keys as well as change app locale without having to reboot the app.",
    "homepage": "https://github.com/danielsaidi/SwiftLocalization",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Daniel Saidi": "[email protected]"
    },
    "source": {
        "git": "https://github.com/danielsaidi/SwiftLocalization.git",
        "tag": "0.2.0"
    },
    "social_media_url": "https://twitter.com/danielsaidi",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "SwiftLocalization/Classes/**/*"
}

Pin It on Pinterest

Share This