🗣
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.
You should only 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). When you add new
gettext
calls, your translation files won't show them until this command is run:mix gettext.extract --merge
Then go and add your translations to the files in the
LC_MESSAGES
folders for each language.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
. Last modified 4mo ago