Giter Site home page Giter Site logo

arb's Introduction

ARB

Command line tool to localize Flutter apps using the DeepL translation API.

Install

cargo install arb

Configuration

Configure your Flutter l10n.yaml file to include a name-prefix and overrides-dir for human translations, for example:

arb-dir: i10n/translations
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
nullable-getter: false
untranslated-messages-file: untranslated.txt
overrides-dir: i10n/overrides
name-prefix: app

Usage

Convert all the strings from the template language into French and write the translations to app_fr.arb:

export DEEPL_API_KEY="<api key>"
arb translate --lang fr --apply l10n.yaml

To see what changes would be made omit the --apply option which will skip calls to the DeepL API and not write files to disc:

arb translate --lang fr l10n.yaml

After making changes to the template resource bundle run the update command to sync translations:

arb update l10n.yaml

For more commands and options run arb help.

Notes

Cache

Once a translation has been created the program will use a diff of the template keys to only translate when necessary and delete translations that have been removed. In order to detect changes to strings a cache file is kept in the application resource bundle directory named .cache.json.

Overrides

If you have human improvements or corrections to the machine-generated translations you can use the --overrides option to prefer human provided translations.

Placeholders

To prevent placeholders from being translated they are converted to XML tags (<ph>) and the API requests are configured to ignore translations for those tags.

Test

Set an API key to run the tests:

export DEEPL_API_KEY="<api key>"
cargo test

License

MIT or Apache-2.0 at your discretion.

© Copyright Save Our Secrets Pte Ltd 2024; all rights reserved.

arb's People

Contributors

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