Code Monkey home page Code Monkey logo

poeditorswift's Introduction

POEditorSwift

Version License Platform

This library is still in Alpha version.

This is an unofficial POEditor Swift library. The main purpose of this library is to make available string translations without being forced to static Localizable.strings files that can be updated only with new releases.

POEditorSwift downloads translations using POEditor APIs and store them locally. A new update is performed only if a new version of a specific language is available remotly.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

POEditorSwift is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'POEditorSwift'

Usage

Initialization

In your AppDelegate didFinishLaunchingWithOptions method initialize POEditorSwift with your API key. You can find your API Key in your POEditor Account Settings Page

import POEditorSwift

POEditor.start(withKey: "YOUR-API-KEY")

Update translations

Now you just have to load translations for a specific project id. Completion block will inform you if thare was an error during update phase. If error is nil everything is updated correctly.

do {
    try POEditor.updateLanguages(for: PROJECT-ID) { error in 
        //check error on completion
    }
} catch {
    //probably you forgot to start POEditor with API key
}

Discover project

If you don't know your project number or you prefer to load it programmatically you can gat all projects from you account using:

POEditor.getProjects { (result) in
            switch result{
            case .success(let projects):
                //All projects
                return
            case .failure(let error):
                //Error
                return
            }
        }

Translate a string

To translate a string just use String class extension:

// Use Locale.current language code
"myString".localize()

// Force a specific language code
"myString".localize(in: "Language code, IE: en")

If the requested translation is not available it will fallback on NSLocalizedString

TODOs

Before declaring this library in beta version there's still some work to do:

  • Unit test the whole library
  • Add Travis CI
  • Add swiftlint
  • I'm sure that this list is longer but i don't know how to fill it

Author

Giuseppe Travasoni, [email protected]

License

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

poeditorswift's People

Contributors

neobeppe avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.