GithubHelp home page GithubHelp logo

jayrave / android_localization Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 545 KB

CLI to automate parts of localization

License: Apache License 2.0

Rust 99.47% Shell 0.53%
cli android-localization

android_localization's Introduction

Build Status Release

android_localization is a command line program to ease working with strings.xml for localizing to non-default locales

Commands

  • localize - Creates CSVs of texts that need to be localized
  • localized - Populates strings XML files from localized texts in CSVs
  • validate - Runs some common validations on XML string files

Quick tour

You are working on your Android app or library & now it is time to localize to non-defaults locales. Probably you wanna find the texts that are yet to be localized, ship them off to a localization service, put the texts in when it comes back & make sure that it didn't get messed up in any way. This CLI helps you automate everything except the actual localization.

./android_localization localize --output-dir ~/to_localize --res-dir ~/my_app/app/src/main/res
./android_localization localized --input-file ~/localized/texts.csv --res-dir ~/my_app/app/src/main/res
./android_localization validate --res-dir ~/my_app/app/src/main/res

Sample input & output

Localize

Let's say we start with these strings.xml files -

<!--values/strings.xml-->
<resources>
    <string name="string_1">string_1 default locale</string>
    <string name="string_2">string_2 default locale</string>
    <string name="string_3">string_3 default locale</string>
</resources>
<!--values-es/strings.xml-->
<resources>
    <string name="string_2">string_2 spanish</string>
</resources>
<!--values-fr/strings.xml-->
<resources>
    <string name="string_2">string_2 french</string>
</resources>

On running ./android_localization localize --output-dir <output_dir> --res-dir <res_dir>, the created CSV would look thus -

string_name default_locale es fr
string_1 string_1 default locale
string_3 string_3 default locale

Localized

Carrying on from the o/p of the localize command, once we put in the localized strings, the input CSV would look thus -

string_name default_locale es fr
string_1 string_1 default locale string_1 spanish string_1 french
string_3 string_3 default locale string_3 spanish string_3 french

On running ./android_localization localized --input-file <input_file> --res-dir <res_dir>, the strings.xmls would be populated & look thus -

<!--values-es/strings.xml-->
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="string_1">string_1 spanish</string>
    <string name="string_2">string_2 spanish</string>
    <string name="string_3">string_3 spanish</string>
</resources>
<!--values-fr/strings.xml-->
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="string_1">string_1 french</string>
    <string name="string_2">string_2 french</string>
    <string name="string_3">string_3 french</string>
</resources>

Installation

Pre-built binaries can be found for the following platforms in the release tab

  • Linux (64-bit)
  • OSX (64-bit)
  • Windows (64-bit)

Compiling from source under the assumption that the appropriate rust toolchain is already installed:

git clone [email protected]:jayrave/android_localization.git
cd android_localization
cargo build --release

Deployment

  • Update version in cli/Cargo.toml
  • Update CHANGELOG.md
  • Add release tag which would trigger travis deploy
  • Once all executables are uploaded, publish the draft release

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.