LogoLogo
v1.6.1
v1.6.1
  • 🌸What is Petal Pro?
  • πŸ’‘Changelog
  • ⏫Upgrade guide
  • Guides
    • πŸš€Creating a web app from start to finish
  • πŸ‘©β€πŸ³Recipes
    • πŸ’How to apply a recipe with git cherry pick
    • #️⃣UUIDs
    • ✍️First/Last name
    • πŸ“¦NPM packages
    • πŸ—ΊοΈGoogle Maps
  • Fundamentals
    • πŸ’ΏInstallation
    • πŸ“‚Folder structure
    • πŸ—ƒοΈIncluded Pages
    • πŸ˜€Users & Authentication
    • 🏒Organizations & Multitenancy
    • 🧊Components
    • ⬛Dark mode
    • 🎨Branding
    • 🌱Seeding
    • πŸ“„Layouts & Menus
    • πŸ–ΌοΈImage uploads
    • πŸ‘₯Impersonation
    • πŸ› οΈBackground Tasks and Jobs
    • πŸ”§Util & Helpers
    • πŸ“§Emails
    • πŸͺJavascript Hooks
    • πŸ“šExtra Hex Libraries
    • πŸ—οΈGenerators
    • πŸ—£οΈTranslations
    • πŸ–οΈContributing
    • πŸ›«Deployment
    • πŸ›‘οΈTesting
Powered by GitBook
On this page
  • How to add update your pot/po files after adding more gettexts
  • How to add/remove languages

Was this helpful?

  1. Fundamentals

Translations

PreviousGeneratorsNextContributing

Last updated 1 year ago

Was this helpful?

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

  • the

  • a good explaining Gettext

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

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"}
]
mix gettext.merge priv/gettext --locale fr

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

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
Twitter thread
hex docs for Gettext
blog post
You should only modify the files in the LC_MESSAGES folders