feat: complete change to gettext from homebrew i18n solution

This commit is contained in:
2026-05-03 22:28:25 +02:00
parent 4bee8cf1db
commit 4de8492c4f
96 changed files with 21579 additions and 1497 deletions

42
lib/bds/gettext.ex Normal file
View File

@@ -0,0 +1,42 @@
defmodule BDS.Gettext do
@moduledoc """
Gettext backend for bDS2.
Two domains are used:
- "ui" : application chrome, menus, settings, dashboard, toasts
- "render" : blog output (Liquid templates, archive labels, pagination, etc.)
The UI locale is managed per-process via `put_locale/1`.
The render locale is passed explicitly via `lgettext/4` so that a single
process can resolve UI strings in the OS language and render strings in
the project's mainLanguage simultaneously.
"""
use Gettext.Backend, otp_app: :bds
@doc """
Convenience wrapper around `lgettext/4` with empty bindings.
Returns the resolved string directly (not a tuple).
"""
def lgettext(locale, domain, msgid) do
case lgettext(locale, domain, msgid, %{}) do
{:ok, text} -> text
{:default, text} -> text
end
end
@doc """
Sets the locale for this backend in the current process.
"""
def put_locale(locale) do
Gettext.put_locale(__MODULE__, locale)
end
@doc """
Gets the locale for this backend in the current process.
"""
def get_locale do
Gettext.get_locale(__MODULE__)
end
end