From 4de8492c4f2774c236121623e0758c10752cba25 Mon Sep 17 00:00:00 2001 From: Chili Palmer Date: Sun, 3 May 2026 22:28:25 +0200 Subject: [PATCH] feat: complete change to gettext from homebrew i18n solution --- lib/bds/desktop/menu_bar.ex | 109 +- lib/bds/desktop/shell_data.ex | 119 +- lib/bds/desktop/shell_live.ex | 22 +- lib/bds/desktop/shell_live/chat_editor.ex | 25 +- .../shell_live/chat_editor/message_build.ex | 7 +- .../shell_live/chat_editor/model_selection.ex | 7 +- .../shell_live/chat_editor/tool_surfaces.ex | 11 +- .../chat_editor_html/chat_editor.html.heex | 28 +- lib/bds/desktop/shell_live/chat_surface.ex | 24 +- lib/bds/desktop/shell_live/import_editor.ex | 248 +- .../import_editor/analysis_state.ex | 36 +- .../import_editor/progress_tracking.ex | 37 +- .../import_editor/taxonomy_editing.ex | 25 +- lib/bds/desktop/shell_live/index.html.heex | 110 +- lib/bds/desktop/shell_live/media_editor.ex | 58 +- .../media_editor_html/media_editor.html.heex | 74 +- lib/bds/desktop/shell_live/menu_editor.ex | 44 +- .../menu_editor/draft_management.ex | 9 +- .../desktop/shell_live/menu_editor/state.ex | 13 +- .../menu_editor_html/menu_editor.html.heex | 20 +- lib/bds/desktop/shell_live/misc_editor.ex | 101 +- .../misc_editor_html/misc_editor.html.heex | 62 +- .../desktop/shell_live/overlay_components.ex | 43 +- .../overlay_html/shell_overlay.html.heex | 52 +- lib/bds/desktop/shell_live/overlay_manager.ex | 14 +- lib/bds/desktop/shell_live/panel_renderer.ex | 30 +- lib/bds/desktop/shell_live/post_editor.ex | 51 +- .../shell_live/post_editor/persistence.ex | 13 +- .../shell_live/post_editor/post_metadata.ex | 7 +- .../post_editor_html/post_editor.html.heex | 88 +- lib/bds/desktop/shell_live/script_editor.ex | 29 +- .../script_editor.html.heex | 24 +- lib/bds/desktop/shell_live/settings_editor.ex | 5 +- .../shell_live/settings_editor/ai_settings.ex | 11 +- .../settings_editor/editor_settings.ex | 7 +- .../settings_editor/managed_categories.ex | 21 +- .../shell_live/settings_editor/mcp_config.ex | 19 +- .../settings_editor/project_settings.ex | 7 +- .../settings_editor/publishing_settings.ex | 9 +- .../settings_editor/style_editor.ex | 7 +- .../settings_editor.html.heex | 200 +- .../style_editor.html.heex | 18 +- .../desktop/shell_live/sidebar_components.ex | 69 +- lib/bds/desktop/shell_live/sidebar_create.ex | 27 +- lib/bds/desktop/shell_live/sidebar_delete.ex | 22 +- lib/bds/desktop/shell_live/tab_helpers.ex | 25 +- lib/bds/desktop/shell_live/tags_editor.ex | 16 +- .../tags_editor_html/tags_editor.html.heex | 28 +- .../desktop/shell_live/task_localization.ex | 17 +- lib/bds/desktop/shell_live/template_editor.ex | 23 +- .../template_editor.html.heex | 20 +- lib/bds/desktop/ui_locale.ex | 1 + lib/bds/gettext.ex | 42 + lib/bds/i18n.ex | 43 - lib/bds/rendering/filters.ex | 21 +- lib/bds/rendering/i18n.ex | 8 - lib/bds/rendering/labels.ex | 88 + lib/bds/rendering/list_archive.ex | 14 +- lib/bds/rendering/post_rendering.ex | 4 +- lib/bds/ui/registry.ex | 218 +- lib/bds/ui/sidebar.ex | 241 +- lib/bds/ui/workbench.ex | 13 +- mix.exs | 1 + mix.lock | 2 +- .../default/templates/not-found.liquid | 6 +- .../partials/language-switcher.liquid | 16 +- .../templates/partials/menu-items.liquid | 18 +- .../default/templates/partials/menu.liquid | 6 +- .../default/templates/post-list.liquid | 20 +- .../default/templates/single-post.liquid | 10 +- priv/gettext/de/LC_MESSAGES/default.po | 12 + priv/gettext/de/LC_MESSAGES/render.po | 156 + priv/gettext/de/LC_MESSAGES/ui.po | 3172 ++++++++++++++++ priv/gettext/default.pot | 12 + priv/gettext/en/LC_MESSAGES/default.po | 12 + priv/gettext/en/LC_MESSAGES/render.po | 156 + priv/gettext/en/LC_MESSAGES/ui.po | 3172 ++++++++++++++++ priv/gettext/es/LC_MESSAGES/default.po | 12 + priv/gettext/es/LC_MESSAGES/render.po | 156 + priv/gettext/es/LC_MESSAGES/ui.po | 3172 ++++++++++++++++ priv/gettext/fr/LC_MESSAGES/default.po | 12 + priv/gettext/fr/LC_MESSAGES/render.po | 156 + priv/gettext/fr/LC_MESSAGES/ui.po | 3172 ++++++++++++++++ priv/gettext/it/LC_MESSAGES/default.po | 12 + priv/gettext/it/LC_MESSAGES/render.po | 156 + priv/gettext/it/LC_MESSAGES/ui.po | 3172 ++++++++++++++++ priv/gettext/render.pot | 169 + priv/gettext/ui.pot | 3184 +++++++++++++++++ .../templates/not-found.liquid | 8 +- .../partials/language-switcher.liquid | 16 +- .../templates/partials/menu-items.liquid | 18 +- .../templates/partials/menu.liquid | 6 +- .../templates/post-list.liquid | 22 +- .../templates/single-post.liquid | 12 +- test/bds/i18n_test.exs | 60 +- test/bds/ui/shell_test.exs | 6 +- 96 files changed, 21579 insertions(+), 1497 deletions(-) create mode 100644 lib/bds/gettext.ex delete mode 100644 lib/bds/rendering/i18n.ex create mode 100644 lib/bds/rendering/labels.ex create mode 100644 priv/gettext/de/LC_MESSAGES/default.po create mode 100644 priv/gettext/de/LC_MESSAGES/render.po create mode 100644 priv/gettext/de/LC_MESSAGES/ui.po create mode 100644 priv/gettext/default.pot create mode 100644 priv/gettext/en/LC_MESSAGES/default.po create mode 100644 priv/gettext/en/LC_MESSAGES/render.po create mode 100644 priv/gettext/en/LC_MESSAGES/ui.po create mode 100644 priv/gettext/es/LC_MESSAGES/default.po create mode 100644 priv/gettext/es/LC_MESSAGES/render.po create mode 100644 priv/gettext/es/LC_MESSAGES/ui.po create mode 100644 priv/gettext/fr/LC_MESSAGES/default.po create mode 100644 priv/gettext/fr/LC_MESSAGES/render.po create mode 100644 priv/gettext/fr/LC_MESSAGES/ui.po create mode 100644 priv/gettext/it/LC_MESSAGES/default.po create mode 100644 priv/gettext/it/LC_MESSAGES/render.po create mode 100644 priv/gettext/it/LC_MESSAGES/ui.po create mode 100644 priv/gettext/render.pot create mode 100644 priv/gettext/ui.pot diff --git a/lib/bds/desktop/menu_bar.ex b/lib/bds/desktop/menu_bar.ex index dea3e61..98ffe71 100644 --- a/lib/bds/desktop/menu_bar.ex +++ b/lib/bds/desktop/menu_bar.ex @@ -7,6 +7,7 @@ defmodule BDS.Desktop.MenuBar do alias BDS.UI.MenuBar, as: ShellMenuBar alias Desktop.OS alias Desktop.Window + use Gettext, backend: BDS.Gettext def groups(opts \\ []) do opts @@ -140,60 +141,58 @@ defmodule BDS.Desktop.MenuBar do defp native_label(label, nil), do: label defp native_label(label, shortcut), do: label <> "\t" <> shortcut - defp group_label(:file), do: translate("menuBar.file") - defp group_label(:edit), do: translate("menuBar.edit") - defp group_label(:view), do: translate("menuBar.view") - defp group_label(:blog), do: translate("menuBar.blog") - defp group_label(:help), do: translate("menuBar.help") + defp group_label(:file), do: dgettext("ui", "File") + defp group_label(:edit), do: dgettext("ui", "Edit") + defp group_label(:view), do: dgettext("ui", "View") + defp group_label(:blog), do: dgettext("ui", "Blog") + defp group_label(:help), do: dgettext("ui", "Help") - defp item_label(:new_post), do: translate("menuBar.newPost") - defp item_label(:import_media), do: translate("menuBar.importMedia") - defp item_label(:save), do: translate("menuBar.save") - defp item_label(:open_in_browser), do: translate("menuBar.openInBrowser") - defp item_label(:open_data_folder), do: translate("menuBar.openDataFolder") - defp item_label(:close_tab), do: translate("menuBar.closeTab") - defp item_label(:quit), do: translate("menuBar.quit") - defp item_label(:undo), do: translate("menuBar.undo") - defp item_label(:redo), do: translate("menuBar.redo") - defp item_label(:cut), do: translate("menuBar.cut") - defp item_label(:copy), do: translate("menuBar.copy") - defp item_label(:paste), do: translate("menuBar.paste") - defp item_label(:delete), do: translate("menuBar.delete") - defp item_label(:select_all), do: translate("menuBar.selectAll") - defp item_label(:find), do: translate("menuBar.find") - defp item_label(:replace), do: translate("menuBar.replace") - defp item_label(:edit_preferences), do: translate("menuBar.preferences") - defp item_label(:view_posts), do: translate("menuBar.viewPosts") - defp item_label(:view_media), do: translate("menuBar.viewMedia") - defp item_label(:toggle_sidebar), do: translate("menuBar.toggleSidebar") - defp item_label(:toggle_panel), do: translate("menuBar.togglePanel") - defp item_label(:toggle_assistant_sidebar), do: translate("menuBar.toggleAssistantSidebar") - defp item_label(:toggle_dev_tools), do: translate("menuBar.toggleDevTools") - defp item_label(:reload), do: translate("menuBar.reload") - defp item_label(:force_reload), do: translate("menuBar.forceReload") - defp item_label(:reset_zoom), do: translate("menuBar.resetZoom") - defp item_label(:zoom_in), do: translate("menuBar.zoomIn") - defp item_label(:zoom_out), do: translate("menuBar.zoomOut") - defp item_label(:toggle_full_screen), do: translate("menuBar.toggleFullScreen") - defp item_label(:publish_selected), do: translate("menuBar.publishSelected") - defp item_label(:preview_post), do: translate("menuBar.previewPost") - defp item_label(:edit_menu), do: translate("menuBar.editMenu") - defp item_label(:rebuild_database), do: translate("menuBar.rebuildDatabase") - defp item_label(:reindex_text), do: translate("menuBar.reindexText") - defp item_label(:rebuild_embedding_index), do: translate("menuBar.rebuildEmbeddingIndex") - defp item_label(:metadata_diff), do: translate("menuBar.metadataDiff") - defp item_label(:regenerate_calendar), do: translate("menuBar.regenerateCalendar") - defp item_label(:validate_translations), do: translate("menuBar.validateTranslations") - defp item_label(:fill_missing_translations), do: translate("menuBar.fillMissingTranslations") - defp item_label(:find_duplicates), do: translate("menuBar.findDuplicates") - defp item_label(:generate_sitemap), do: translate("menuBar.generateSite") - defp item_label(:validate_site), do: translate("menuBar.validateSite") - defp item_label(:upload_site), do: translate("menuBar.uploadSite") - defp item_label(:about), do: translate("menuBar.about") - defp item_label(:documentation), do: translate("menuBar.documentation") - defp item_label(:api_documentation), do: translate("menuBar.apiDocumentation") - defp item_label(:view_on_github), do: translate("menuBar.viewOnGithub") - defp item_label(:report_issue), do: translate("menuBar.reportIssue") - - defp translate(text), do: ShellData.translate(text, %{}, UILocale.current()) + defp item_label(:new_post), do: dgettext("ui", "New Post") + defp item_label(:import_media), do: dgettext("ui", "Import Media") + defp item_label(:save), do: dgettext("ui", "Save") + defp item_label(:open_in_browser), do: dgettext("ui", "Open in Browser") + defp item_label(:open_data_folder), do: dgettext("ui", "Open Data Folder") + defp item_label(:close_tab), do: dgettext("ui", "Close Tab") + defp item_label(:quit), do: dgettext("ui", "Quit") + defp item_label(:undo), do: dgettext("ui", "Undo") + defp item_label(:redo), do: dgettext("ui", "Redo") + defp item_label(:cut), do: dgettext("ui", "Cut") + defp item_label(:copy), do: dgettext("ui", "Copy") + defp item_label(:paste), do: dgettext("ui", "Paste") + defp item_label(:delete), do: dgettext("ui", "Delete") + defp item_label(:select_all), do: dgettext("ui", "Select All") + defp item_label(:find), do: dgettext("ui", "Find") + defp item_label(:replace), do: dgettext("ui", "Replace") + defp item_label(:edit_preferences), do: dgettext("ui", "Preferences") + defp item_label(:view_posts), do: dgettext("ui", "Posts") + defp item_label(:view_media), do: dgettext("ui", "Media") + defp item_label(:toggle_sidebar), do: dgettext("ui", "Toggle Sidebar") + defp item_label(:toggle_panel), do: dgettext("ui", "Toggle Panel") + defp item_label(:toggle_assistant_sidebar), do: dgettext("ui", "Toggle Assistant Sidebar") + defp item_label(:toggle_dev_tools), do: dgettext("ui", "Toggle Dev Tools") + defp item_label(:reload), do: dgettext("ui", "Reload") + defp item_label(:force_reload), do: dgettext("ui", "Force Reload") + defp item_label(:reset_zoom), do: dgettext("ui", "Reset Zoom") + defp item_label(:zoom_in), do: dgettext("ui", "Zoom In") + defp item_label(:zoom_out), do: dgettext("ui", "Zoom Out") + defp item_label(:toggle_full_screen), do: dgettext("ui", "Toggle Full Screen") + defp item_label(:publish_selected), do: dgettext("ui", "Publish Selected") + defp item_label(:preview_post), do: dgettext("ui", "Preview Post") + defp item_label(:edit_menu), do: dgettext("ui", "Edit Menu") + defp item_label(:rebuild_database), do: dgettext("ui", "Rebuild Database") + defp item_label(:reindex_text), do: dgettext("ui", "Reindex Text") + defp item_label(:rebuild_embedding_index), do: dgettext("ui", "Rebuild Embedding Index") + defp item_label(:metadata_diff), do: dgettext("ui", "Metadata Diff") + defp item_label(:regenerate_calendar), do: dgettext("ui", "Regenerate Calendar") + defp item_label(:validate_translations), do: dgettext("ui", "Validate Translations") + defp item_label(:fill_missing_translations), do: dgettext("ui", "Fill Missing Translations") + defp item_label(:find_duplicates), do: dgettext("ui", "Find Duplicate Posts") + defp item_label(:generate_sitemap), do: dgettext("ui", "Generate Site") + defp item_label(:validate_site), do: dgettext("ui", "Validate Site") + defp item_label(:upload_site), do: dgettext("ui", "Upload Site") + defp item_label(:about), do: dgettext("ui", "About") + defp item_label(:documentation), do: dgettext("ui", "Documentation") + defp item_label(:api_documentation), do: dgettext("ui", "API Documentation") + defp item_label(:view_on_github), do: dgettext("ui", "View on GitHub") + defp item_label(:report_issue), do: dgettext("ui", "Report Issue") end diff --git a/lib/bds/desktop/shell_data.ex b/lib/bds/desktop/shell_data.ex index 7353307..6acf9b0 100644 --- a/lib/bds/desktop/shell_data.ex +++ b/lib/bds/desktop/shell_data.ex @@ -1,6 +1,8 @@ defmodule BDS.Desktop.ShellData do @moduledoc false + use Gettext, backend: BDS.Gettext + alias BDS.Git alias BDS.I18n alias BDS.Projects @@ -12,12 +14,24 @@ defmodule BDS.Desktop.ShellData do Application.get_env(:bds, :desktop)[:title] || "Blogging Desktop Server" end - def ui_language do - I18n.current_ui_locale() + def activity_icon(id) do + case to_string(id) do + "posts" -> ~s() + "pages" -> ~s() + "media" -> ~s() + "scripts" -> ~s() + "templates" -> ~s() + "tags" -> ~s() + "chat" -> ~s() + "import" -> ~s() + "git" -> ~s() + "settings" -> ~s() + _other -> activity_icon("posts") + end end - def translations(locale \\ nil) do - I18n.get_ui_translations(effective_ui_language(locale)) + def ui_language do + I18n.current_ui_locale() end def supported_ui_languages do @@ -26,14 +40,6 @@ defmodule BDS.Desktop.ShellData do end) end - def translate(key, bindings \\ %{}, locale \\ nil) do - text = Map.get(translations(locale), to_string(key), to_string(key)) - - Enum.reduce(bindings, text, fn {binding, value}, acc -> - String.replace(acc, "%{#{binding}}", to_string(value)) - end) - end - def project_snapshot do Projects.shell_snapshot() rescue @@ -77,20 +83,20 @@ defmodule BDS.Desktop.ShellData do def assistant_cards do [ - %{label: "Offline Gate", text: "Automatic AI actions stay gated by airplane mode."}, + %{label: dgettext("ui", "Offline Gate"), text: dgettext("ui", "Automatic AI actions stay gated by airplane mode.")}, %{ - label: "Filesystem Sync", - text: "Metadata flush, diffing, and rebuild hooks still need editor wiring." + label: dgettext("ui", "Filesystem Sync"), + text: dgettext("ui", "Metadata flush, diffing, and rebuild hooks still need editor wiring.") }, - %{label: "Desktop Runtime", text: "The app window is now served from LiveView state."} + %{label: dgettext("ui", "Desktop Runtime"), text: dgettext("ui", "The app window is now served from LiveView state.")} ] end def editor_meta(task_status) do [ - %{label: "Status", value: task_status.running_task_message || "Idle"}, - %{label: "Mode", value: "Offline"}, - %{label: "Main Language", value: ui_language()} + %{label: dgettext("ui", "Status"), value: task_status.running_task_message || dgettext("ui", "Idle")}, + %{label: dgettext("ui", "Mode"), value: dgettext("ui", "Offline")}, + %{label: dgettext("ui", "Main Language"), value: ui_language()} ] end @@ -140,70 +146,18 @@ defmodule BDS.Desktop.ShellData do |> Enum.uniq() end - defp git_remote_state_provider do - Application.get_env(:bds, :git_remote_state_provider, &Git.remote_state/2) - end - - defp parse_positive_count(value) do - case Integer.parse(value) do - {count, _rest} when count > 0 -> count - _other -> 0 - end - end - - def activity_icon(id) do - case to_string(id) do - "posts" -> - ~s() - - "pages" -> - ~s() - - "media" -> - ~s() - - "scripts" -> - ~s() - - "templates" -> - ~s() - - "tags" -> - ~s() - - "chat" -> - ~s() - - "import" -> - ~s() - - "git" -> - ~s() - - "settings" -> - ~s() - - _other -> - activity_icon("posts") - end - end - def dashboard_status_label(status) do case to_string(status) do - "draft" -> translate("dashboard.status.draft") - "published" -> translate("dashboard.status.published") - "archived" -> translate("dashboard.status.archived") + "draft" -> dgettext("ui", "Draft") + "published" -> dgettext("ui", "Published") + "archived" -> dgettext("ui", "Archived") other -> other |> String.replace("_", " ") |> String.capitalize() end end def dashboard_post_count_label(count) do normalized_count = count || 0 - - key = - if normalized_count == 1, do: "dashboard.postCount.one", else: "dashboard.postCount.other" - - translate(key, %{count: normalized_count}) + dngettext("ui", "%{count} post", "%{count} posts", normalized_count, count: normalized_count) end def dashboard_tag_cloud_items(items) when is_list(items) do @@ -258,10 +212,10 @@ defmodule BDS.Desktop.ShellData do def route_label(route) do case to_string(route) do "git_log" -> - "Git Log" + dgettext("ui", "Git Log") "post_links" -> - "Post Links" + dgettext("ui", "Post Links") other -> other @@ -288,11 +242,16 @@ defmodule BDS.Desktop.ShellData do end end - defp effective_ui_language(nil) do - BDS.Desktop.UILocale.current() || ui_language() + defp git_remote_state_provider do + Application.get_env(:bds, :git_remote_state_provider, &Git.remote_state/2) end - defp effective_ui_language(locale), do: locale + defp parse_positive_count(value) do + case Integer.parse(value) do + {count, _rest} when count > 0 -> count + _other -> 0 + end + end defp maybe_add_panel_tab(tabs, :post, :post_links), do: tabs ++ [:post_links] diff --git a/lib/bds/desktop/shell_live.ex b/lib/bds/desktop/shell_live.ex index c043444..b7da0d4 100644 --- a/lib/bds/desktop/shell_live.ex +++ b/lib/bds/desktop/shell_live.ex @@ -57,6 +57,7 @@ defmodule BDS.Desktop.ShellLive do alias BDS.UI.{Commands, MenuBar, Session, Workbench} alias Desktop.OS alias BDS.Desktop.Shutdown + use Gettext, backend: BDS.Gettext @refresh_interval 1_500 @output_entry_limit 20 @@ -586,29 +587,26 @@ defmodule BDS.Desktop.ShellLive do |> assign(:current_tab, current_tab(workbench)) end - defp translated(text, bindings \\ %{}), - do: ShellData.translate(text, bindings, UILocale.current()) - defp encoded_shortcuts(shortcuts), do: Jason.encode!(shortcuts) defp encoded_workbench_session(workbench), do: Jason.encode!(Session.serialize(workbench)) - defp panel_tab_label(:tasks), do: translated("Tasks") - defp panel_tab_label(:output), do: translated("Output") - defp panel_tab_label(:git_log), do: translated("Git Log") + defp panel_tab_label(:tasks), do: dgettext("ui", "Tasks") + defp panel_tab_label(:output), do: dgettext("ui", "Output") + defp panel_tab_label(:git_log), do: dgettext("ui", "Git Log") defp panel_tab_label(tab), do: ShellData.route_label(tab) - defp activity_label("AI Assistant"), do: "Chat" - defp activity_label("Source Control"), do: "Git" - defp activity_label(label), do: translated(label) + defp activity_label("AI Assistant"), do: dgettext("ui", "Chat") + defp activity_label("Source Control"), do: dgettext("ui", "Git") + defp activity_label(label), do: label defp active_sidebar_label(activity_buttons, active_view, sidebar_data) do - Enum.find_value(activity_buttons, translated(Map.get(sidebar_data, :title, "")), fn button -> + Enum.find_value(activity_buttons, Map.get(sidebar_data, :title, ""), fn button -> if button.id == active_view, do: activity_label(button.label), else: nil end) end - defp sidebar_header_label(label), do: translated(label) + defp sidebar_header_label(label), do: label defp timeline_height(entry, entries) do max_count = @@ -680,6 +678,8 @@ defmodule BDS.Desktop.ShellLive do if normalized == socket.assigns.page_language do socket else + UILocale.put(normalized) + socket |> assign(:page_language, normalized) |> reload_shell(socket.assigns.workbench) diff --git a/lib/bds/desktop/shell_live/chat_editor.ex b/lib/bds/desktop/shell_live/chat_editor.ex index 270e95d..3862159 100644 --- a/lib/bds/desktop/shell_live/chat_editor.ex +++ b/lib/bds/desktop/shell_live/chat_editor.ex @@ -6,9 +6,9 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do import Phoenix.HTML, only: [raw: 1] alias BDS.{AI, BoundedAtoms, MapUtils, Persistence} - alias BDS.Desktop.ShellData alias BDS.Desktop.ShellLive.ChatEditor.{MessageBuild, ModelSelection, ToolTracking} alias BDS.Desktop.ShellLive.TabHelpers + use Gettext, backend: BDS.Gettext embed_templates("chat_editor_html/*") @@ -72,7 +72,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do {:noreply, assign(socket, :model_selector_open?, false) |> build_data()} {:error, reason} -> - notify_parent({:chat_editor_output, translated("Chat"), inspect(reason), "error"}) + notify_parent({:chat_editor_output, dgettext("ui", "Chat"), inspect(reason), "error"}) {:noreply, assign(socket, :model_selector_open?, false) |> build_data()} end end @@ -196,8 +196,8 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do socket.assigns.offline_mode -> notify_parent( - {:chat_editor_output, translated("Chat"), - translated("Automatic AI actions stay gated by airplane mode."), "info"} + {:chat_editor_output, dgettext("ui", "Chat"), + dgettext("ui", "Automatic AI actions stay gated by airplane mode."), "info"} ) build_data(socket) @@ -272,7 +272,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do assign(socket, :request, nil) |> build_data() {:error, reason} -> - notify_parent({:chat_editor_output, translated("Chat"), format_error(reason), "error"}) + notify_parent({:chat_editor_output, dgettext("ui", "Chat"), format_error(reason), "error"}) assign(socket, :request, nil) |> build_data() end end @@ -483,8 +483,8 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do # ── HEEx-callable helpers ───────────────────────────────────────────────── @spec message_role_label(atom()) :: String.t() - def message_role_label(:user), do: translated("chat.role.you") - def message_role_label(_role), do: translated("chat.role.assistant") + def message_role_label(:user), do: dgettext("ui", "You") + def message_role_label(_role), do: dgettext("ui", "Assistant") defdelegate tool_call_name(tool_call), to: ToolTracking defdelegate tool_call_arguments(tool_call), to: ToolTracking @@ -547,10 +547,10 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do <% end %>
-
<%= translated("chat.toolArguments") %>
+
<%= dgettext("ui", "Arguments") %>
<%= Jason.encode!(marker.arguments || %{}, pretty: true) %>
<%= if marker.result not in [nil, ""] do %> -
<%= translated("chat.toolResult") %>
+
<%= dgettext("ui", "Result") %>
<%= marker.result %>
<% end %>
@@ -571,7 +571,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do <%= surface_icon(@surface.type) %> <%= surface_title(@surface) %> - +
<%= case @surface.type do %> @@ -848,7 +848,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do defp present?(value), do: not is_nil(value) defp format_error(%{kind: :endpoint_not_configured}), - do: translated("chat.apiKeyRequiredDescription") + do: dgettext("ui", "Configure an API key in Settings to enable AI chat.") defp format_error(reason), do: inspect(reason) @@ -860,7 +860,4 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do :error -> 0 end end - - defp translated(text, bindings \\ %{}), - do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current()) end diff --git a/lib/bds/desktop/shell_live/chat_editor/message_build.ex b/lib/bds/desktop/shell_live/chat_editor/message_build.ex index 9479722..c1908ed 100644 --- a/lib/bds/desktop/shell_live/chat_editor/message_build.ex +++ b/lib/bds/desktop/shell_live/chat_editor/message_build.ex @@ -3,8 +3,8 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.MessageBuild do alias BDS.AI alias BDS.AI.ChatConversation - alias BDS.Desktop.ShellData alias BDS.Desktop.ShellLive.ChatEditor.{ModelSelection, ToolSurfaces, ToolTracking} + use Gettext, backend: BDS.Gettext @spec build(term()) :: term() def build(%{current_tab: %{type: :chat, id: conversation_id}} = assigns) do @@ -22,7 +22,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.MessageBuild do %{ id: conversation.id, - title: conversation.title || translated("chat.newChat"), + title: conversation.title || dgettext("ui", "New Chat"), model: conversation.model, effective_model: effective_model, available_models: available_models, @@ -268,7 +268,4 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.MessageBuild do defp request_started_at(%{started_at: started_at}) when is_integer(started_at), do: started_at defp request_started_at(_request), do: nil - - defp translated(text, bindings \\ %{}), - do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current()) end diff --git a/lib/bds/desktop/shell_live/chat_editor/model_selection.ex b/lib/bds/desktop/shell_live/chat_editor/model_selection.ex index ebfca46..44a7084 100644 --- a/lib/bds/desktop/shell_live/chat_editor/model_selection.ex +++ b/lib/bds/desktop/shell_live/chat_editor/model_selection.ex @@ -2,9 +2,9 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.ModelSelection do @moduledoc false alias BDS.AI - alias BDS.Desktop.ShellData import Phoenix.Component, only: [assign: 3] + use Gettext, backend: BDS.Gettext @spec toggle_model_selector(term(), term()) :: term() def toggle_model_selector(socket, reload) do @@ -34,7 +34,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.ModelSelection do {:error, reason} -> socket - |> append_output.(translated("Chat"), inspect(reason), nil, "error") + |> append_output.(dgettext("ui", "Chat"), inspect(reason), nil, "error") |> reload.(socket.assigns.workbench) end end @@ -78,7 +78,4 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.ModelSelection do defp blank?(value) when is_binary(value), do: String.trim(value) == "" defp blank?(nil), do: true - - defp translated(text, bindings \\ %{}), - do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current()) end diff --git a/lib/bds/desktop/shell_live/chat_editor/tool_surfaces.ex b/lib/bds/desktop/shell_live/chat_editor/tool_surfaces.ex index 7965199..bfebca2 100644 --- a/lib/bds/desktop/shell_live/chat_editor/tool_surfaces.ex +++ b/lib/bds/desktop/shell_live/chat_editor/tool_surfaces.ex @@ -1,7 +1,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.ToolSurfaces do @moduledoc false - alias BDS.Desktop.ShellData + use Gettext, backend: BDS.Gettext @render_tool_names MapSet.new([ "render_card", @@ -85,7 +85,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.ToolSurfaces do |> List.wrap() |> Enum.map(fn entry -> %{ - label: map_value(entry, "label", translated("chat.role.assistant")), + label: map_value(entry, "label", dgettext("ui", "Assistant")), value: numeric_value(map_value(entry, "value", 0)), segments: List.wrap(map_value(entry, "segments", [])) } @@ -173,7 +173,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.ToolSurfaces do fields: fields, submit_label: map_value(arguments, "submitLabel") || - map_value(arguments, "submit_label", translated("chat.stop")), + map_value(arguments, "submit_label", dgettext("ui", "Stop")), submit_action: map_value(arguments, "submitAction") || map_value(arguments, "submit_action", "submitForm") @@ -249,7 +249,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.ToolSurfaces do defp decode_surface_actions(actions) when is_list(actions) do Enum.map(actions, fn action -> %{ - label: map_value(action, "label", translated("chat.openSettings")), + label: map_value(action, "label", dgettext("ui", "Open Settings")), action: map_value(action, "action", "openSettings"), payload: map_value(action, "payload", %{}) } @@ -296,7 +296,4 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.ToolSurfaces do defp truthy?(value) when value in [true, "true", 1, "1", "on"], do: true defp truthy?(_value), do: false - - defp translated(text, bindings \\ %{}), - do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current()) end diff --git a/lib/bds/desktop/shell_live/chat_editor_html/chat_editor.html.heex b/lib/bds/desktop/shell_live/chat_editor_html/chat_editor.html.heex index 2abe445..98e6a06 100644 --- a/lib/bds/desktop/shell_live/chat_editor_html/chat_editor.html.heex +++ b/lib/bds/desktop/shell_live/chat_editor_html/chat_editor.html.heex @@ -3,7 +3,7 @@
<%= if @chat_editor.needs_api_key? do %> - <%= translated("chat.setupTitle") %> + <%= dgettext("ui", "AI Chat Setup") %> <% else %> <%= @chat_editor.title %> <% end %> @@ -18,7 +18,7 @@ phx-target={@myself} data-testid="chat-model-selector-button" > - <%= @chat_editor.effective_model || translated("chat.modelUnavailable") %> + <%= @chat_editor.effective_model || dgettext("ui", "No model") %> @@ -59,24 +59,24 @@ <%= if @chat_editor.needs_api_key? do %>
🔑
-

<%= translated("chat.apiKeyRequiredTitle") %>

-

<%= translated("chat.apiKeyRequiredDescription") %>

+

<%= dgettext("ui", "API Key Required") %>

+

<%= dgettext("ui", "Configure an API key in Settings to enable AI chat.") %>

- +
<% else %> <%= if Enum.empty?(@chat_editor.messages) and not @chat_editor.is_streaming do %>
🤖
-

<%= translated("chat.welcomeTitle") %>

-

<%= translated("chat.welcomeDescription") %>

+

<%= dgettext("ui", "Welcome to the AI Assistant") %>

+

<%= dgettext("ui", "I can help you manage your blog with rich visualizations. Try asking me to:") %>

    -
  • <%= translated("chat.welcomeTipSearch") %>
  • -
  • <%= translated("chat.welcomeTipChart") %>
  • -
  • <%= translated("chat.welcomeTipTable") %>
  • -
  • <%= translated("chat.welcomeTipMetadata") %>
  • -
  • <%= translated("chat.welcomeTipTabs") %>
  • +
  • <%= dgettext("ui", "Search for posts about a specific topic") %>
  • +
  • <%= dgettext("ui", "Show a chart of posts published per month") %>
  • +
  • <%= dgettext("ui", "Compare my recent posts in a table") %>
  • +
  • <%= dgettext("ui", "Update metadata for posts or media") %>
  • +
  • <%= dgettext("ui", "Show post statistics by year in tabs with charts") %>
<% else %> @@ -149,11 +149,11 @@ <%= unless @chat_editor.needs_api_key? do %>
<%= if @chat_editor.is_streaming do %> - + <% end %>
- +
diff --git a/lib/bds/desktop/shell_live/chat_surface.ex b/lib/bds/desktop/shell_live/chat_surface.ex index c444b04..a8977fc 100644 --- a/lib/bds/desktop/shell_live/chat_surface.ex +++ b/lib/bds/desktop/shell_live/chat_surface.ex @@ -3,7 +3,7 @@ defmodule BDS.Desktop.ShellLive.ChatSurface do import Phoenix.Component, only: [assign: 3] - alias BDS.Desktop.ShellData + use Gettext, backend: BDS.Gettext def assistant_turn(prompt, socket) do [ @@ -12,12 +12,12 @@ defmodule BDS.Desktop.ShellLive.ChatSurface do ] end - def assistant_project_name(nil), do: translated("Projects") + def assistant_project_name(nil), do: dgettext("ui", "Projects") def assistant_project_name(project), do: project.name - def assistant_message_label("assistant"), do: translated("Assistant") - def assistant_message_label("user"), do: translated("You") - def assistant_message_label(_role), do: translated("Assistant") + def assistant_message_label("assistant"), do: dgettext("ui", "Assistant") + def assistant_message_label("user"), do: dgettext("ui", "You") + def assistant_message_label(_role), do: dgettext("ui", "Assistant") def assistant_message_testid(role), do: "assistant-message-#{role}" @@ -30,19 +30,9 @@ defmodule BDS.Desktop.ShellLive.ChatSurface do defp assistant_reply(socket) do if socket.assigns.offline_mode do - ShellData.translate( - "Automatic AI actions stay gated by airplane mode.", - %{}, - socket.assigns.page_language - ) + BDS.Gettext.lgettext(socket.assigns.page_language, "ui", "Automatic AI actions stay gated by airplane mode.") else - ShellData.translate( - "The assistant sidebar chat surface is ready, but model execution is not connected yet.", - %{}, - socket.assigns.page_language - ) + BDS.Gettext.lgettext(socket.assigns.page_language, "ui", "The assistant sidebar chat surface is ready, but model execution is not connected yet.") end end - - defp translated(text), do: ShellData.translate(text, %{}, BDS.Desktop.UILocale.current()) end diff --git a/lib/bds/desktop/shell_live/import_editor.ex b/lib/bds/desktop/shell_live/import_editor.ex index 849c8b2..5d48fde 100644 --- a/lib/bds/desktop/shell_live/import_editor.ex +++ b/lib/bds/desktop/shell_live/import_editor.ex @@ -30,6 +30,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do translate_execution_phase: 1 ] + use Gettext, backend: BDS.Gettext import TaxonomyEditing, only: [ existing_taxonomy_terms: 1, @@ -162,7 +163,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do definition_id = socket.assigns.definition_id socket = - case FolderPicker.choose_directory(translated("importAnalysis.uploadsFolder")) do + case FolderPicker.choose_directory(dgettext("ui", "Uploads Folder")) do {:ok, uploads_folder_path} -> {:ok, _definition} = ImportDefinitions.update_definition(definition_id, %{ @@ -175,7 +176,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do build_data(socket) {:error, %{message: message}} -> - notify_output(translated("activity.import"), message, "error") + notify_output(dgettext("ui", "Import"), message, "error") build_data(socket) end @@ -187,7 +188,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do project_id = socket.assigns.project_id socket = - case FilePicker.choose_file(translated("importAnalysis.wxrFile")) do + case FilePicker.choose_file(dgettext("ui", "WXR File")) do {:ok, wxr_file_path} -> {:ok, definition} = ImportDefinitions.update_definition(definition_id, %{ @@ -214,7 +215,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do socket |> assign(:analysis_state, %{ loading: true, - step: translated("importAnalysis.analyzingWxr"), + step: dgettext("ui", "Analyzing WXR file..."), detail: Path.basename(wxr_file_path), file_path: wxr_file_path, ref: task.ref @@ -226,7 +227,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do build_data(socket) {:error, %{message: message}} -> - notify_output(translated("activity.import"), message, "error") + notify_output(dgettext("ui", "Import"), message, "error") build_data(socket) end @@ -430,12 +431,8 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do %{} = report <- ImportDefinitions.decode_analysis_result(definition) do if socket.assigns.offline_mode? do notify_output( - translated("activity.import"), - ShellData.translate( - "Automatic AI actions stay gated by airplane mode.", - %{}, - socket.assigns[:page_language] || ShellData.ui_language() - ), + dgettext("ui", "Import"), + BDS.Gettext.lgettext(socket.assigns[:page_language] || ShellData.ui_language(), "ui", "Automatic AI actions stay gated by airplane mode."), "info" ) @@ -467,15 +464,15 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do mapped_count = TaxonomyEditing.auto_mapped_count(report, updated_report) notify_output( - translated("activity.import"), - translated("importAnalysis.mappedCount", %{count: mapped_count}), + dgettext("ui", "Import"), + dgettext("ui", "%{count} mapped", count: mapped_count), "info" ) build_data(socket) {:error, reason} -> - notify_output(translated("activity.import"), inspect(reason), "error") + notify_output(dgettext("ui", "Import"), inspect(reason), "error") build_data(socket) end end @@ -552,7 +549,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do socket |> assign(:analysis_state, default_analysis_state()) - |> notify_output(translated("activity.import"), message, "error") + |> notify_output(dgettext("ui", "Import"), message, "error") match?(%{ref: ^ref}, socket.assigns.execution_state) and reason not in [:normal, :shutdown] -> message = if is_binary(reason), do: reason, else: inspect(reason) @@ -567,7 +564,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do ref: nil }) ) - |> notify_output(translated("activity.import"), message, "error") + |> notify_output(dgettext("ui", "Import"), message, "error") true -> socket @@ -630,11 +627,11 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do end defp maybe_update_tab_meta(socket, name) do - title = name || translated("importAnalysis.untitledImport") + title = name || dgettext("ui", "Untitled Import") notify_parent( {:import_editor_tab_meta, socket.assigns.definition_id, title, - translated("importAnalysis.headerDescription")} + dgettext("ui", "Select a WordPress export file (WXR) and an uploads folder to analyze what would be imported.")} ) socket @@ -653,7 +650,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do end end - defp selected_model_label(nil, []), do: translated("importAnalysis.analyzeWith") + defp selected_model_label(nil, []), do: dgettext("ui", "Analyze with...") defp selected_model_label(nil, [model | _rest]), do: model.name || model.id defp selected_model_label(model_id, available_models) do @@ -685,14 +682,14 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do socket {:error, reason} -> - notify_output(socket, translated("activity.import"), inspect(reason), "error") + notify_output(socket, dgettext("ui", "Import"), inspect(reason), "error") end {:error, %{message: message}} -> - notify_output(socket, translated("activity.import"), message, "error") + notify_output(socket, dgettext("ui", "Import"), message, "error") {:error, reason} -> - notify_output(socket, translated("activity.import"), inspect(reason), "error") + notify_output(socket, dgettext("ui", "Import"), inspect(reason), "error") end end @@ -713,8 +710,8 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do ref: nil }) |> notify_output( - translated("activity.import"), - translated("importAnalysis.importComplete", %{count: previous_state.count}), + dgettext("ui", "Import"), + dgettext("ui", "Import completed successfully!", count: previous_state.count), "info" ) @@ -727,7 +724,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do error: message, ref: nil }) - |> notify_output(translated("activity.import"), message, "error") + |> notify_output(dgettext("ui", "Import"), message, "error") {:error, reason} -> message = inspect(reason) @@ -740,7 +737,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do error: message, ref: nil }) - |> notify_output(translated("activity.import"), message, "error") + |> notify_output(dgettext("ui", "Import"), message, "error") end # Allow DB connections to settle before rebuilding @@ -812,27 +809,27 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do class="import-definition-name" type="text" name="import_definition[name]" - value={@import_editor.definition_name || translated("importAnalysis.untitledImport")} - placeholder={translated("importAnalysis.namePlaceholder")} + value={@import_editor.definition_name || dgettext("ui", "Untitled Import")} + placeholder={dgettext("ui", "Import name...")} /> -

<%= translated("importAnalysis.headerDescription") %>

+

<%= dgettext("ui", "Select a WordPress export file (WXR) and an uploads folder to analyze what would be imported.") %>

- +
- <%= @import_editor.uploads_folder_path || translated("importAnalysis.noFolderSelected") %> + <%= @import_editor.uploads_folder_path || dgettext("ui", "No folder selected") %>
- +
- +
- <%= @import_editor.wxr_file_path || translated("importAnalysis.selectFileToAnalyze") %> + <%= @import_editor.wxr_file_path || dgettext("ui", "Select a file to analyze") %>
- +
@@ -840,7 +837,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do
-
<%= @analysis_state.step || translated("importAnalysis.analyzingWxr") %>
+
<%= @analysis_state.step || dgettext("ui", "Analyzing WXR file...") %>
<%= if present?(@analysis_state.detail) do %>
<%= @analysis_state.detail %>
<% end %> @@ -851,37 +848,37 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do <%= if not is_nil(@report) and not @import_editor.is_loading do %>
- <%= translated("importAnalysis.site") %> - <%= get_in(@report, [:site_info, :title]) || translated("importAnalysis.untitled") %> + <%= dgettext("ui", "Site") %> + <%= get_in(@report, [:site_info, :title]) || dgettext("ui", "Untitled") %>
- <%= translated("importAnalysis.url") %> - <%= get_in(@report, [:site_info, :url]) || translated("importAnalysis.notAvailable") %> + <%= dgettext("ui", "URL") %> + <%= get_in(@report, [:site_info, :url]) || dgettext("ui", "N/A") %>
- <%= translated("importAnalysis.language") %> - <%= get_in(@report, [:site_info, :language]) || translated("importAnalysis.notAvailable") %> + <%= dgettext("ui", "Language") %> + <%= get_in(@report, [:site_info, :language]) || dgettext("ui", "N/A") %>
- <%= translated("importAnalysis.file") %> + <%= dgettext("ui", "File") %> <%= @import_editor.wxr_file_path |> to_string() |> Path.basename() %>
- <.stat_card label={translated("importAnalysis.posts")} stats={@report.post_stats} /> + <.stat_card label={dgettext("ui", "posts")} stats={@report.post_stats} /> <%= if Map.get(@report, :other_stats) && Map.get(@report.other_stats, :total, 0) > 0 do %> - <.other_stat_card label={translated("importAnalysis.other")} stats={@report.other_stats} /> + <.other_stat_card label={dgettext("ui", "Other")} stats={@report.other_stats} /> <% end %> - <.stat_card label={translated("importAnalysis.pages")} stats={@report.page_stats} /> - <.media_stat_card label={translated("importAnalysis.media")} stats={@report.media_stats} /> - <.taxonomy_stat_card label={translated("importAnalysis.categories")} stats={@report.category_stats} /> - <.taxonomy_stat_card label={translated("importAnalysis.tags")} stats={@report.tag_stats} /> + <.stat_card label={dgettext("ui", "pages")} stats={@report.page_stats} /> + <.media_stat_card label={dgettext("ui", "media")} stats={@report.media_stats} /> + <.taxonomy_stat_card label={dgettext("ui", "Categories")} stats={@report.category_stats} /> + <.taxonomy_stat_card label={dgettext("ui", "Tags")} stats={@report.tag_stats} />
<%= if Enum.any?(Map.get(@report, :date_distribution, [])) do %>
-

<%= translated("importAnalysis.dateDistribution") %>

+

<%= dgettext("ui", "Date Distribution") %>

<%= for row <- @report.date_distribution do %>
@@ -900,13 +897,13 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do <%= if @execution_state.is_executing do %>
-

<%= translated("importAnalysis.importing") %>

+

<%= dgettext("ui", "Importing...") %>

- <%= @execution_state.phase || translated("importAnalysis.executionStarting") %> + <%= @execution_state.phase || dgettext("ui", "Starting...") %> <%= if present?(@execution_state.detail) do %> <%= @execution_state.detail %> <% end %> @@ -921,18 +918,18 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do <%= if not @execution_state.is_executing and not @execution_state.completed do %>
- <%= translated("importAnalysis.readyToImport") %> - <%= if @counts.tags > 0 do %><%= @counts.tags %> <%= translated("importAnalysis.tagsCategories") %><% end %> - <%= if @counts.posts > 0 do %><%= @counts.posts %> <%= translated("importAnalysis.posts") %><% end %> - <%= if @counts.media > 0 do %><%= @counts.media %> <%= translated("importAnalysis.media") %><% end %> - <%= if @counts.pages > 0 do %><%= @counts.pages %> <%= translated("importAnalysis.pages") %><% end %> + <%= dgettext("ui", "Ready to import:") %> + <%= if @counts.tags > 0 do %><%= @counts.tags %> <%= dgettext("ui", "tags/categories") %><% end %> + <%= if @counts.posts > 0 do %><%= @counts.posts %> <%= dgettext("ui", "posts") %><% end %> + <%= if @counts.media > 0 do %><%= @counts.media %> <%= dgettext("ui", "media") %><% end %> + <%= if @counts.pages > 0 do %><%= @counts.pages %> <%= dgettext("ui", "pages") %><% end %>
@@ -940,56 +937,56 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do <%= if @execution_state.completed do %>
- <%= translated("importAnalysis.importComplete", %{count: @execution_state.count || @counts.total}) %> + <%= dgettext("ui", "Import completed successfully!", count: @execution_state.count || @counts.total) %>
<% end %> <%= if present?(@execution_state.error) do %>
- <%= translated("importAnalysis.importFailed", %{error: @execution_state.error}) %> + <%= dgettext("ui", "Import failed: %{error}", error: @execution_state.error) %>
<% end %> <%= if Enum.any?(@post_conflicts) do %> - <.conflict_section title={translated("importAnalysis.postSlugConflicts")} items={@post_conflicts} expanded={@sections.post_conflicts} section="post_conflicts" myself={@myself} /> + <.conflict_section title={dgettext("ui", "Post Slug Conflicts")} items={@post_conflicts} expanded={@sections.post_conflicts} section="post_conflicts" myself={@myself} /> <% end %> <%= if Enum.any?(@page_conflicts) do %> - <.conflict_section title={translated("importAnalysis.pageSlugConflicts")} items={@page_conflicts} expanded={@sections.page_conflicts} section="page_conflicts" myself={@myself} /> + <.conflict_section title={dgettext("ui", "Page Slug Conflicts")} items={@page_conflicts} expanded={@sections.page_conflicts} section="page_conflicts" myself={@myself} /> <% end %> <%= if Enum.any?(@post_items) do %> - <.post_detail_section title={translated("importAnalysis.postsWithCount", %{count: length(@post_items)})} items={@post_items} expanded={@sections.posts} section="posts" myself={@myself} /> + <.post_detail_section title={dgettext("ui", "Posts (%{count})", count: length(@post_items))} items={@post_items} expanded={@sections.posts} section="posts" myself={@myself} /> <% end %> <%= if Enum.any?(@other_items) do %> - <.post_detail_section title={translated("importAnalysis.otherWithCount", %{count: length(@other_items)})} items={@other_items} expanded={@sections.other} section="other" show_type={true} myself={@myself} /> + <.post_detail_section title={dgettext("ui", "Other (%{count})", count: length(@other_items))} items={@other_items} expanded={@sections.other} section="other" show_type={true} myself={@myself} /> <% end %> <%= if Enum.any?(@detail_pages) do %> - <.post_detail_section title={translated("importAnalysis.pagesWithCount", %{count: length(@detail_pages)})} items={@detail_pages} expanded={@sections.pages} section="pages" myself={@myself} /> + <.post_detail_section title={dgettext("ui", "Pages (%{count})", count: length(@detail_pages))} items={@detail_pages} expanded={@sections.pages} section="pages" myself={@myself} /> <% end %> <%= if Enum.any?(@detail_media) do %> - <.media_detail_section title={translated("importAnalysis.mediaWithCount", %{count: length(@detail_media)})} items={@detail_media} expanded={@sections.media} section="media" myself={@myself} /> + <.media_detail_section title={dgettext("ui", "Media (%{count})", count: length(@detail_media))} items={@detail_media} expanded={@sections.media} section="media" myself={@myself} /> <% end %> <%= if Enum.any?(Map.get(@report.items, :categories, [])) or Enum.any?(Map.get(@report.items, :tags, [])) do %>
<%= if @sections.taxonomy do %>
- + <%= if @import_editor.model_selector_open? do %>
<%= for model <- @import_editor.available_models do %> <% end %>
@@ -1000,12 +997,12 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do <%= @import_editor.selected_model_label %> - <%= translated("importAnalysis.aiMappingHint") %> + <%= dgettext("ui", "AI will suggest mappings from new to existing items to avoid duplicates") %>
<.taxonomy_group - title={translated("importAnalysis.categories")} + title={dgettext("ui", "Categories")} items={Map.get(@report.items, :categories, [])} suggestions={Map.get(@import_editor.taxonomy_terms, :categories, [])} edit={@import_editor.taxonomy_edit} @@ -1013,7 +1010,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do myself={@myself} /> <.taxonomy_group - title={translated("importAnalysis.tags")} + title={dgettext("ui", "Tags")} items={Map.get(@report.items, :tags, [])} suggestions={Map.get(@import_editor.taxonomy_terms, :tags, [])} edit={@import_editor.taxonomy_edit} @@ -1029,14 +1026,14 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do <%= if Enum.any?(Map.get(macros, :discovered, [])) do %>
<%= if @sections.macros do %>
- <%= translated("importAnalysis.mappedCount", %{count: macros.mapped_count || 0}) %> - <%= translated("importAnalysis.unmappedCount", %{count: macros.unmapped_count || 0}) %> + <%= dgettext("ui", "%{count} mapped", count: macros.mapped_count || 0) %> + <%= dgettext("ui", "%{count} unmapped", count: macros.unmapped_count || 0) %>
<%= for macro <- macros.discovered do %> @@ -1044,9 +1041,9 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do
<%= macro.name %> - <%= if macro.mapped, do: translated("importAnalysis.macroStatusMapped"), else: translated("importAnalysis.macroStatusUnknown") %> + <%= if macro.mapped, do: dgettext("ui", "Mapped"), else: dgettext("ui", "Unknown") %> - <%= translated("importAnalysis.macroUses", %{count: macro.total_count}) %> + <%= dgettext("ui", "%{count} uses", count: macro.total_count) %>
<%= if Enum.any?(Map.get(macro, :usages, [])) do %>
@@ -1058,17 +1055,17 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do <%= k %>=<%= v %> <% end %> <% else %> - <%= translated("importAnalysis.noParameters") %> + <%= dgettext("ui", "(no parameters)") %> <% end %> - <%= translated("importAnalysis.macroUses", %{count: usage.count}) %> + <%= dgettext("ui", "%{count} uses", count: usage.count) %>
<% end %>
<% end %> <%= if Enum.any?(Map.get(macro, :post_slugs, [])) do %>
- <%= translated("importAnalysis.usedIn", %{items: Enum.join(Enum.take(macro.post_slugs, 5), ", "), more: if(length(macro.post_slugs) > 5, do: translated("importAnalysis.moreSuffix", %{count: length(macro.post_slugs) - 5}), else: "")}) %> + <%= dgettext("ui", "Used in: %{items}%{more}", items: Enum.join(Enum.take(macro.post_slugs, 5), ", "), more: (if length(macro.post_slugs) > 5, do: dgettext("ui", ", +%{count} more", count: length(macro.post_slugs) - 5), else: "")) %>
<% end %>
@@ -1084,7 +1081,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do -

<%= translated("importAnalysis.emptyState") %>

+

<%= dgettext("ui", "Select a WordPress export file to begin analysis.") %>

<% end %> <% end %> @@ -1111,10 +1108,10 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do - - - - + + + + @@ -1122,15 +1119,15 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do - + @@ -1163,15 +1160,15 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do
<%= translated("importAnalysis.slug") %><%= translated("importAnalysis.newEntryWxr") %><%= translated("importAnalysis.existingEntry") %><%= translated("importAnalysis.resolution") %><%= dgettext("ui", "Slug") %><%= dgettext("ui", "New Entry (WXR)") %><%= dgettext("ui", "Existing Entry") %><%= dgettext("ui", "Resolution") %>
<%= Map.get(item, :slug) %> <%= Map.get(item, :title) %><%= Map.get(item, :existing_title) || translated("importAnalysis.none") %><%= Map.get(item, :existing_title) || dgettext("ui", "--") %>
- + <%= if @show_type do %> - + <% end %> - - - - - + + + + + @@ -1184,8 +1181,8 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do - - + + <% end %> @@ -1214,11 +1211,11 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do
<%= translated("importAnalysis.status") %><%= dgettext("ui", "Status") %><%= translated("importAnalysis.type") %><%= dgettext("ui", "Type") %><%= translated("importAnalysis.title") %><%= translated("importAnalysis.slug") %><%= translated("importAnalysis.categories") %><%= translated("importAnalysis.wpStatus") %><%= translated("importAnalysis.existingMatch") %><%= dgettext("ui", "Title") %><%= dgettext("ui", "Slug") %><%= dgettext("ui", "Categories") %><%= dgettext("ui", "WP Status") %><%= dgettext("ui", "Existing Match") %>
<%= Map.get(item, :title) %> <%= Map.get(item, :slug) %> <%= joined_or_none(Map.get(item, :categories)) %><%= Map.get(item, :wp_status) || translated("importAnalysis.none") %><%= Map.get(item, :existing_title) || translated("importAnalysis.none") %><%= Map.get(item, :wp_status) || dgettext("ui", "--") %><%= Map.get(item, :existing_title) || dgettext("ui", "--") %>
- - - - - + + + + + @@ -1226,9 +1223,9 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do - + - + <% end %> @@ -1248,10 +1245,10 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do

<%= @label %>

<%= total_stats(@stats) %>
- <%= if @stats.new_count > 0 do %><%= @stats.new_count %> <%= translated("importAnalysis.new") %><% end %> - <%= if @stats.update_count > 0 do %><%= @stats.update_count %> <%= translated("importAnalysis.update") %><% end %> - <%= if @stats.conflict_count > 0 do %><%= @stats.conflict_count %> <%= translated("importAnalysis.conflict") %><% end %> - <%= if @stats.duplicate_count > 0 do %><%= @stats.duplicate_count %> <%= translated("importAnalysis.duplicate") %><% end %> + <%= if @stats.new_count > 0 do %><%= @stats.new_count %> <%= dgettext("ui", "new") %><% end %> + <%= if @stats.update_count > 0 do %><%= @stats.update_count %> <%= dgettext("ui", "update") %><% end %> + <%= if @stats.conflict_count > 0 do %><%= @stats.conflict_count %> <%= dgettext("ui", "conflict") %><% end %> + <%= if @stats.duplicate_count > 0 do %><%= @stats.duplicate_count %> <%= dgettext("ui", "duplicate") %><% end %>
""" @@ -1285,11 +1282,11 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do

<%= @label %>

<%= total_media_stats(@stats) %>
- <%= if @stats.new_count > 0 do %><%= @stats.new_count %> <%= translated("importAnalysis.new") %><% end %> - <%= if @stats.update_count > 0 do %><%= @stats.update_count %> <%= translated("importAnalysis.update") %><% end %> - <%= if @stats.conflict_count > 0 do %><%= @stats.conflict_count %> <%= translated("importAnalysis.conflict") %><% end %> - <%= if @stats.duplicate_count > 0 do %><%= @stats.duplicate_count %> <%= translated("importAnalysis.duplicate") %><% end %> - <%= if @stats.missing_count > 0 do %><%= @stats.missing_count %> <%= translated("importAnalysis.missing") %><% end %> + <%= if @stats.new_count > 0 do %><%= @stats.new_count %> <%= dgettext("ui", "new") %><% end %> + <%= if @stats.update_count > 0 do %><%= @stats.update_count %> <%= dgettext("ui", "update") %><% end %> + <%= if @stats.conflict_count > 0 do %><%= @stats.conflict_count %> <%= dgettext("ui", "conflict") %><% end %> + <%= if @stats.duplicate_count > 0 do %><%= @stats.duplicate_count %> <%= dgettext("ui", "duplicate") %><% end %> + <%= if @stats.missing_count > 0 do %><%= @stats.missing_count %> <%= dgettext("ui", "missing") %><% end %>
""" @@ -1305,9 +1302,9 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do

<%= @label %>

<%= @stats.existing_count + @stats.mapped_count + @stats.new_count %>
- <%= if @stats.existing_count > 0 do %><%= @stats.existing_count %> <%= translated("importAnalysis.existing") %><% end %> - <%= if @stats.mapped_count > 0 do %><%= @stats.mapped_count %> <%= translated("importAnalysis.mapped") %><% end %> - <%= if @stats.new_count > 0 do %><%= @stats.new_count %> <%= translated("importAnalysis.new") %><% end %> + <%= if @stats.existing_count > 0 do %><%= @stats.existing_count %> <%= dgettext("ui", "existing") %><% end %> + <%= if @stats.mapped_count > 0 do %><%= @stats.mapped_count %> <%= dgettext("ui", "mapped") %><% end %> + <%= if @stats.new_count > 0 do %><%= @stats.new_count %> <%= dgettext("ui", "new") %><% end %>
""" @@ -1342,14 +1339,14 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do type="text" name="mapped_to" value={Map.get(@edit || %{}, :value, Map.get(item, :mapped_to) || "") || ""} - placeholder={translated("importAnalysis.mapToPlaceholder")} + placeholder={dgettext("ui", "Map to...")} list={"taxonomy-suggestions-#{@type}"} autocomplete="off" /> - - + + <%= if present?(item.mapped_to) do %> - + <% end %> <% else %> @@ -1380,7 +1377,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do phx-value-name={item.name} phx-value-mapped_to={Map.get(item, :mapped_to) || ""} ><%= item.mapped_to %> - + <% end %> <% end %> @@ -1416,7 +1413,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do end defp joined_or_none(values) when is_list(values) and values != [], do: Enum.join(values, ", ") - defp joined_or_none(_values), do: translated("importAnalysis.none") + defp joined_or_none(_values), do: dgettext("ui", "--") defp status_badge_class(status), do: ["status-badge", status] @@ -1445,7 +1442,4 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do defp maybe_put(map, _key, nil), do: map defp maybe_put(map, key, value), do: Map.put(map, key, value) - - defp translated(text, bindings \\ %{}), - do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current()) end diff --git a/lib/bds/desktop/shell_live/import_editor/analysis_state.ex b/lib/bds/desktop/shell_live/import_editor/analysis_state.ex index e6e6574..c357eb8 100644 --- a/lib/bds/desktop/shell_live/import_editor/analysis_state.ex +++ b/lib/bds/desktop/shell_live/import_editor/analysis_state.ex @@ -2,7 +2,8 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.AnalysisState do @moduledoc false alias BDS.{ImportAnalysis, ImportDefinitions, Metadata} - alias BDS.Desktop.{FilePicker, FolderPicker, ShellData} + alias BDS.Desktop.{FilePicker, FolderPicker} + use Gettext, backend: BDS.Gettext @spec change_definition(term(), term(), term()) :: term() def change_definition(socket, params, reload) do @@ -18,7 +19,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.AnalysisState do @spec select_uploads_folder(term(), term(), term()) :: term() def select_uploads_folder(socket, reload, append_output) do with %{id: definition_id} <- socket.assigns.current_tab do - case FolderPicker.choose_directory(translated("importAnalysis.uploadsFolder")) do + case FolderPicker.choose_directory(dgettext("ui", "Uploads Folder")) do {:ok, uploads_folder_path} -> {:ok, _definition} = ImportDefinitions.update_definition(definition_id, %{ @@ -32,7 +33,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.AnalysisState do {:error, %{message: message}} -> socket - |> append_output.(translated("activity.import"), message, nil, "error") + |> append_output.(dgettext("ui", "Import"), message, nil, "error") |> reload.(socket.assigns.workbench) end else @@ -44,7 +45,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.AnalysisState do def select_and_analyze(socket, reload, append_output) do with %{id: definition_id} <- socket.assigns.current_tab, %{} = definition <- ImportDefinitions.get_definition(definition_id) do - case FilePicker.choose_file(translated("importAnalysis.wxrFile")) do + case FilePicker.choose_file(dgettext("ui", "WXR File")) do {:ok, wxr_file_path} -> project_id = socket.assigns.projects.active_project_id @@ -78,7 +79,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.AnalysisState do :import_editor_analysis_states, Map.put(socket.assigns.import_editor_analysis_states, definition_id, %{ loading: true, - step: translated("importAnalysis.analyzingWxr"), + step: dgettext("ui", "Analyzing WXR file..."), detail: Path.basename(wxr_file_path), file_path: wxr_file_path, ref: task.ref @@ -99,7 +100,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.AnalysisState do {:error, %{message: message}} -> socket - |> append_output.(translated("activity.import"), message, nil, "error") + |> append_output.(dgettext("ui", "Import"), message, nil, "error") |> reload.(socket.assigns.workbench) end else @@ -167,18 +168,18 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.AnalysisState do {:error, reason} -> socket - |> append_output.(translated("activity.import"), inspect(reason), nil, "error") + |> append_output.(dgettext("ui", "Import"), inspect(reason), nil, "error") |> reload.(socket.assigns.workbench) end {:error, %{message: message}} -> socket - |> append_output.(translated("activity.import"), message, nil, "error") + |> append_output.(dgettext("ui", "Import"), message, nil, "error") |> reload.(socket.assigns.workbench) {:error, reason} -> socket - |> append_output.(translated("activity.import"), inspect(reason), nil, "error") + |> append_output.(dgettext("ui", "Import"), inspect(reason), nil, "error") |> reload.(socket.assigns.workbench) end end @@ -200,7 +201,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.AnalysisState do :import_editor_analysis_states, Map.delete(socket.assigns.import_editor_analysis_states, definition_id) ) - |> append_output.(translated("activity.import"), message, nil, "error") + |> append_output.(dgettext("ui", "Import"), message, nil, "error") |> reload.(socket.assigns.workbench) end end @@ -294,12 +295,12 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.AnalysisState do def translate_phase(step) when is_binary(step) do case step do - "parsing" -> translated("importAnalysis.analysisPhase.parsing") - "scanning" -> translated("importAnalysis.analysisPhase.scanning") - "taxonomies" -> translated("importAnalysis.analysisPhase.taxonomies") - "posts" -> translated("importAnalysis.analysisPhase.posts") - "media" -> translated("importAnalysis.analysisPhase.media") - "complete" -> translated("importAnalysis.analysisPhase.complete") + "parsing" -> dgettext("ui", "Parsing WXR file...") + "scanning" -> dgettext("ui", "Scanning entries...") + "taxonomies" -> dgettext("ui", "Analyzing taxonomies...") + "posts" -> dgettext("ui", "Analyzing posts...") + "media" -> dgettext("ui", "Analyzing media...") + "complete" -> dgettext("ui", "Analysis complete") other -> other end end @@ -307,8 +308,5 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.AnalysisState do @spec translate_phase(term()) :: term() def translate_phase(other), do: other - defp translated(text, bindings \\ %{}), - do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current()) - defp present?(value), do: value not in [nil, ""] end diff --git a/lib/bds/desktop/shell_live/import_editor/progress_tracking.ex b/lib/bds/desktop/shell_live/import_editor/progress_tracking.ex index 6f9d739..fe0afc2 100644 --- a/lib/bds/desktop/shell_live/import_editor/progress_tracking.ex +++ b/lib/bds/desktop/shell_live/import_editor/progress_tracking.ex @@ -2,8 +2,8 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.ProgressTracking do @moduledoc false alias BDS.{ImportDefinitions, ImportExecution} - alias BDS.Desktop.ShellData alias BDS.Desktop.ShellLive.ImportEditor.AnalysisState + use Gettext, backend: BDS.Gettext @spec execute_import(term(), term(), term()) :: term() def execute_import(socket, reload, _append_output) do @@ -129,8 +129,8 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.ProgressTracking do }) ) |> append_output.( - translated("activity.import"), - translated("importAnalysis.importComplete", %{count: previous_state.count}), + dgettext("ui", "Import"), + dgettext("ui", "Import completed successfully!", count: previous_state.count), nil, "info" ) @@ -148,7 +148,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.ProgressTracking do ref: nil }) ) - |> append_output.(translated("activity.import"), message, nil, "error") + |> append_output.(dgettext("ui", "Import"), message, nil, "error") |> reload.(socket.assigns.workbench) {:error, reason} -> @@ -165,7 +165,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.ProgressTracking do ref: nil }) ) - |> append_output.(translated("activity.import"), message, nil, "error") + |> append_output.(dgettext("ui", "Import"), message, nil, "error") |> reload.(socket.assigns.workbench) end end @@ -208,7 +208,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.ProgressTracking do ref: nil }) ) - |> append_output.(translated("activity.import"), message, nil, "error") + |> append_output.(dgettext("ui", "Import"), message, nil, "error") |> reload.(socket.assigns.workbench) end end @@ -265,16 +265,16 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.ProgressTracking do seconds = div(ms, 1000) if seconds < 60 do - translated("importAnalysis.eta", %{ - value: translated("importAnalysis.etaSeconds", %{count: seconds}) - }) + dgettext("ui", "ETA: %{value}", + value: dgettext("ui", "%{count}s", count: seconds) + ) else m = div(seconds, 60) s = rem(seconds, 60) - translated("importAnalysis.eta", %{ - value: translated("importAnalysis.etaMinutes", %{minutes: m, seconds: s}) - }) + dgettext("ui", "ETA: %{value}", + value: dgettext("ui", "%{minutes}m %{seconds}s", minutes: m, seconds: s) + ) end end @@ -282,18 +282,15 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.ProgressTracking do def translate_execution_phase(phase) when is_binary(phase) do case phase do - "tags" -> translated("importAnalysis.phase.tags") - "posts" -> translated("importAnalysis.phase.posts") - "media" -> translated("importAnalysis.phase.media") - "pages" -> translated("importAnalysis.phase.pages") - "complete" -> translated("importAnalysis.phase.complete") + "tags" -> dgettext("ui", "Importing tags & categories...") + "posts" -> dgettext("ui", "Importing posts...") + "media" -> dgettext("ui", "Importing media...") + "pages" -> dgettext("ui", "Importing pages...") + "complete" -> dgettext("ui", "Import complete") other -> other end end @spec translate_execution_phase(term()) :: term() def translate_execution_phase(other), do: other - - defp translated(text, bindings \\ %{}), - do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current()) end diff --git a/lib/bds/desktop/shell_live/import_editor/taxonomy_editing.ex b/lib/bds/desktop/shell_live/import_editor/taxonomy_editing.ex index 9032ca9..6461140 100644 --- a/lib/bds/desktop/shell_live/import_editor/taxonomy_editing.ex +++ b/lib/bds/desktop/shell_live/import_editor/taxonomy_editing.ex @@ -2,7 +2,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.TaxonomyEditing do @moduledoc false alias BDS.{AI, ImportDefinitions, Metadata, Tags} - alias BDS.Desktop.ShellData + use Gettext, backend: BDS.Gettext @spec start_taxonomy_edit(term(), term(), term()) :: term() def start_taxonomy_edit( @@ -85,12 +85,8 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.TaxonomyEditing do socket.assigns.offline_mode -> socket |> append_output.( - translated("activity.import"), - ShellData.translate( - "Automatic AI actions stay gated by airplane mode.", - %{}, - socket.assigns.page_language - ), + dgettext("ui", "Import"), + BDS.Gettext.lgettext(socket.assigns.page_language, "ui", "Automatic AI actions stay gated by airplane mode."), nil, "info" ) @@ -124,8 +120,8 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.TaxonomyEditing do socket |> append_output.( - translated("activity.import"), - translated("importAnalysis.mappedCount", %{count: mapped_count}), + dgettext("ui", "Import"), + dgettext("ui", "%{count} mapped", count: mapped_count), Map.get(socket.assigns.import_editor_selected_models, definition_id), "info" ) @@ -134,7 +130,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.TaxonomyEditing do {:error, reason} -> socket |> append_output.( - translated("activity.import"), + dgettext("ui", "Import"), inspect(reason), Map.get(socket.assigns.import_editor_selected_models, definition_id), "error" @@ -274,19 +270,16 @@ defmodule BDS.Desktop.ShellLive.ImportEditor.TaxonomyEditing do def taxonomy_mapping_tooltip(item) do action = if present?(item.mapped_to), - do: translated("importAnalysis.mappingActionEdit"), - else: translated("importAnalysis.mappingActionAdd") + do: dgettext("ui", "edit"), + else: dgettext("ui", "add") - translated("importAnalysis.mappingTooltip", %{action: action}) + dgettext("ui", "Click to %{action} mapping", action: action) end @spec maybe_put_option(term(), term(), term()) :: term() def maybe_put_option(opts, _key, nil), do: opts def maybe_put_option(opts, key, value), do: Keyword.put(opts, key, value) - defp translated(text, bindings \\ %{}), - do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current()) - defp present?(value), do: value not in [nil, ""] defp blank_to_nil(""), do: nil defp blank_to_nil(value), do: value diff --git a/lib/bds/desktop/shell_live/index.html.heex b/lib/bds/desktop/shell_live/index.html.heex index 57a9adb..4ae23a1 100644 --- a/lib/bds/desktop/shell_live/index.html.heex +++ b/lib/bds/desktop/shell_live/index.html.heex @@ -77,8 +77,8 @@ data-testid="toggle-sidebar" type="button" phx-click="toggle_sidebar" - aria-label={translated("Toggle sidebar")} - title={translated("Toggle sidebar")} + aria-label={dgettext("ui", "Toggle sidebar")} + title={dgettext("ui", "Toggle sidebar")} > @@ -89,8 +89,8 @@ data-testid="toggle-panel" type="button" phx-click="toggle_panel" - aria-label={translated("Toggle panel")} - title={translated("Toggle panel")} + aria-label={dgettext("ui", "Toggle panel")} + title={dgettext("ui", "Toggle panel")} > @@ -101,8 +101,8 @@ data-testid="toggle-assistant" type="button" phx-click="toggle_assistant_sidebar" - aria-label={translated("Toggle assistant")} - title={translated("Toggle assistant")} + aria-label={dgettext("ui", "Toggle assistant")} + title={dgettext("ui", "Toggle assistant")} > @@ -178,8 +178,8 @@ data-testid="sidebar-filter-toggle" type="button" phx-click="toggle_sidebar_filters" - aria-label={translated(Map.get(@sidebar_data.filters, :toggle_filters_label))} - title={translated(Map.get(@sidebar_data.filters, :toggle_filters_label))} + aria-label={Map.get(@sidebar_data.filters, :toggle_filters_label)} + title={Map.get(@sidebar_data.filters, :toggle_filters_label)} > @@ -194,8 +194,8 @@ type="button" phx-click="create_sidebar_item" phx-value-kind={create_action.kind} - aria-label={translated(create_action.label)} - title={translated(create_action.label)} + aria-label={create_action.label} + title={create_action.label} > @@ -215,7 +215,7 @@
<%= if Enum.empty?(@workbench.tabs) do %> -
<%= translated("Dashboard") %>
+
<%= dgettext("ui", "Dashboard") %>
<% else %>
<%= for tab <- @workbench.tabs do %> @@ -253,8 +253,8 @@ phx-click="close_tab" phx-value-type={tab.type} phx-value-id={tab.id} - aria-label={translated("Close tab")} - title={translated("Close tab")} + aria-label={dgettext("ui", "Close tab")} + title={dgettext("ui", "Close tab")} > × @@ -269,41 +269,41 @@ <%= if is_nil(@current_tab) do %>
-

<%= translated("dashboard.title") %>

-

<%= translated("dashboard.subtitle") %>

+

<%= dgettext("ui", "Dashboard") %>

+

<%= dgettext("ui", "Overview of your blog database") %>

<%= @dashboard.post_stats.total_posts || 0 %>
-
<%= translated("dashboard.stats.totalPosts") %>
+
<%= dgettext("ui", "Total Posts") %>
- <%= translated("dashboard.stats.published", %{count: @dashboard.post_stats.published_count || 0}) %> - <%= translated("dashboard.stats.drafts", %{count: @dashboard.post_stats.draft_count || 0}) %> + <%= dgettext("ui", "dashboard.stats.published", count: @dashboard.post_stats.published_count || 0) %> + <%= dgettext("ui", "dashboard.stats.drafts", count: @dashboard.post_stats.draft_count || 0) %> <%= if (@dashboard.post_stats.archived_count || 0) > 0 do %> - <%= translated("dashboard.stats.archived", %{count: @dashboard.post_stats.archived_count || 0}) %> + <%= dgettext("ui", "dashboard.stats.archived", count: @dashboard.post_stats.archived_count || 0) %> <% end %>
<%= @dashboard.media_stats.media_count || 0 %>
-
<%= translated("dashboard.stats.mediaFiles") %>
+
<%= dgettext("ui", "Media Files") %>
- <%= translated("dashboard.stats.images", %{count: @dashboard.media_stats.image_count || 0}) %> + <%= dgettext("ui", "dashboard.stats.images", count: @dashboard.media_stats.image_count || 0) %> <%= ShellData.format_bytes(@dashboard.media_stats.total_bytes || 0) %>
<%= length(@dashboard_tag_cloud_items) %>
-
<%= translated("dashboard.stats.tags") %>
+
<%= dgettext("ui", "Tags") %>
- <%= translated("dashboard.stats.categories", %{count: length(@dashboard_category_counts)}) %> + <%= dgettext("ui", "dashboard.stats.categories", count: length(@dashboard_category_counts)) %>
<%= if Enum.any?(@dashboard_timeline_entries) do %>
-

<%= translated("dashboard.section.postsOverTime") %>

+

<%= dgettext("ui", "Posts Over Time") %>

<%= for entry <- @dashboard_timeline_entries do %>
@@ -322,7 +322,7 @@ <%= if Enum.any?(@dashboard_tag_cloud_items) do %>
-

<%= translated("dashboard.section.tags") %>

+

<%= dgettext("ui", "Tags") %>

<%= for item <- @dashboard_tag_cloud_items do %> <%= item.tag %> @@ -333,7 +333,7 @@ <%= if Enum.any?(@dashboard_category_counts) do %>
-

<%= translated("dashboard.section.categories") %>

+

<%= dgettext("ui", "Categories") %>

<%= for category <- @dashboard_category_counts do %> @@ -347,7 +347,7 @@ <%= if Enum.any?(@dashboard_recent_posts) do %>
-

<%= translated("dashboard.section.recentlyUpdated") %>

+

<%= dgettext("ui", "Recently Updated") %>

<%= for post <- @dashboard_recent_posts do %>
@@ -442,8 +442,8 @@ @@ -471,8 +471,8 @@ data-testid="panel-close" type="button" phx-click="toggle_panel" - aria-label={translated("Close panel")} - title={translated("Close panel")} + aria-label={dgettext("ui", "Close panel")} + title={dgettext("ui", "Close panel")} > × @@ -493,24 +493,24 @@
- <%= translated("AI Assistant") %> - <%= translated("AI conversations") %> + <%= dgettext("ui", "AI Assistant") %> + <%= dgettext("ui", "AI conversations") %>
- <%= if @offline_mode, do: translated("Offline"), else: translated("Chat") %> + <%= if @offline_mode, do: dgettext("ui", "Offline"), else: dgettext("ui", "Chat") %>
- <%= translated("Project") %> + <%= dgettext("ui", "Project") %> <%= BDS.Desktop.ShellLive.ChatSurface.assistant_project_name(@current_project) %>
- <%= translated("Editor") %> + <%= dgettext("ui", "Editor") %> <%= BDS.Desktop.ShellLive.TabHelpers.tab_title(@current_tab, @tab_meta) %>

<%= BDS.Desktop.ShellLive.TabHelpers.tab_subtitle(@current_tab, @tab_meta) %>

@@ -527,7 +527,7 @@ data-testid="assistant-prompt-input" name="assistant[prompt]" rows="6" - placeholder={translated("Ask the assistant about the active project or editor.")} + placeholder={dgettext("ui", "Ask the assistant about the active project or editor.")} ><%= @assistant_prompt %> @@ -544,8 +544,8 @@
<%= for card <- @assistant_cards do %>
- <%= translated(card.label) %> - <%= translated(card.text) %> + <%= card.label %> + <%= card.text %>
<% end %>
@@ -576,8 +576,8 @@ data-testid="toggle-sidebar" type="button" phx-click="toggle_sidebar" - aria-label={translated("Toggle sidebar")} - title={translated("Toggle sidebar")} + aria-label={dgettext("ui", "Toggle sidebar")} + title={dgettext("ui", "Toggle sidebar")} > @@ -588,8 +588,8 @@ data-testid="toggle-panel" type="button" phx-click="toggle_panel" - aria-label={translated("Toggle panel")} - title={translated("Toggle panel")} + aria-label={dgettext("ui", "Toggle panel")} + title={dgettext("ui", "Toggle panel")} > @@ -600,8 +600,8 @@ data-testid="toggle-assistant" type="button" phx-click="toggle_assistant_sidebar" - aria-label={translated("Toggle assistant")} - title={translated("Toggle assistant")} + aria-label={dgettext("ui", "Toggle assistant")} + title={dgettext("ui", "Toggle assistant")} > @@ -614,7 +614,7 @@ class="project-selector-trigger" data-testid="project-selector-trigger" type="button" - title={translated("Switch project")} + title={dgettext("ui", "Switch project")} phx-click="toggle_project_menu" > @@ -629,7 +629,7 @@ <%= if @project_menu_open do %>
- <%= translated("Projects") %> + <%= dgettext("ui", "Projects") %>
<%= for project <- @projects.projects do %> @@ -650,10 +650,10 @@
@@ -663,7 +663,7 @@ <%= if @status.left.running_task_message do %> <% end %> - <%= @status.left.running_task_message || translated("Idle") %> + <%= @status.left.running_task_message || dgettext("ui", "Idle") %> <%= if (@status.left.running_task_overflow || 0) > 0 do %> +<%= @status.left.running_task_overflow %> <% end %> @@ -673,9 +673,9 @@ <%= @status.right.post_count %> <%= @status.right.media_count %> <%= @status.right.theme_badge %> - +
- <%= translated("UI") %> + <%= dgettext("ui", "UI") %>
- +
- +
<%= if @media_editor.dimensions do %>
- +
<% end %>
- +
- +
- +
- +
- +
- +
- +
- +
- +
diff --git a/lib/bds/desktop/shell_live/menu_editor.ex b/lib/bds/desktop/shell_live/menu_editor.ex index 81bf265..e57881c 100644 --- a/lib/bds/desktop/shell_live/menu_editor.ex +++ b/lib/bds/desktop/shell_live/menu_editor.ex @@ -3,7 +3,8 @@ defmodule BDS.Desktop.ShellLive.MenuEditor do use Phoenix.LiveComponent - alias BDS.Desktop.ShellData + + use Gettext, backend: BDS.Gettext alias BDS.Desktop.ShellLive.MenuEditor.{ DraftManagement, @@ -215,7 +216,7 @@ defmodule BDS.Desktop.ShellLive.MenuEditor do Enum.map(state.items, &TreeOps.persisted_item/1) ) - notify_output(translated("menuEditor.tabTitle"), translated("menuEditor.saved"), "info") + notify_output(dgettext("ui", "Blog Menu"), dgettext("ui", "Blog menu saved"), "info") socket |> build_data() end @@ -236,8 +237,8 @@ defmodule BDS.Desktop.ShellLive.MenuEditor do tab_meta = Map.put(socket.assigns.tab_meta, {:menu_editor, tab_id}, %{ - title: translated("menuEditor.tabTitle"), - subtitle: translated("menuEditor.description") + title: dgettext("ui", "Blog Menu"), + subtitle: dgettext("ui", "Manage the central blog navigation outline and save it to meta/menu.opml.") }) socket @@ -284,7 +285,7 @@ defmodule BDS.Desktop.ShellLive.MenuEditor do phx-target={@myself} style={"--menu-editor-depth: #{@depth};"} > - ⋮⋮ + ⋮⋮ <.kind_icon kind={item.kind} /> @@ -317,16 +318,16 @@ defmodule BDS.Desktop.ShellLive.MenuEditor do
@@ -334,7 +335,7 @@ defmodule BDS.Desktop.ShellLive.MenuEditor do <%= if @menu_editor.draft.type == :page do %> <%= if @menu_editor.items == [] do %> - + <% else %>
- + <%= if @misc_editor.kind == :site_validation do %> - + <% end %> <%= if @misc_editor.kind == :find_duplicates do %> - + <% end %>
@@ -25,9 +25,9 @@ <%= case @misc_editor.kind do %> <% :site_validation -> %>
-

<%= translated("Missing URLs") %>

<%= if Enum.empty?(@misc_editor.missing_url_paths) do %>

<%= translated("None found") %>

<% end %>
    <%= for path <- @misc_editor.missing_url_paths do %>
  • <%= path %>
  • <% end %>
-

<%= translated("Extra URLs") %>

<%= if Enum.empty?(@misc_editor.extra_url_paths) do %>

<%= translated("None found") %>

<% end %>
    <%= for path <- @misc_editor.extra_url_paths do %>
  • <%= path %>
  • <% end %>
-

<%= translated("Updated URLs") %>

<%= if Enum.empty?(@misc_editor.updated_post_url_paths) do %>

<%= translated("None found") %>

<% end %>
    <%= for path <- @misc_editor.updated_post_url_paths do %>
  • <%= path %>
  • <% end %>
+

<%= dgettext("ui", "Missing URLs") %>

<%= if Enum.empty?(@misc_editor.missing_url_paths) do %>

<%= dgettext("ui", "None found") %>

<% end %>
    <%= for path <- @misc_editor.missing_url_paths do %>
  • <%= path %>
  • <% end %>
+

<%= dgettext("ui", "Extra URLs") %>

<%= if Enum.empty?(@misc_editor.extra_url_paths) do %>

<%= dgettext("ui", "None found") %>

<% end %>
    <%= for path <- @misc_editor.extra_url_paths do %>
  • <%= path %>
  • <% end %>
+

<%= dgettext("ui", "Updated URLs") %>

<%= if Enum.empty?(@misc_editor.updated_post_url_paths) do %>

<%= dgettext("ui", "None found") %>

<% end %>
    <%= for path <- @misc_editor.updated_post_url_paths do %>
  • <%= path %>
  • <% end %>
<% :metadata_diff -> %> @@ -81,7 +81,7 @@ phx-value-direction="db_to_file" phx-value-field={field.field_name} > - <%= translated("DB to File") %> + <%= dgettext("ui", "DB to File") %>
<% end %> @@ -130,7 +130,7 @@ <%= diff.db_value %>
- <%= translated("File") %> + <%= dgettext("ui", "File") %> <%= diff.file_value %>
@@ -145,7 +145,7 @@ <%= if @misc_editor.active_field == nil and @misc_editor.orphan_files != [] do %>
-

<%= translated("Orphan Files") %>

+

<%= dgettext("ui", "Orphan Files") %>

<%= length(@misc_editor.orphan_files) %>
@@ -165,13 +165,13 @@
<%= orphan.slug %> -
<%= translated("Orphan Files") %>
+
<%= dgettext("ui", "Orphan Files") %>
-
<%= translated("Path") %>
+
<%= dgettext("ui", "Path") %>
<%= orphan.file_path %>
@@ -192,30 +192,30 @@
-

<%= translated("translationValidation.databaseTitle") %>

+

<%= dgettext("ui", "translationValidation.databaseTitle") %>

<%= if @misc_editor.invalid_database_rows == [] do %> -

<%= translated("translationValidation.noneDatabase") %>

+

<%= dgettext("ui", "translationValidation.noneDatabase") %>

<% else %>
<%= for issue <- @misc_editor.invalid_database_rows do %>

<%= translation_issue_label(issue) %>

-
<%= translated("translationValidation.field.translationFor") %>
+
<%= dgettext("ui", "translationValidation.field.translationFor") %>
<%= translation_issue_value(issue, :translation_for) %>
<%= if translation_issue_value(issue, :translation_id) do %> -
<%= translated("translationValidation.field.translationId") %>
+
<%= dgettext("ui", "translationValidation.field.translationId") %>
<%= translation_issue_value(issue, :translation_id) %>
<% end %> <%= if translation_issue_value(issue, :title) do %> -
<%= translated("translationValidation.field.title") %>
+
<%= dgettext("ui", "translationValidation.field.title") %>
<%= translation_issue_value(issue, :title) %>
<% end %> -
<%= translated("translationValidation.field.languages") %>
+
<%= dgettext("ui", "translationValidation.field.languages") %>
<%= translation_issue_languages(issue) %>
<%= if translation_issue_value(issue, :file_path) do %> -
<%= translated("translationValidation.field.filePath") %>
+
<%= dgettext("ui", "translationValidation.field.filePath") %>
<%= translation_issue_value(issue, :file_path) %>
<% end %>
@@ -226,26 +226,26 @@
-

<%= translated("translationValidation.filesystemTitle") %>

+

<%= dgettext("ui", "translationValidation.filesystemTitle") %>

<%= if @misc_editor.invalid_filesystem_files == [] do %> -

<%= translated("translationValidation.noneFilesystem") %>

+

<%= dgettext("ui", "translationValidation.noneFilesystem") %>

<% else %>
<%= for issue <- @misc_editor.invalid_filesystem_files do %>

<%= translation_issue_label(issue) %>

-
<%= translated("translationValidation.field.translationFor") %>
+
<%= dgettext("ui", "translationValidation.field.translationFor") %>
<%= translation_issue_value(issue, :translation_for) %>
<%= if translation_issue_value(issue, :title) do %> -
<%= translated("translationValidation.field.title") %>
+
<%= dgettext("ui", "translationValidation.field.title") %>
<%= translation_issue_value(issue, :title) %>
<% end %> -
<%= translated("translationValidation.field.languages") %>
+
<%= dgettext("ui", "translationValidation.field.languages") %>
<%= translation_issue_languages(issue) %>
<%= if translation_issue_value(issue, :file_path) do %> -
<%= translated("translationValidation.field.filePath") %>
+
<%= dgettext("ui", "translationValidation.field.filePath") %>
<%= translation_issue_value(issue, :file_path) %>
<% end %>
@@ -256,8 +256,8 @@
- - + +
@@ -269,8 +269,8 @@ - <%= if(BDS.MapUtils.attr(pair, :exact_match), do: translated("Exact Match"), else: "#{Float.round((BDS.MapUtils.attr(pair, :similarity) || 0.0) * 100, 1)}%") %> - + <%= if(BDS.MapUtils.attr(pair, :exact_match), do: dgettext("ui", "Exact Match"), else: "#{Float.round((BDS.MapUtils.attr(pair, :similarity) || 0.0) * 100, 1)}%") %> + <% end %>
@@ -281,7 +281,7 @@

<%= @misc_editor.empty_message %>

<% else %>
- + +
<%= for result <- if(String.length(@shell_overlay.search_query) >= 2, do: @shell_overlay.results, else: @shell_overlay.related_posts) do %> @@ -69,20 +69,20 @@ <% end %> <%= if Enum.empty?(if(String.length(@shell_overlay.search_query) >= 2, do: @shell_overlay.results, else: @shell_overlay.related_posts)) do %> -
<%= translated("No items") %>
+
<%= dgettext("ui", "No items") %>
<% end %>
<% else %>
- + <% end %>
@@ -90,13 +90,13 @@ <% :insert_media -> %>
- +
<%= translated("importAnalysis.status") %><%= translated("importAnalysis.filename") %><%= translated("importAnalysis.type") %><%= translated("importAnalysis.path") %><%= translated("importAnalysis.existingMatch") %><%= dgettext("ui", "Status") %><%= dgettext("ui", "Filename") %><%= dgettext("ui", "Type") %><%= dgettext("ui", "Path") %><%= dgettext("ui", "Existing Match") %>
<%= item.status %> <%= Map.get(item, :filename) %><%= Map.get(item, :mime_type) || translated("importAnalysis.none") %><%= Map.get(item, :mime_type) || dgettext("ui", "--") %> <%= Map.get(item, :relative_path) %><%= Map.get(item, :existing_title) || translated("importAnalysis.none") %><%= Map.get(item, :existing_title) || dgettext("ui", "--") %>
- - - - - - - + + + + + + + @@ -167,7 +167,7 @@ @@ -195,103 +195,103 @@
<%= translated("Category") %><%= translated("Title") %><%= translated("Render in Lists") %><%= translated("Show Titles") %><%= translated("Post Template") %><%= translated("List Template") %><%= translated("Actions") %><%= dgettext("ui", "Category") %><%= dgettext("ui", "Title") %><%= dgettext("ui", "Render in Lists") %><%= dgettext("ui", "Show Titles") %><%= dgettext("ui", "Post Template") %><%= dgettext("ui", "List Template") %><%= dgettext("ui", "Actions") %>
- - + +
-
+
- +
-
+
<% end %> <%= if @settings_editor.ai_visible? do %>
-

<%= translated("AI") %>

<%= translated("OpenAI-compatible endpoints, model routing, airplane mode, and system prompt") %>

+

<%= dgettext("ui", "AI") %>

<%= dgettext("ui", "OpenAI-compatible endpoints, model routing, airplane mode, and system prompt") %>

-
+
- +
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
- +
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
-
+
+
-
+
@@ -305,53 +305,53 @@ <% end %>
-
+
<% end %> <%= if @settings_editor.technology_visible? do %>
-

<%= translated("Technology") %>

<%= translated("Application-level runtime behavior and semantic indexing") %>

+

<%= dgettext("ui", "Technology") %>

<%= dgettext("ui", "Application-level runtime behavior and semantic indexing") %>

-
-
+
+
-
-

<%= translated("Scripting capabilities are configured at the application layer in the rewrite and do not expose runtime switching here.") %>

+
+

<%= dgettext("ui", "Scripting capabilities are configured at the application layer in the rewrite and do not expose runtime switching here.") %>

-
+
<% end %> <%= if @settings_editor.publishing_visible? do %>
-

<%= translated("Publishing") %>

<%= translated("Deployment credentials for upload tasks") %>

+

<%= dgettext("ui", "Publishing") %>

<%= dgettext("ui", "Deployment credentials for upload tasks") %>

-
-
-
-
+
+
+
+
-
+
<% end %> <%= if @settings_editor.mcp_visible? do %>
-

<%= translated("MCP") %>

<%= translated("Agent configuration files for the built-in bDS MCP server") %>

+

<%= dgettext("ui", "MCP") %>

<%= dgettext("ui", "Agent configuration files for the built-in bDS MCP server") %>

<%= for agent <- @settings_editor.mcp do %>
-

<%= agent.config_path || translated("Not supported in the rewrite yet") %>

+

<%= agent.config_path || dgettext("ui", "Not supported in the rewrite yet") %>

@@ -362,16 +362,16 @@ <%= if @settings_editor.data_visible? do %>
-

<%= translated("Data Maintenance") %>

<%= translated("Rebuild filesystem-backed records and thumbnails") %>

+

<%= dgettext("ui", "Data Maintenance") %>

<%= dgettext("ui", "Rebuild filesystem-backed records and thumbnails") %>

- - - - - - - - + + + + + + + +
<% end %> diff --git a/lib/bds/desktop/shell_live/settings_editor_html/style_editor.html.heex b/lib/bds/desktop/shell_live/settings_editor_html/style_editor.html.heex index a705d34..bcd7fa4 100644 --- a/lib/bds/desktop/shell_live/settings_editor_html/style_editor.html.heex +++ b/lib/bds/desktop/shell_live/settings_editor_html/style_editor.html.heex @@ -1,10 +1,10 @@
-

<%= translated("Style") %>

-

<%= translated("Theme preview and renderer theme selection") %>

+

<%= dgettext("ui", "Style") %>

+

<%= dgettext("ui", "Theme preview and renderer theme selection") %>

-
+
<%= for theme <- @style_editor.themes do %> +
- +
\ No newline at end of file diff --git a/lib/bds/desktop/shell_live/sidebar_components.ex b/lib/bds/desktop/shell_live/sidebar_components.ex index 32ebfaf..cd3fb3c 100644 --- a/lib/bds/desktop/shell_live/sidebar_components.ex +++ b/lib/bds/desktop/shell_live/sidebar_components.ex @@ -6,6 +6,7 @@ defmodule BDS.Desktop.ShellLive.SidebarComponents do alias BDS.Desktop.ShellData alias BDS.Desktop.UILocale alias BDS.UI.Registry + use Gettext, backend: BDS.Gettext def sidebar_content(assigns) do UILocale.put(assigns.page_language) @@ -60,9 +61,9 @@ defmodule BDS.Desktop.ShellLive.SidebarComponents do type="text" name="sidebar_filters[search]" value={Map.get(@selected_filters, :search) || ""} - placeholder={translated(@sidebar_filters_config.search_placeholder)} + placeholder={@sidebar_filters_config.search_placeholder} /> -
<% end %> @@ -96,7 +97,7 @@ defmodule BDS.Desktop.ShellLive.SidebarComponents do phx-click="toggle_sidebar_archive" > <%= if @archive_collapsed, do: "▶", else: "▼" %> - <%= translated(@sidebar_filters_config.archive_label) %> + <%= @sidebar_filters_config.archive_label %> <%= if Map.get(@selected_filters, :year) do %> <% end %> @@ -157,9 +158,9 @@ defmodule BDS.Desktop.ShellLive.SidebarComponents do phx-click="toggle_sidebar_tags" > <%= if @tags_collapsed, do: "▶", else: "▼" %> - <%= translated(@sidebar_filters_config.tags_label) %> + <%= @sidebar_filters_config.tags_label %> <%= if Enum.any?(Map.get(@selected_filters, :tags, [])) do %> - + <% end %>
<%= unless @tags_collapsed do %> @@ -198,9 +199,9 @@ defmodule BDS.Desktop.ShellLive.SidebarComponents do phx-click="toggle_sidebar_categories" > <%= if @categories_collapsed, do: "▶", else: "▼" %> - <%= translated(@sidebar_filters_config.categories_label) %> + <%= @sidebar_filters_config.categories_label %> <%= if Enum.any?(Map.get(@selected_filters, :categories, [])) do %> - + <% end %>
<%= unless @categories_collapsed do %> @@ -240,7 +241,7 @@ defmodule BDS.Desktop.ShellLive.SidebarComponents do ~H""" """ @@ -266,7 +267,7 @@ defmodule BDS.Desktop.ShellLive.SidebarComponents do
<% else %> <% end %> """ @@ -465,17 +466,17 @@ defmodule BDS.Desktop.ShellLive.SidebarComponents do data-testid="sidebar-open-item" data-route={item.route} data-item-id={item.id} - data-open-title={translated(item.title)} - data-open-subtitle={translated(Map.get(@sidebar_data, :subtitle, ""))} + data-open-title={item.title} + data-open-subtitle={Map.get(@sidebar_data, :subtitle, "")} type="button" phx-click="open_sidebar_item" phx-value-route={item.route} phx-value-id={item.id} - phx-value-title={translated(item.title)} - phx-value-subtitle={translated(Map.get(@sidebar_data, :subtitle, ""))} + phx-value-title={item.title} + phx-value-subtitle={Map.get(@sidebar_data, :subtitle, "")} > <%= Map.get(item, :icon, "") %> - <%= translated(item.title) %> + <%= item.title %> <% end %>
@@ -487,7 +488,7 @@ defmodule BDS.Desktop.ShellLive.SidebarComponents do <%= for section <- Map.get(@sidebar_data, :sections, []) do %> {% endif %} - \ No newline at end of file + diff --git a/priv/data/projects/default/templates/partials/menu.liquid b/priv/data/projects/default/templates/partials/menu.liquid index 5c24b09..5425713 100644 --- a/priv/data/projects/default/templates/partials/menu.liquid +++ b/priv/data/projects/default/templates/partials/menu.liquid @@ -1,7 +1,7 @@ \ No newline at end of file + diff --git a/priv/data/projects/default/templates/post-list.liquid b/priv/data/projects/default/templates/post-list.liquid index 02dcc73..d322d02 100644 --- a/priv/data/projects/default/templates/post-list.liquid +++ b/priv/data/projects/default/templates/post-list.liquid @@ -11,32 +11,30 @@ version: 1 {% render 'partials/head', page_title: page_title, pico_stylesheet_href: pico_stylesheet_href, language_prefix: language_prefix %}
- {% render 'partials/language-switcher', blog_languages: blog_languages, language: language %} + {% render 'partials/language-switcher', blog_languages: blog_languages, language: language, labels: labels %} {% if archive_context %} {% if show_archive_range_heading and min_date and max_date %} {% if archive_context.kind == 'tag' or archive_context.kind == 'category' %}

{{ archive_context.name }} - {{ min_date.day }}.{{ min_date.month }}.{{ min_date.year }} - {{ max_date.day }}.{{ max_date.month }}.{{ max_date.year }}

{% else %} -

{{ 'render.archive' | i18n: language }} {{ min_date.day }}.{{ min_date.month }}.{{ min_date.year }} - {{ max_date.day }}.{{ max_date.month }}.{{ max_date.year }}

+

{{ labels.archive_label }} {{ min_date.day }}.{{ min_date.month }}.{{ min_date.year }} - {{ max_date.day }}.{{ max_date.month }}.{{ max_date.year }}

{% endif %} {% else %} {% if archive_context.kind == 'tag' or archive_context.kind == 'category' %}

{{ archive_context.name }}

{% elsif archive_context.kind == 'month' and archive_context.month and archive_context.year %} - {% assign month_key = 'render.month.' | append: archive_context.month %} -

{{ 'render.archive' | i18n: language }} {{ month_key | i18n: language }} {{ archive_context.year }}

+

{{ labels.archive_label }} {{ archive_month_name }} {{ archive_context.year }}

{% elsif archive_context.kind == 'year' and archive_context.year %} -

{{ 'render.archive' | i18n: language }} {{ archive_context.year }}

+

{{ labels.archive_label }} {{ archive_context.year }}

{% elsif archive_context.kind == 'day' and archive_context.day and archive_context.month and archive_context.year %} - {% assign day_month_key = 'render.month.' | append: archive_context.month %} -

{{ 'render.archive' | i18n: language }} {{ archive_context.day }}. {{ day_month_key | i18n: language }} {{ archive_context.year }}

+

{{ labels.archive_label }} {{ archive_context.day }}. {{ archive_month_name }} {{ archive_context.year }}

{% else %}

{{ page_title }}

{% endif %} {% endif %} {% endif %} - {% render 'partials/menu', menu_items: menu_items, language: language, calendar_initial_year: calendar_initial_year, calendar_initial_month: calendar_initial_month %} + {% render 'partials/menu', menu_items: menu_items, language: language, calendar_initial_year: calendar_initial_year, calendar_initial_month: calendar_initial_month, labels: labels %}
{% for day_block in day_blocks %} @@ -80,15 +78,15 @@ version: 1
{% if has_prev_page or has_next_page %} -