feat: complete change to gettext from homebrew i18n solution
This commit is contained in:
@@ -4,8 +4,8 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.AISettings do
|
||||
use Phoenix.Component
|
||||
|
||||
alias BDS.AI
|
||||
alias BDS.Desktop.ShellData
|
||||
alias BDS.Desktop.ShellLive.SettingsEditor.EditorSettings
|
||||
use Gettext, backend: BDS.Gettext
|
||||
|
||||
@spec ai_form(term()) :: term()
|
||||
def ai_form(assigns) do
|
||||
@@ -88,7 +88,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.AISettings do
|
||||
else
|
||||
{:error, reason} ->
|
||||
socket
|
||||
|> append_output.(translated("AI Settings"), inspect(reason), nil, "error")
|
||||
|> append_output.(dgettext("ui", "AI Settings"), inspect(reason), nil, "error")
|
||||
|> reload.(socket.assigns.workbench)
|
||||
end
|
||||
end
|
||||
@@ -153,7 +153,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.AISettings do
|
||||
else
|
||||
{:error, reason} ->
|
||||
socket
|
||||
|> append_output.(translated("AI Settings"), inspect(reason), nil, "error")
|
||||
|> append_output.(dgettext("ui", "AI Settings"), inspect(reason), nil, "error")
|
||||
|> reload.(socket.assigns.workbench)
|
||||
end
|
||||
end
|
||||
@@ -168,7 +168,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.AISettings do
|
||||
|
||||
{:error, reason} ->
|
||||
socket
|
||||
|> append_output.(translated("AI Settings"), inspect(reason), nil, "error")
|
||||
|> append_output.(dgettext("ui", "AI Settings"), inspect(reason), nil, "error")
|
||||
|> reload.(socket.assigns.workbench)
|
||||
end
|
||||
end
|
||||
@@ -315,7 +315,4 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.AISettings do
|
||||
trimmed -> trimmed
|
||||
end
|
||||
end
|
||||
|
||||
defp translated(text, bindings \\ %{}),
|
||||
do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current())
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.EditorSettings do
|
||||
use Phoenix.Component
|
||||
|
||||
alias BDS.Settings
|
||||
alias BDS.Desktop.ShellData
|
||||
use Gettext, backend: BDS.Gettext
|
||||
|
||||
@spec editor_form() :: term()
|
||||
def editor_form do
|
||||
@@ -42,7 +42,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.EditorSettings do
|
||||
else
|
||||
{:error, reason} ->
|
||||
socket
|
||||
|> append_output.(translated("Editor Settings"), inspect(reason), nil, "error")
|
||||
|> append_output.(dgettext("ui", "Editor Settings"), inspect(reason), nil, "error")
|
||||
|> reload.(socket.assigns.workbench)
|
||||
end
|
||||
end
|
||||
@@ -80,7 +80,4 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.EditorSettings do
|
||||
defp truthy?(value), do: value in [true, "true", "on", "1", 1]
|
||||
defp boolean_string(true), do: "true"
|
||||
defp boolean_string(false), do: "false"
|
||||
|
||||
defp translated(text, bindings \\ %{}),
|
||||
do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current())
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.ManagedCategories do
|
||||
use Phoenix.Component
|
||||
|
||||
alias BDS.Metadata
|
||||
alias BDS.Desktop.ShellData
|
||||
use Gettext, backend: BDS.Gettext
|
||||
|
||||
@protected_categories MapSet.new(["article", "aside", "page", "picture"])
|
||||
@default_category_settings %{
|
||||
@@ -56,8 +56,8 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.ManagedCategories do
|
||||
name == "" ->
|
||||
socket
|
||||
|> append_output.(
|
||||
translated("Categories"),
|
||||
translated("Category name is required"),
|
||||
dgettext("ui", "Categories"),
|
||||
dgettext("ui", "Category name is required"),
|
||||
nil,
|
||||
"error"
|
||||
)
|
||||
@@ -72,7 +72,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.ManagedCategories do
|
||||
|
||||
{:error, reason} ->
|
||||
socket
|
||||
|> append_output.(translated("Categories"), inspect(reason), nil, "error")
|
||||
|> append_output.(dgettext("ui", "Categories"), inspect(reason), nil, "error")
|
||||
|> reload.(socket.assigns.workbench)
|
||||
end
|
||||
end
|
||||
@@ -104,7 +104,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.ManagedCategories do
|
||||
else
|
||||
{:error, reason} ->
|
||||
socket
|
||||
|> append_output.(translated("Categories"), inspect(reason), nil, "error")
|
||||
|> append_output.(dgettext("ui", "Categories"), inspect(reason), nil, "error")
|
||||
|> reload.(socket.assigns.workbench)
|
||||
end
|
||||
end
|
||||
@@ -128,7 +128,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.ManagedCategories do
|
||||
|
||||
{:error, reason} ->
|
||||
socket
|
||||
|> append_output.(translated("Categories"), inspect(reason), nil, "error")
|
||||
|> append_output.(dgettext("ui", "Categories"), inspect(reason), nil, "error")
|
||||
|> reload.(socket.assigns.workbench)
|
||||
end
|
||||
end
|
||||
@@ -141,8 +141,8 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.ManagedCategories do
|
||||
MapSet.member?(@protected_categories, category) ->
|
||||
socket
|
||||
|> append_output.(
|
||||
translated("Categories"),
|
||||
translated("Protected categories cannot be removed"),
|
||||
dgettext("ui", "Categories"),
|
||||
dgettext("ui", "Protected categories cannot be removed"),
|
||||
nil,
|
||||
"error"
|
||||
)
|
||||
@@ -155,7 +155,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.ManagedCategories do
|
||||
|
||||
{:error, reason} ->
|
||||
socket
|
||||
|> append_output.(translated("Categories"), inspect(reason), nil, "error")
|
||||
|> append_output.(dgettext("ui", "Categories"), inspect(reason), nil, "error")
|
||||
|> reload.(socket.assigns.workbench)
|
||||
end
|
||||
end
|
||||
@@ -197,7 +197,4 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.ManagedCategories do
|
||||
trimmed -> trimmed
|
||||
end
|
||||
end
|
||||
|
||||
defp translated(text, bindings \\ %{}),
|
||||
do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current())
|
||||
end
|
||||
|
||||
@@ -3,8 +3,8 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.MCPConfig do
|
||||
|
||||
use Phoenix.Component
|
||||
|
||||
alias BDS.Desktop.ShellData
|
||||
alias BDS.MCP.AgentConfig
|
||||
use Gettext, backend: BDS.Gettext
|
||||
|
||||
@mcp_agents [
|
||||
%{id: :claude_code, label: "Claude Code", supported?: true},
|
||||
@@ -47,15 +47,15 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.MCPConfig do
|
||||
|
||||
{:error, reason} ->
|
||||
socket
|
||||
|> append_output.(translated("MCP"), format_config_error(reason), nil, "error")
|
||||
|> append_output.(dgettext("ui", "MCP"), format_config_error(reason), nil, "error")
|
||||
|> reload.(socket.assigns.workbench)
|
||||
end
|
||||
|
||||
_other ->
|
||||
socket
|
||||
|> append_output.(
|
||||
translated("MCP"),
|
||||
translated("This MCP agent is not supported in the rewrite yet"),
|
||||
dgettext("ui", "MCP"),
|
||||
dgettext("ui", "This MCP agent is not supported in the rewrite yet"),
|
||||
nil,
|
||||
"error"
|
||||
)
|
||||
@@ -70,28 +70,28 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.MCPConfig do
|
||||
end
|
||||
|
||||
defp format_config_error({:read_config, path, reason}) do
|
||||
translated("Could not read MCP config %{path}: %{reason}",
|
||||
dgettext("ui", "Could not read MCP config %{path}: %{reason}",
|
||||
path: path,
|
||||
reason: inspect(reason)
|
||||
)
|
||||
end
|
||||
|
||||
defp format_config_error({:write_config, path, reason}) do
|
||||
translated("Could not write MCP config %{path}: %{reason}",
|
||||
dgettext("ui", "Could not write MCP config %{path}: %{reason}",
|
||||
path: path,
|
||||
reason: inspect(reason)
|
||||
)
|
||||
end
|
||||
|
||||
defp format_config_error({:create_config_dir, path, reason}) do
|
||||
translated("Could not create MCP config folder %{path}: %{reason}",
|
||||
dgettext("ui", "Could not create MCP config folder %{path}: %{reason}",
|
||||
path: path,
|
||||
reason: inspect(reason)
|
||||
)
|
||||
end
|
||||
|
||||
defp format_config_error({:decode_config, path, _reason}) do
|
||||
translated("Could not parse MCP config %{path}", path: path)
|
||||
dgettext("ui", "Could not parse MCP config %{path}", path: path)
|
||||
end
|
||||
|
||||
defp mcp_configured?(%{supported?: false}), do: false
|
||||
@@ -124,7 +124,4 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.MCPConfig do
|
||||
|> Map.get("mcpServers", %{})
|
||||
|> Map.has_key?("bDS")
|
||||
end
|
||||
|
||||
defp translated(text, bindings \\ %{}),
|
||||
do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current())
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.ProjectSettings do
|
||||
use Phoenix.Component
|
||||
|
||||
alias BDS.Metadata
|
||||
alias BDS.Desktop.ShellData
|
||||
use Gettext, backend: BDS.Gettext
|
||||
|
||||
@spec project_metadata(term()) :: term()
|
||||
def project_metadata(assigns) do
|
||||
@@ -56,7 +56,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.ProjectSettings do
|
||||
|
||||
{:error, reason} ->
|
||||
socket
|
||||
|> append_output.(translated("Settings"), inspect(reason), nil, "error")
|
||||
|> append_output.(dgettext("ui", "Settings"), inspect(reason), nil, "error")
|
||||
|> reload.(socket.assigns.workbench)
|
||||
end
|
||||
end
|
||||
@@ -111,7 +111,4 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.ProjectSettings do
|
||||
trimmed -> trimmed
|
||||
end
|
||||
end
|
||||
|
||||
defp translated(text, bindings \\ %{}),
|
||||
do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current())
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.PublishingSettings do
|
||||
use Phoenix.Component
|
||||
|
||||
alias BDS.Metadata
|
||||
alias BDS.Desktop.ShellData
|
||||
use Gettext, backend: BDS.Gettext
|
||||
|
||||
@spec publishing_form(term()) :: term()
|
||||
def publishing_form(metadata) do
|
||||
@@ -37,7 +37,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.PublishingSettings do
|
||||
|
||||
{:error, reason} ->
|
||||
socket
|
||||
|> append_output.(translated("Publishing"), inspect(reason), nil, "error")
|
||||
|> append_output.(dgettext("ui", "Publishing"), inspect(reason), nil, "error")
|
||||
|> reload.(socket.assigns.workbench)
|
||||
end
|
||||
end
|
||||
@@ -54,7 +54,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.PublishingSettings do
|
||||
|
||||
{:error, reason} ->
|
||||
socket
|
||||
|> append_output.(translated("Publishing"), inspect(reason), nil, "error")
|
||||
|> append_output.(dgettext("ui", "Publishing"), inspect(reason), nil, "error")
|
||||
|> reload.(socket.assigns.workbench)
|
||||
end
|
||||
end
|
||||
@@ -87,7 +87,4 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.PublishingSettings do
|
||||
trimmed -> trimmed
|
||||
end
|
||||
end
|
||||
|
||||
defp translated(text, bindings \\ %{}),
|
||||
do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current())
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.StyleEditor do
|
||||
use Phoenix.Component
|
||||
|
||||
alias BDS.Metadata
|
||||
alias BDS.Desktop.ShellData
|
||||
use Gettext, backend: BDS.Gettext
|
||||
|
||||
@themes [
|
||||
"default",
|
||||
@@ -71,7 +71,7 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.StyleEditor do
|
||||
|
||||
{:error, reason} ->
|
||||
socket
|
||||
|> append_output.(translated("Style"), inspect(reason), nil, "error")
|
||||
|> append_output.(dgettext("ui", "Style"), inspect(reason), nil, "error")
|
||||
|> reload.(socket.assigns.workbench)
|
||||
end
|
||||
end
|
||||
@@ -104,7 +104,4 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.StyleEditor do
|
||||
dark_bg_color: "#0f172a"
|
||||
}
|
||||
end
|
||||
|
||||
defp translated(text, bindings \\ %{}),
|
||||
do: ShellData.translate(text, bindings, BDS.Desktop.UILocale.current())
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user