πŸ—£οΈTranslations

If you're new to translations then please take a look at our Twitter thread explaining the basics. Also check out:

In a nutshell, you run text that you want translated through the gettext function and then add in your translations. These are found in priv/gettext. The .pot files are auto-generated - you just need to modify the files in the LC_MESSAGES folders.

We've tried to implement gettext throughout the public facing areas of the boilerplate (we may have missed some places - feel free to point them out to us or a PR would be very helpful).

How to add update your pot/po files after adding more gettexts

When you add new gettext calls, your translation files won't show them until this command is run:

mix gettext.extract --merge

Or if you can use our easier-to-remember alias (aliases are defined in the mix.exs file):

mix update_translations

Then go and add your translations to the files in the LC_MESSAGES folders for each language.

How to add/remove languages

Modify the languages in the confix.exs file:

config.exs
config :petal_pro, PetalProWeb.Gettext, allowed_locales: ~w(en fr)

config :petal_pro, :language_options, [
  %{locale: "en", flag: "πŸ‡¬πŸ‡§", label: "English"},
  %{locale: "fr", flag: "πŸ‡«πŸ‡·", label: "French"}
]

If you're adding a new language, you'll need to run this (keep in mind fr means French - change this to whatever language you're adding - here's a list of them all):

mix gettext.merge priv/gettext --locale fr

To delete a language, remove it from the config and delete the corresponding folder in priv/gettext.