Code Monkey home page Code Monkey logo

proton-i18n's Introduction

Proton I18N

A CLI to manage translations - validation - extraction - sync with crowdin

We use ttag for our React projects and angular-gettext for our WebClient.

How to install ?

$ npm i -D github:ProtonMail/proton-i18n.git#semver:^1.0.0

Commands

$ npx proton-i18n help
Usage: $ proton-i18n <command>
Available commands:
  - crowdin
      To update, download etc. translations (--help to get more details)

  - validate <type>
      To validate the translations, check if we have contexts
        - type: default (default) validate we don't have missing context
        - type: lint-functions check if we use the right format for ttag

  - extract <type>
      Extract all translations from the projet
      - type: default (app) extract translations from the app and reactComponents + shared
      - type: reactComponents extract only translations from react-components
      - type: shared extract only translations from proton-shared

  - list <type>
      List all translations available
        - type: default (default) write them inside a file po/lang.json
        - type: show print JSON inside the console

  - compile
      Compile all translations from the dir ./po to a JSON inside src/i18n/<lang>.json

  - commit <type>
      Commit translations
      - type: update commit new extracted translations
      - type: upgrade commit new translations (po, json)

  - upgrade <flag>
      Upgrade translations inside your app from the latest version available on crowdin.
      It will:
        - Get list of translations available
        - Upgrade our translations with ones from crowdin
        - Store a cache of translations available in the app
        - Export translations as JSON
        - Commit everything

      - flag: default none, it will auto fetch latest translations (proton-i18n crowdin --list --type --limit=95)
      - flag: --custom it will use your version of the file
      - flag: --limit-i18n Custom limit to extract the list of translations available. Default 90.

Validate

$ proton-i18n validate

Output errors in translation if we don't find a context for one or many translatins.

$ proton-i18n validate --lint

For the CI, reject if there is at least one missing context

How to setup ?

You need to have a file .env inside the directory <project>/env/.

I18N_DEPENDENCY_REPO=<REPOSITORY WITH TRANSLATIONS>
I18N_DEPENDENCY_BRANCH=<BRANCH FOR THE TRANSLATIONS>
CROWDIN_KEY_API=<API-KEY>
CROWDIN_PROJECT_NAME=<CROWDIN-PROJECT-NAME>
CROWDIN_FILE_NAME='<FILE NAME AVAILABLE ON CROWDIN>' // ex: ProtonVPN Settings Website.pot
I18N_TEMPLATE_FILE:<FILE SOURCE TO UPLOAD TO CROWDIN>

You don't need these key if you don't manage crowdin, for extraction and validation we won't need them.

  • I18N_TEMPLATE_FILE: Default value -> template.pot

We need this key to detect the project as we require some custom code for it.

Tests

Update test linter

Add a use case inside test/js then run ./test/run.sh generate

proton-i18n's People

Contributors

dhoko avatar mmso avatar vincaslt avatar

Watchers

 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.