feat: complete change to gettext from homebrew i18n solution
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user