Internationalization

Copy Markdown View Source

GanttEx ships with Gettext translations for:

LocaleLanguage
enEnglish
esSpanish
frFrench
itItalian
deGerman
ptPortuguese
pt_BRBrazilian Portuguese
jaJapanese

Choose it per chart; names such as "pt-BR" or "es-CL" are normalized:

<.live_component module={GanttEx.Live.Gantt} id="gantt" tasks={@tasks} links={@links} locale={@locale} />

The translations live in their own backend (GanttEx.Gettext), so they never mix with your application's messages.

Date patterns

Date formats are translated too, so each language orders dates its own way (03/07/2025 in English, 07/03/2025 in Spanish, 07.03.2025 in German, 2025/03/07 in Japanese):

GanttEx.I18n.format(~N[2025-03-07 00:00:00], :month_year, "ja")
#=> "2025年3月"

The named patterns are :date, :datetime, :time, :day, :weekday_day, :day_month, :weekday_date, :month_year, :month, :year and :quarter.

Adding or fixing a language

  1. Add the locale to @locales in GanttEx.I18n.
  2. Run mix gettext.merge priv/gettext --locale xx.
  3. Translate priv/gettext/xx/LC_MESSAGES/default.po, including the date format patterns and the month and weekday names.

test/gantt_ex/i18n_test.exs fails if any message of a bundled locale is left untranslated.