Skip to content

Commit 8550136

Browse files
committed
fix(i18n): migrate Ai.qml and fix OSD.qml i18n calls
OSD.qml: fix i18n.t() -> I18n.t() (lowercase caused empty strings) Ai.qml: migrate hardcoded user-visible strings to I18n.t(): - /model command: model not found, switched to model messages - /help command: full help message - API key missing error (with model name and key_id substitution) - Network request failed error - No response from API message - Command executed successfully (no output) message - Model descriptions for all 6 providers translations: add 13 new keys to en/ru/es (ai.api_key_missing, ai.cmd_no_output, ai.desc_*, ai.env_variable, ai.help_message, ai.model_not_found, ai.network_failed, ai.no_response, ai.switched_to_model)
1 parent ba7342e commit 8550136

5 files changed

Lines changed: 68 additions & 17 deletions

File tree

modules/services/Ai.qml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,16 @@ Singleton {
257257
}
258258
}
259259
if (!found) {
260-
pushSystemMessage("Model '" + args + "' not found.");
260+
pushSystemMessage(I18n.t("ai.model_not_found").replace("%1", args));
261261
} else {
262-
pushSystemMessage("Switched to model: " + currentModel.name);
262+
pushSystemMessage(I18n.t("ai.switched_to_model").replace("%1", currentModel.name));
263263
}
264264
} else {
265265
modelSelectionRequested();
266266
}
267267
return true;
268268
case "/help":
269-
pushSystemMessage("🤖 **Assistant Commands**\n\n" + "**`/new`**\n" + "Starts a fresh conversation context.\n\n" + "**`/model [name]`**\n" + "Switches the active AI model.\n" + "• **List models:** Type `/model` without arguments.\n" + "• **Switch:** Type `/model gemini` or `/model mistral`.\n\n" + "**`/help`**\n" + "Shows this help message.\n\n" + "💡 **Tips:**\n" + "• **Edit:** Click the pen icon on any message to modify it.\n" + "• **Regenerate:** Click the refresh icon to get a new response.\n" + "• **Copy:** Use the copy button to grab code or text.");
269+
pushSystemMessage(I18n.t("ai.help_message"));
270270
return true;
271271
}
272272

@@ -341,7 +341,7 @@ Singleton {
341341
function makeRequest() {
342342
let apiKey = getApiKey(currentModel);
343343
if (!apiKey && currentModel.requires_key) {
344-
lastError = "API Key missing for " + currentModel.name + ". Add it in Settings or set " + (currentModel.key_id || "the environment variable") + ".";
344+
lastError = I18n.t("ai.api_key_missing").replace("%1", currentModel.name).replace("%2", currentModel.key_id || I18n.t("ai.env_variable"));
345345
isLoading = false;
346346

347347
let errChat = Array.from(currentChat);
@@ -531,14 +531,14 @@ Singleton {
531531
let lastMsg = root.currentChat[root.currentChat.length - 1];
532532
if (!lastMsg.content) {
533533
let newChat = Array.from(root.currentChat);
534-
newChat[newChat.length - 1].content = "No response received from the API.";
534+
newChat[newChat.length - 1].content = I18n.t("ai.no_response");
535535
root.currentChat = newChat;
536536
}
537537
}
538538

539539
root.saveCurrentChat();
540540
} else {
541-
root.lastError = "Network Request Failed: " + curlStderr.text;
541+
root.lastError = I18n.t("ai.network_failed").replace("%1", curlStderr.text);
542542

543543
// Update the placeholder message with error
544544
let errChat = Array.from(root.currentChat);
@@ -566,7 +566,7 @@ Singleton {
566566
onExited: exitCode => {
567567
let output = cmdStdout.text + "\n" + cmdStderr.text;
568568
if (output.trim() === "")
569-
output = "Command executed successfully (no output).";
569+
output = I18n.t("ai.cmd_no_output");
570570

571571
let msg = currentChat[targetIndex];
572572
let newChat = Array.from(currentChat);
@@ -791,7 +791,7 @@ for f in files:
791791
let m = aiModelFactory.createObject(root, {
792792
name: item.displayName || id,
793793
icon: Qt.resolvedUrl("../../../assets/aiproviders/google.svg"),
794-
description: item.description || "Google Gemini Model",
794+
description: item.description || I18n.t("ai.desc_google"),
795795
endpoint: "https://generativelanguage.googleapis.com/v1beta",
796796
model: id,
797797
provider: "gemini",
@@ -837,7 +837,7 @@ for f in files:
837837
let m = aiModelFactory.createObject(root, {
838838
name: id,
839839
icon: Qt.resolvedUrl("../../../assets/aiproviders/openai.svg"),
840-
description: "OpenAI Model",
840+
description: I18n.t("ai.desc_openai"),
841841
endpoint: "https://api.openai.com",
842842
model: id,
843843
provider: "openai",
@@ -874,7 +874,7 @@ for f in files:
874874
let m = aiModelFactory.createObject(root, {
875875
name: id,
876876
icon: Qt.resolvedUrl("../../../assets/aiproviders/mistral.svg"),
877-
description: "Mistral Model",
877+
description: I18n.t("ai.desc_mistral"),
878878
endpoint: "https://api.mistral.ai/v1",
879879
model: id,
880880
provider: "mistral",
@@ -910,7 +910,7 @@ for f in files:
910910
let m = aiModelFactory.createObject(root, {
911911
name: id,
912912
icon: Qt.resolvedUrl("../../../assets/aiproviders/groq.svg"),
913-
description: "Groq Model",
913+
description: I18n.t("ai.desc_groq"),
914914
endpoint: "https://api.groq.com/openai/v1",
915915
model: id,
916916
provider: "groq",
@@ -946,7 +946,7 @@ for f in files:
946946
let m = aiModelFactory.createObject(root, {
947947
name: item.display_name || id,
948948
icon: Qt.resolvedUrl("../../../assets/aiproviders/anthropic.svg"),
949-
description: item.description || "Anthropic Model",
949+
description: item.description || I18n.t("ai.desc_anthropic"),
950950
endpoint: "https://api.anthropic.com/v1/messages",
951951
model: id,
952952
provider: "anthropic",
@@ -981,7 +981,7 @@ for f in files:
981981
let m = aiModelFactory.createObject(root, {
982982
name: item.name,
983983
icon: Qt.resolvedUrl("../../../assets/aiproviders/ollama.svg"),
984-
description: "Local Ollama Model",
984+
description: I18n.t("ai.desc_ollama"),
985985
endpoint: "http://127.0.0.1:11434",
986986
model: item.name,
987987
provider: "ollama",

modules/shell/osd/OSD.qml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ PanelWindow {
103103
Text {
104104
text: {
105105
if (GlobalStates.osdIndicator === "volume")
106-
return "Volume";
106+
return I18n.t("osd.volume");
107107
if (GlobalStates.osdIndicator === "mic")
108-
return "Microphone";
108+
return I18n.t("osd.mic");
109109
if (GlobalStates.osdIndicator === "brightness")
110-
return "Brightness";
110+
return I18n.t("osd.brightness");
111111
return "";
112112
}
113113
font.family: Config.theme.font

translations/en.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
{
22
"_meta.direction": "ltr",
3+
"ai.api_key_missing": "API Key missing for %1. Add it in Settings or set %2.",
34
"ai.approve": "Approve",
45
"ai.ask_or_help": "Ask AI or type /help...",
56
"ai.chat_history": "Chat History",
7+
"ai.cmd_no_output": "Command executed successfully (no output).",
68
"ai.cmd_set_api_key": "Set API key",
79
"ai.cmd_set_system_prompt": "Set system prompt",
810
"ai.cmd_show_help": "Show help",
911
"ai.cmd_start_new_chat": "Start new chat",
1012
"ai.cmd_switch_model": "Switch AI model",
1113
"ai.command_approved": "Command Approved",
1214
"ai.command_rejected": "Command Rejected",
15+
"ai.desc_anthropic": "Anthropic Model",
16+
"ai.desc_google": "Google Gemini Model",
17+
"ai.desc_groq": "Groq Model",
18+
"ai.desc_mistral": "Mistral Model",
19+
"ai.desc_ollama": "Local Ollama Model",
20+
"ai.desc_openai": "OpenAI Model",
21+
"ai.env_variable": "the environment variable",
1322
"ai.curl_placeholder": "curl -X POST...",
1423
"ai.curl_placeholders": "Placeholders: {{ENDPOINT}}, {{API_KEY}}, {{BODY_PATH}}",
1524
"ai.custom_curl": "Custom cURL Template",
@@ -18,13 +27,18 @@
1827
"ai.custom_provider_key": "Custom Provider API Key",
1928
"ai.endpoint_placeholder": "e.g. https://...",
2029
"ai.enter_api_key": "Enter API Key...",
30+
"ai.help_message": "🤖 **Assistant Commands**\n\n**`/new`**\nStarts a fresh conversation context.\n\n**`/model [name]`**\nSwitches the active AI model.\n- **List models:** Type `/model` without arguments.\n- **Switch:** Type `/model gemini` or `/model mistral`.\n\n**`/help`**\nShows this help message.\n\n💡 **Tips:**\n- **Edit:** Click the pen icon on any message to modify it.\n- **Regenerate:** Click the refresh icon to get a new response.\n- **Copy:** Use the copy button to grab code or text.",
2131
"ai.hello_user": "Hello, %1.",
32+
"ai.model_not_found": "Model '%1' not found.",
2233
"ai.message": "Message AI...",
34+
"ai.network_failed": "Network Request Failed: %1",
35+
"ai.no_response": "No response received from the API.",
2336
"ai.panel_title": "AI & API Keys",
2437
"ai.refresh_models": "Refresh?",
2538
"ai.reject": "Reject",
2639
"ai.run_command": "Run Command",
2740
"ai.search_models": "Search models...",
41+
"ai.switched_to_model": "Switched to model: %1",
2842
"bar.tooltip.audio_switcher": "Audio Device Switcher",
2943
"bar.tooltip.controls": "Audio & Brightness Controls",
3044
"bar.tooltip.keyboard_layout": "Keyboard Layout",
@@ -247,6 +261,9 @@
247261
"notifications.now": "Now",
248262
"notifications.panel_title": "Notifications",
249263
"notifications.yesterday": "Yesterday",
264+
"osd.brightness": "Brightness",
265+
"osd.mic": "Microphone",
266+
"osd.volume": "Volume",
250267
"overview.search": "Search windows...",
251268
"performance.blur_transition": "Blur Transition",
252269
"performance.dashboard_persist": "Persist Dashboard Tabs",

translations/es.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
{
22
"_meta.direction": "ltr",
3+
"ai.api_key_missing": "Falta la clave API para %1. Agrégala en Configuración o establece %2.",
34
"ai.approve": "Aprobar",
45
"ai.ask_or_help": "Pregunta al AI o escribe /help...",
56
"ai.chat_history": "Historial de chat",
7+
"ai.cmd_no_output": "Comando ejecutado correctamente (sin salida).",
68
"ai.cmd_set_api_key": "Establecer clave API",
79
"ai.cmd_set_system_prompt": "Establecer prompt del sistema",
810
"ai.cmd_show_help": "Mostrar ayuda",
911
"ai.cmd_start_new_chat": "Iniciar nuevo chat",
1012
"ai.cmd_switch_model": "Cambiar modelo de AI",
1113
"ai.command_approved": "Comando aprobado",
1214
"ai.command_rejected": "Comando rechazado",
15+
"ai.desc_anthropic": "Modelo de Anthropic",
16+
"ai.desc_google": "Modelo de Google Gemini",
17+
"ai.desc_groq": "Modelo de Groq",
18+
"ai.desc_mistral": "Modelo de Mistral",
19+
"ai.desc_ollama": "Modelo local de Ollama",
20+
"ai.desc_openai": "Modelo de OpenAI",
21+
"ai.env_variable": "la variable de entorno",
1322
"ai.curl_placeholder": "curl -X POST...",
1423
"ai.curl_placeholders": "Marcadores: {{ENDPOINT}}, {{API_KEY}}, {{BODY_PATH}}",
1524
"ai.custom_curl": "Plantilla cURL personalizada",
@@ -18,13 +27,18 @@
1827
"ai.custom_provider_key": "Clave API del proveedor personalizado",
1928
"ai.endpoint_placeholder": "ej. https://...",
2029
"ai.enter_api_key": "Ingresar clave API...",
30+
"ai.help_message": "🤖 **Comandos del asistente**\n\n**`/new`**\nInicia un nuevo contexto de conversación.\n\n**`/model [nombre]`**\nCambia el modelo de AI activo.\n- **Lista de modelos:** Escribe `/model` sin argumentos.\n- **Cambiar:** Escribe `/model gemini` o `/model mistral`.\n\n**`/help`**\nMuestra este mensaje de ayuda.\n\n💡 **Consejos:**\n- **Editar:** Haz clic en el ícono de lápiz en cualquier mensaje.\n- **Regenerar:** Haz clic en el ícono de actualizar para obtener una nueva respuesta.\n- **Copiar:** Usa el botón de copiar para código o texto.",
2131
"ai.hello_user": "Hola, %1.",
32+
"ai.model_not_found": "Modelo '%1' no encontrado.",
2233
"ai.message": "Mensaje al AI...",
34+
"ai.network_failed": "Error de red: %1",
35+
"ai.no_response": "La API no devolvió ninguna respuesta.",
2336
"ai.panel_title": "AI y claves API",
2437
"ai.refresh_models": "¿Actualizar?",
2538
"ai.reject": "Rechazar",
2639
"ai.run_command": "Ejecutar comando",
2740
"ai.search_models": "Buscar modelos...",
41+
"ai.switched_to_model": "Modelo cambiado: %1",
2842
"bar.tooltip.audio_switcher": "Selector de dispositivo de audio",
2943
"bar.tooltip.controls": "Controles de audio y brillo",
3044
"bar.tooltip.keyboard_layout": "Disposición del teclado",
@@ -247,6 +261,9 @@
247261
"notifications.now": "Ahora",
248262
"notifications.panel_title": "Notificaciones",
249263
"notifications.yesterday": "Ayer",
264+
"osd.brightness": "Brillo",
265+
"osd.mic": "Micrófono",
266+
"osd.volume": "Volumen",
250267
"overview.search": "Buscar ventanas...",
251268
"performance.blur_transition": "Transición de desenfoque",
252269
"performance.dashboard_persist": "Mantener pestañas del panel",

translations/ru.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
{
22
"_meta.direction": "ltr",
3+
"ai.api_key_missing": "API-ключ отсутствует для %1. Добавьте его в настройках или задайте %2.",
34
"ai.approve": "Одобрить",
45
"ai.ask_or_help": "Спросите AI или введите /help...",
56
"ai.chat_history": "История чата",
7+
"ai.cmd_no_output": "Команда выполнена успешно (вывод отсутствует).",
68
"ai.cmd_set_api_key": "Установить API ключ",
79
"ai.cmd_set_system_prompt": "Установить системный промпт",
810
"ai.cmd_show_help": "Показать справку",
911
"ai.cmd_start_new_chat": "Начать новый чат",
1012
"ai.cmd_switch_model": "Переключить модель AI",
1113
"ai.command_approved": "Команда одобрена",
1214
"ai.command_rejected": "Команда отклонена",
15+
"ai.desc_anthropic": "Модель Anthropic",
16+
"ai.desc_google": "Модель Google Gemini",
17+
"ai.desc_groq": "Модель Groq",
18+
"ai.desc_mistral": "Модель Mistral",
19+
"ai.desc_ollama": "Локальная модель Ollama",
20+
"ai.desc_openai": "Модель OpenAI",
21+
"ai.env_variable": "переменную окружения",
1322
"ai.curl_placeholder": "curl -X POST...",
1423
"ai.curl_placeholders": "Заполнители: {{ENDPOINT}}, {{API_KEY}}, {{BODY_PATH}}",
1524
"ai.custom_curl": "Пользовательский шаблон cURL",
@@ -18,13 +27,18 @@
1827
"ai.custom_provider_key": "API-ключ пользовательского провайдера",
1928
"ai.endpoint_placeholder": "например, https://...",
2029
"ai.enter_api_key": "Введите API-ключ...",
30+
"ai.help_message": "🤖 **Команды ассистента**\n\n**`/new`**\nНачинает новый контекст разговора.\n\n**`/model [название]`**\nПереключает активную модель AI.\n- **Список моделей:** Введите `/model` без аргументов.\n- **Переключение:** Введите `/model gemini` или `/model mistral`.\n\n**`/help`**\nПоказывает это сообщение.\n\n💡 **Советы:**\n- **Редактировать:** Нажмите на значок карандаша у любого сообщения.\n- **Повторить:** Нажмите на значок обновления для нового ответа.\n- **Копировать:** Используйте кнопку копирования для кода или текста.",
2131
"ai.hello_user": "Привет, %1.",
32+
"ai.model_not_found": "Модель '%1' не найдена.",
2233
"ai.message": "Сообщение AI...",
34+
"ai.network_failed": "Ошибка сети: %1",
35+
"ai.no_response": "API не вернул ответ.",
2336
"ai.panel_title": "AI и API-ключи",
2437
"ai.refresh_models": "Обновить?",
2538
"ai.reject": "Отклонить",
2639
"ai.run_command": "Выполнить команду",
2740
"ai.search_models": "Поиск моделей...",
41+
"ai.switched_to_model": "Модель переключена: %1",
2842
"bar.tooltip.audio_switcher": "Переключатель аудиоустройств",
2943
"bar.tooltip.controls": "Управление звуком и яркостью",
3044
"bar.tooltip.keyboard_layout": "Раскладка клавиатуры",
@@ -247,6 +261,9 @@
247261
"notifications.now": "Сейчас",
248262
"notifications.panel_title": "Уведомления",
249263
"notifications.yesterday": "Вчера",
264+
"osd.brightness": "Яркость",
265+
"osd.mic": "Микрофон",
266+
"osd.volume": "Громкость",
250267
"overview.search": "Поиск окон...",
251268
"performance.blur_transition": "Переход размытия",
252269
"performance.dashboard_persist": "Сохранять вкладки панели управления",
@@ -406,7 +423,7 @@
406423
"settings.system.blur_transition": "Переход размытия",
407424
"settings.system.clipboard_prefix": "Префикс буфера обмена",
408425
"settings.system.emoji_prefix": "Префикс эмодзи",
409-
"settings.system.idle": "Простой",
426+
"settings.system.idle": "Простой (Idle)",
410427
"settings.system.idle_listener": "Слушатель простоя",
411428
"settings.system.idle_settings": "Настройки простоя",
412429
"settings.system.language": "Язык",

0 commit comments

Comments
 (0)