Gettext Automatic Translator Written in Elixir
Translates .PO files generated by gettext in your Elixir/Phoenix project
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.
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.
-
Follow instruction in the Workflow section of the gettext library
-
Generate new locale, e.g. for Spanish this would be:
$ mix gettext.merge priv/gettext --locale es
-
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. -
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.
- Write translations to original default.po to avoid this copy-paste step
- Implement plurals
- Translate errors.po