getatrex

Automatic Gettext locale translator for Elixir/Phoenix projects.


Keywords
elixir, gettext, locale, phoenix-framework, translation
License
Apache-2.0

Documentation

Getatrex circleci

Gettext Automatic Translator Written in Elixir

Translates .PO files generated by gettext in your Elixir/Phoenix project

Demo how it works

IMAGE ALT TEXT HERE

Installation

Install package

The package can be installed by adding getatrex to your list of dependencies in mix.exs:

def deps do
  [{:getatrex, "~> 0.1.0", only: :dev, runtime: false}]
end

This will install goth package as a dependency which you will need to set up in order to use for Google automatic translations.

Add Google Cloud Translation API Key for Goth package

If you don't have API key, you can get it in your Google Cloud Console https://console.cloud.google.com/apis/credentials

Download JSON file with credentials, put it somewhere (not recommending to put in under source control).

Open your config/config.exs file and add following:

# Google credentials
config :goth, json: "goth_credentials.json" |> File.read!

where json is the path to you credentials file.

Getting started

  1. Follow instruction in the Workflow section of the gettext library

  2. Generate new locale, e.g. for Spanish this would be:

$ mix gettext.merge priv/gettext --locale es
  1. IMPORTANT! Do the git commit -a -m 'adding new spanish locale' to have previous version fixed in git with possibility to easily edit and revert.

  2. Translate new Spanish locale with getatrex:

$ mix getatrex es

Now you have new file created translated_default.po with translations, you can now open your IDE to fix silly translations and replace original default.po when you done.

TODO

  1. Write translations to original default.po to avoid this copy-paste step
  2. Implement plurals
  3. Translate errors.po