From cca6cbcad674a2c865cd94443fd66438b7dc5674 Mon Sep 17 00:00:00 2001 From: Jorge Thomas - Akrista <23145794+Akrista@users.noreply.github.com> Date: Thu, 13 Apr 2023 21:00:10 -0400 Subject: [PATCH] feat: add Spanish Language (#31) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * * 🐳 chore(Dockerfile): add Dockerfile for sqlchat This commit adds a Dockerfile for sqlchat. The Dockerfile is based on Alpine Linux version 3.17 and installs the necessary dependencies for the application to run. The Dockerfile also sets the metadata for the container and copies the application files into the container. The Dockerfile uses pnpm to install the application dependencies and sets the OPENAI_API_KEY and OPENAI_API_ENDPOINT arguments for the container. The CMD instruction specifies the command to run when the container starts, which is to run the application in development mode using pnpm. * * 🌐 feat(LocaleSelector.tsx): add support for Spanish language * 🌐 feat(LocaleSwitch.tsx): add support for switching to Spanish language * 🎨 style(ThemeSwitch.tsx): refactor button JSX for readability The LocaleSelector component now includes an option for Spanish language. The LocaleSwitch component now includes support for switching to Spanish language. The ThemeSwitch component has been refactored to improve readability of the button JSX. * 🌐 feat(i18n.ts): add support for Spanish language A new language, Spanish, has been added to the application. The translations for the new language have been added to the es.json file. The i18n configuration has been updated to include the new language. * ✨ feat(setting.ts): add support for Spanish language The Locale type now includes "es" for Spanish language support. * * 🗑️ chore(Dockerfile): remove Dockerfile The Dockerfile has been removed from the repository. * * 🐛 fix(LocaleSwitch.tsx): fix indentation and add missing semicolon * 🐛 fix(ThemeSwitch.tsx): remove unnecessary code and fix indentation The LocaleSwitch component had an indentation issue and a missing semicolon. The ThemeSwitch component had unnecessary code that was removed, and the indentation was fixed. --- src/components/LocaleSelector.tsx | 4 +++ src/components/LocaleSwitch.tsx | 2 ++ src/locales/es.json | 60 +++++++++++++++++++++++++++++++ src/locales/i18n.ts | 4 +++ src/types/setting.ts | 2 +- 5 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/locales/es.json diff --git a/src/components/LocaleSelector.tsx b/src/components/LocaleSelector.tsx index 151019d..cb49b61 100644 --- a/src/components/LocaleSelector.tsx +++ b/src/components/LocaleSelector.tsx @@ -16,6 +16,10 @@ const localeItemList: LocaleItem[] = [ value: "zh", label: "中文", }, + { + value: "es", + label: "Español", + }, ]; const LocaleSelector = () => { diff --git a/src/components/LocaleSwitch.tsx b/src/components/LocaleSwitch.tsx index 3be9c6b..d09383b 100644 --- a/src/components/LocaleSwitch.tsx +++ b/src/components/LocaleSwitch.tsx @@ -8,6 +8,8 @@ const LocaleSwitch = () => { const handleLocaleChange = () => { if (locale === "en") { settingStore.setLocale("zh"); + } else if (locale === "zh") { + settingStore.setLocale("es"); } else { settingStore.setLocale("en"); } diff --git a/src/locales/es.json b/src/locales/es.json new file mode 100644 index 0000000..6a94127 --- /dev/null +++ b/src/locales/es.json @@ -0,0 +1,60 @@ +{ + "common": { + "clear": "Limpiar", + "close": "Cerrar", + "confirm": "Confirmar", + "save": "Guardar", + "loading": "Cargando", + "setting": "Configuración", + "copy": "Copiar", + "delete": "Borrar" + }, + "conversation": { + "new-chat": "Nuevo Chat", + "conversation-title": "Titulo de conversación", + "edit-title": "Editar Titulo de conversación" + }, + "connection": { + "self": "Conexión", + "new": "Crear Conexión", + "select-database": "Selecciona tu base de datos" + }, + "execution": { + "title": "Ejecutar consulta", + "message": { + "executing": "Ejecutando consulta...", + "no-connection": "No se ha seleccionado una conexión", + "no-data": "No hay datos para mostrar" + } + }, + "editor": { + "placeholder": "Ingresa tu pregunta aquí..." + }, + "setting": { + "self": "Configuración", + "basic": { + "self": "Básico", + "language": "Idioma" + }, + "theme": { + "self": "Tema", + "system": "Usar tema del sistema", + "light": "Claro", + "dark": "Oscuro" + }, + "openai-api-configuration": { + "self": "Configuración del API de OpenAI" + }, + "data": { + "self": "Datos", + "clear-all-data": "Limpiar todos los datos" + } + }, + "social": { + "join-discord-channel": "Unirse al canal de Discord", + "join-wechat-group": "Unirse al grupo de WeChat" + }, + "banner": { + "data-storage": "Las configuraciones de conexión y las consultas se almacenan en tu navegador." + } +} diff --git a/src/locales/i18n.ts b/src/locales/i18n.ts index e72c79d..3c4fd4b 100644 --- a/src/locales/i18n.ts +++ b/src/locales/i18n.ts @@ -2,6 +2,7 @@ import i18n from "i18next"; import { initReactI18next } from "react-i18next"; import enLocale from "./en.json"; import zhLocale from "./zh.json"; +import esLocale from "./es.json"; i18n.use(initReactI18next).init({ resources: { @@ -11,6 +12,9 @@ i18n.use(initReactI18next).init({ zh: { translation: zhLocale, }, + es: { + translation: esLocale, + }, }, fallbackLng: "en", }); diff --git a/src/types/setting.ts b/src/types/setting.ts index cc2c97c..56a9ef1 100644 --- a/src/types/setting.ts +++ b/src/types/setting.ts @@ -1,4 +1,4 @@ -export type Locale = "en" | "zh"; +export type Locale = "en" | "zh" | "es"; export type Theme = "light" | "dark" | "system";