Skip to content

Wire core sidebar tabs to PhoenixKitWeb.Gettext for ru/et#529

Merged
ddon merged 3 commits into
BeamLabEU:devfrom
timujinne:feature/core-sidebar-i18n
May 11, 2026
Merged

Wire core sidebar tabs to PhoenixKitWeb.Gettext for ru/et#529
ddon merged 3 commits into
BeamLabEU:devfrom
timujinne:feature/core-sidebar-i18n

Conversation

@timujinne
Copy link
Copy Markdown
Contributor

@timujinne timujinne commented May 10, 2026

Summary

Phase 3 of per-module i18n migration (Q7, deferred from PR #522). Core admin sidebar tabs now carry gettext_backend: PhoenixKitWeb.Gettext so Tab.localized_label/1 translates them at render time — matching the behaviour already working for external module tabs (Newsletters, Billing, Emails, etc.).

Changes

lib/phoenix_kit/dashboard/admin_tabs.ex

  • Added gettext_backend: PhoenixKitWeb.Gettext to 6 explicit %Tab{} literals: :admin_dashboard, :admin_users, :admin_activity, :admin_media, :admin_settings, :admin_settings_media
  • Orchestrator prior work preserved: admin_subtab/8 helper (covers 13 subtabs) + :admin_modules_page

lib/phoenix_kit/dashboard/registry.ex

  • Added gettext_backend: PhoenixKitWeb.Gettext to user-dashboard defaults: :dashboard_home, :dashboard_settings

lib/phoenix_kit/jobs.ex

  • Added gettext_backend: PhoenixKitWeb.Gettext to :admin_jobs Tab

priv/gettext/ru/LC_MESSAGES/default.po

  • Filled 5 existing empty msgstr: Permissions, Settings, Health, Integrations, Organization
  • Appended 13 new entries: Manage Users, Live Sessions, Referral Codes, Activity, Media, General, Authorization, Dimensions, Jobs, Languages, SEO, Sitemap, Home

priv/gettext/et/LC_MESSAGES/default.po

  • Filled existing empty msgstr for Dashboard, Users, Roles, Sessions, Permissions, Settings, Health, Integrations, Organization
  • Appended 14 new entries (same 13 as ru + Modules)

Verification

Verified live on decor_3d_print (port 4001) after mix deps.compile phoenix_kit --force. Sample output under ru locale:

admin_dashboard → Панель управления
admin_users → Пользователи
admin_users_manage → Управление пользователями
admin_users_live_sessions → Активные сессии
admin_users_sessions → Сессии
admin_users_roles → Роли
admin_activity → Активность
admin_users_permissions → Разрешения
admin_media → Медиа
admin_jobs → Задачи
admin_modules_page → Модули
admin_settings → Настройки
admin_settings_general → Общие
admin_settings_authorization → Авторизация
admin_settings_organization → Организация
admin_settings_integrations → Интеграции
admin_settings_media → Медиа
dashboard_home → Панель управления
dashboard_settings → Настройки

Out of scope (separate follow-up sweeps)

  • Body strings on admin LiveView pages (sweep B)
  • Other locales (de/es/fr/it/pl) — fall back to English msgid
  • Module-side packages (done in Phase 2)

Phase 3 of the per-module i18n migration (Q7 deferred from PR BeamLabEU#522).
All core admin sidebar tabs now carry gettext_backend: PhoenixKitWeb.Gettext
so Tab.localized_label/1 can translate them at render time.

Wired tabs:
- admin_dashboard, admin_users (admin_tabs.ex explicit Tab literals)
- admin_activity, admin_media (admin_tabs.ex explicit Tab literals)
- admin_settings, admin_settings_media (admin_tabs.ex explicit Tab literals)
- admin_subtab/8 helper already done by orchestrator (covers 13 subtabs)
- admin_modules_page already done by orchestrator
- dashboard_home, dashboard_settings (registry.ex user-dashboard defaults)
- admin_jobs (jobs.ex Module.admin_tabs/0)

Translation work (ru + et default.po):
- Filled empty msgstr entries for: Permissions, Settings, Health,
  Integrations, Organization (both locales); Dashboard, Users, Roles,
  Sessions (et only — ru already had translations)
- Appended 13 new entries each locale: Manage Users, Live Sessions,
  Referral Codes, Activity, Media, General, Authorization, Dimensions,
  Jobs, Languages, SEO, Sitemap, Home
- Modules entry already added by orchestrator (ru only); added for et

No @Version bump. No CHANGELOG entry (maintainer-owned).
mdon pushed a commit to mdon/phoenix_kit that referenced this pull request May 10, 2026
- Drop phx-change from <form> — was duplicating the binding on the
  inner <input>, causing the same "search" event to fire twice in
  quick succession on each keystroke (input first, then form on the
  same change). Server did double work; payloads matched so no
  incorrect state, but redundant.
- Add phx-target to <form> so phx-submit retargets correctly when
  the toolbar is rendered inside a LiveComponent. Latent bug — no
  in-tree consumer used target with on_submit, but the contract was
  broken for future ones.
- Add 2 regression tests asserting phx-change appears exactly once
  and phx-target appears on both <form> and <input> in the form
  variant. Test count now 15 (was 13).

Both issues surfaced in the self-review for PR BeamLabEU#529.
mdon pushed a commit to mdon/phoenix_kit that referenced this pull request May 10, 2026
Self-review of PR BeamLabEU#529 archived to dev_docs/pull_requests per
project convention. Verdict: APPROVE with NITPICKs. Two
IMPROVEMENT-MEDIUM items (search_toolbar form variant double-binds
phx-change; phx-target not propagated to <form>) were fixed in
preceding commit dfc9123.
timujinne and others added 2 commits May 11, 2026 08:06
Resolved conflicts in priv/gettext/{et,ru}/LC_MESSAGES/default.po by taking
upstream/dev side. Rationale:

et:
- Sessions: Sessioonid (consistent with "Aktiivsed sessioonid")
- Settings: Seaded (consistent with rest of file)
- Health:   Seisund (more semantic)
- Big block: upstream's gettext.extract already covered all admin_tabs.ex
  msgids from PRs BeamLabEU#530/BeamLabEU#531 with matching translations; the orphan "Home"
  entry added in this branch had no source reference (admin_dashboard
  label is "Dashboard", not "Home") and was dropped.

ru:
- Permissions: Права (consistent with "Права для", "Права обновлены")
- Big block: same reasoning as et.

PR's gettext_backend wiring in admin_tabs.ex (8 tabs), registry.ex (2
tabs), and jobs.ex (1 tab) preserved by the merge.
All user-facing strings in the media browser (buttons, titles, tooltips,
placeholders, empty states, flash notifications, and confirm dialogs) are
now routed through gettext/ngettext. Russian and Estonian translations
filled in (3-form and 2-form plurals respectively).
@ddon ddon merged commit 21252d1 into BeamLabEU:dev May 11, 2026
@timujinne
Copy link
Copy Markdown
Contributor Author

Additional commit c717c9d0 cherry-picked into this branch: Wrap MediaBrowser UI strings in gettext + add ru/et translations.

Scope (out of the original PR description):

  • lib/phoenix_kit_web/components/media_browser.{ex,html.heex} — all user-facing strings (buttons, titles, tooltips, placeholders, empty states, flash notifications, confirm dialogs) routed through gettext / ngettext.
  • lib/phoenix_kit_web/live/users/media.{ex,html.heex} — page title + admin header strings.
  • priv/gettext/default.pot + locale .po files — extract & merge.
  • Russian (3-form plurals) and Estonian (2-form plurals) translations filled in priv/gettext/{ru,et}/LC_MESSAGES/default.po. Other locales fall back to the English msgid.

@timujinne
Copy link
Copy Markdown
Contributor Author

Post-merge review of the MediaBrowser i18n cherry-pick (c717c9d0)

For the record, here is a follow-up review of the MediaBrowser i18n changes in this PR. The sidebar-tabs piece (the original PR scope) reviewed clean. Findings below apply only to the cherry-picked commit and can be addressed in a follow-up PR if/when needed.

Major

  1. Three strings in list-view duplicate of the folder dropdown were not wrapped, while their grid-view twins were. Users will see mixed languages when switching to list view.

    • lib/phoenix_kit_web/components/media_browser.html.heex:1047Color heading
    • lib/phoenix_kit_web/components/media_browser.html.heex:1078data-confirm={"Delete '#{folder.name}'? Files move to parent."} (raw interpolation)
    • lib/phoenix_kit_web/components/media_browser.html.heex:1081Delete button text

    Grid-view counterparts at :735, :766, :769 are correctly wrapped.

  2. Three messages embed two independent counts in a single gettext call, making correct pluralization impossible in Russian (3 forms) and Estonian (2 forms). The translator was forced to write awkward файл(ов) / папк(у/и) constructions.

    • lib/phoenix_kit_web/components/media_browser.ex:1743build_partial_success_message: %{new} file(s) uploaded, %{err} failed
    • lib/phoenix_kit_web/components/media_browser.ex:1770build_new_and_duplicates_message: %{new} new file(s) added. %{dup} file(s) were already uploaded
    • lib/phoenix_kit_web/components/media_browser.ex:1879delete_selected_confirm, files+folders branch: Delete %{files} file(s) and %{folders} folder(s)?

    Fix pattern — compose two ngettext results and inject via gettext:

    files_str = ngettext("%{count} file", "%{count} files", new_count)
    errors_str = ngettext("%{count} failed", "%{count} failed", error_count)
    gettext("Partially successful: %{files} uploaded, %{errors} due to missing storage buckets.",
      files: files_str, errors: errors_str)

Minor

  • %{count} selected (ru): current msgstr[0] = "%{count} выбран" implies masculine gender, which is wrong for folders (feminine). Prefer a neutral predicative: «Выбрано: %{count}» across all three forms.
  • String.upcase(f.file_type || "FILE") at media_browser.html.heex:1339, 1367 — fallback "FILE" is shown to the user but not localized. Arguable since it acts as a technical label.

Cherry-pick history note

Duplicate commit titles in history (d44bf95c on dev, c717c9d0 in this branch — same content). Resolved naturally by the merge.

ddon added a commit that referenced this pull request May 11, 2026
Fix MediaBrowser i18n review findings (follow-up to #529)
timujinne added a commit to timujinne/phoenix_kit that referenced this pull request May 11, 2026
timujinne added a commit to timujinne/phoenix_kit that referenced this pull request May 11, 2026
Brings main up to date with dev (102 commits) including:
- PR BeamLabEU#529 sidebar i18n (merged via upstream)
- PR BeamLabEU#532 MediaBrowser i18n followup (merged via upstream)
- fix/orphan-query-publishing-versions
timujinne added a commit to timujinne/phoenix_kit that referenced this pull request May 11, 2026
…sions

These 4 admin_tabs.ex labels are translated via dynamic Gettext.dgettext/3
(not extracted by mix gettext.extract), so they must be added manually.

They were originally in PR BeamLabEU#529 but got dropped during merge-conflict
resolution when --theirs picked the upstream side (which didn't yet have
these bare entries). Restoring with the translations from the original
PR commit (43e528a).
@timujinne timujinne deleted the feature/core-sidebar-i18n branch May 18, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants