GithubHelp home page GithubHelp logo

bikemap / lingohubcli Goto Github PK

View Code? Open in Web Editor NEW
1.0 21.0 0.0 71 KB

A simple swift command line tool for automating LingoHub translations.

License: Apache License 2.0

Swift 100.00%
lingohub command-line-tool swift localization

lingohubcli's Introduction

LingoHubCLI

The lingohub command line tool makes it super-easy to upload and download localisable resources to and from LingoHub.

It currently supports iOS and Android projects (with the option to extend to any platforms).

Important note: Only base translations are uploaded to LingoHub and base translations are never overwritten with data from LingoHub. This means, alterations to the base have to be done within the project by a developer.

Upload

$ lingohub upload

The tool extracts the base translation of the project and uploads it to LingoHub for translation.

Download

$ lingohub download

The tool downloads all available translated resources of the project from LingoHub and places them in the proper folder.

Installation

See Build & Distribution section below for building the tool from source.

For easy install on macOS, find the latest binary in the release section.

Use the tool locally in your project folder or copy it to /usr/local/bin/ for global access.

Configuration

The configuration is done using the .lingorc file in the project root folder.

Property Description
platform ios, android Specifies the platform of the project. File locations and naming conventions depend on this.
team The slug of the team from LingoHub. For instance: "bikemap-gmbh"
project The slug of the project name from LingoHub. For instance: 'ios-test'
token The authorisation token generated by LingoHub.
projectFolder Optional Defaults to the current directory.
translationFolder The folder where the translations are stored. For instance app/src/main/res for Android.
baseLocale The base translation's locale. Your default language. This local will be the one uploaded to LingoHub, however it is never downloaded.
separator The separator you used for your uploaded resources.

Example .lingorc:

{
  "platform": "android",
  "team": "bikemap-gmbh",
  "project": "android-test",
  "token": "your-token",
  "projectFolder": "/Users/path/to/projet/folder/",
  "translationFolder": "app/src/main/res",
  "baseLocale": "en",
  "separator": "_"
}

Naming Convention

iOS

According to LingoHub documentation, we put the locale in the files names, for instance: Localizable_zh-Hans-CN.strings or BMRideStartBottomBarView_it.strings". The locale is then recognised by LingoHub automatically.

The locale format depends on the platform (e.g. simplified Chinese on iOS is zh-Hans-CN). Then you define your separator (_ in the above example) to work with your local files and folders.

Android

Android differs in a way that they need an additional "r" in the name of the folders, where the language is used in different countries. For instace the Brazilian Portuguese locale folder looks like this: src/main/res/values-pt-rBR.

So for this reason we upload the strings files named like strings-pt-rBR.xml. The lingohub script then uses these locales in the file name when placing the new translations into the project.

Build & Distribution

You need swift 4 to be installed.

$ swift build -c release -Xswiftc -static-stdlib
Compile Swift Module 'LingoHubCLI' (5 sources)
Linking ./.build/x86_64-apple-macosx10.10/release/LingoHubCLI

$ cp ./.build/x86_64-apple-macosx10.10/release/LingoHubCLI ./lingohub

Or to install globally:

$ cp -f ./.build/x86_64-apple-macosx10.10/release/LingoHubCLI /usr/local/bin/lingohub

Contribution

To support more platforms:

  • add a new class that confirms to the ResourceProvider protocol,
  • implement project specific logic,
  • extend the func engage() in the main.swift file.

lingohubcli's People

Contributors

benedikt-brandtner-bikemap avatar hactar avatar olkir avatar

Stargazers

 avatar

Watchers

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