From 2db8c5e08e88f1020bb8d55deec90c42ecdb47c4 Mon Sep 17 00:00:00 2001 From: Jhon Felipe Urrego Mejia Date: Sun, 15 Dec 2024 01:26:45 -0500 Subject: [PATCH] 1st i18n compatible --- ejemplo_de_cambio_de_idioma | 19 ++++++++++ ejemplo_de_uso | 14 ++++++++ estructura_de_carpetas | 7 ++++ src/components/example.tsx | 12 +++++++ src/i18n/config.js | 31 ++++++++++++++++ src/i18n/translations/en.json | 68 +++++++++++++++++++++++++++++++++++ src/i18n/translations/es.json | 68 +++++++++++++++++++++++++++++++++++ src/i18n/translations/it.json | 68 +++++++++++++++++++++++++++++++++++ src/index.js | 1 + 9 files changed, 288 insertions(+) create mode 100644 ejemplo_de_cambio_de_idioma create mode 100644 ejemplo_de_uso create mode 100644 estructura_de_carpetas create mode 100644 src/components/example.tsx create mode 100644 src/i18n/config.js create mode 100644 src/i18n/translations/en.json create mode 100644 src/i18n/translations/es.json create mode 100644 src/i18n/translations/it.json create mode 100644 src/index.js diff --git a/ejemplo_de_cambio_de_idioma b/ejemplo_de_cambio_de_idioma new file mode 100644 index 0000000000..abdaba0401 --- /dev/null +++ b/ejemplo_de_cambio_de_idioma @@ -0,0 +1,19 @@ +import { useTranslation } from 'react-i18next'; + +function LanguageSwitcher() { + const { i18n } = useTranslation(); + + const changeLanguage = (lng) => { + i18n.changeLanguage(lng); + }; + + return ( +
+ + + +
+ ); +} + +export default LanguageSwitcher; \ No newline at end of file diff --git a/ejemplo_de_uso b/ejemplo_de_uso new file mode 100644 index 0000000000..b0b59d126a --- /dev/null +++ b/ejemplo_de_uso @@ -0,0 +1,14 @@ +import { useTranslation } from 'react-i18next'; + +function MyComponent() { + const { t } = useTranslation(); + + return ( +
+

{t('common.welcome')}

+ +
+ ); +} + +export default MyComponent; \ No newline at end of file diff --git a/estructura_de_carpetas b/estructura_de_carpetas new file mode 100644 index 0000000000..8b4b73e7cb --- /dev/null +++ b/estructura_de_carpetas @@ -0,0 +1,7 @@ +src/ + ├── i18n/ + │ ├── config.js + │ └── translations/ + │ ├── en.json + │ ├── es.json + │ └── it.json \ No newline at end of file diff --git a/src/components/example.tsx b/src/components/example.tsx new file mode 100644 index 0000000000..b84b5048fc --- /dev/null +++ b/src/components/example.tsx @@ -0,0 +1,12 @@ +import { useTranslation } from 'react-i18next'; + +export const ExampleComponent = () => { + const { t } = useTranslation(); + + return ( +
+ + +
+ ); +}; \ No newline at end of file diff --git a/src/i18n/config.js b/src/i18n/config.js new file mode 100644 index 0000000000..a90c1fa9b9 --- /dev/null +++ b/src/i18n/config.js @@ -0,0 +1,31 @@ +import i18n from 'i18next'; +import { initReactI18next } from 'react-i18next'; + +import translationEN from './translations/en.json'; +import translationES from './translations/es.json'; +import translationIT from './translations/it.json'; + +const resources = { + en: { + translation: translationEN + }, + es: { + translation: translationES + }, + it: { + translation: translationIT + } +}; + +i18n + .use(initReactI18next) + .init({ + resources, + lng: 'en', // idioma por defecto + fallbackLng: 'en', + interpolation: { + escapeValue: false + } + }); + +export default i18n; \ No newline at end of file diff --git a/src/i18n/translations/en.json b/src/i18n/translations/en.json new file mode 100644 index 0000000000..ca02560bee --- /dev/null +++ b/src/i18n/translations/en.json @@ -0,0 +1,68 @@ +{ + "common": { + "welcome": "Welcome", + "login": "Login", + "signup": "Sign Up", + "logout": "Logout", + "cancel": "Cancel", + "save": "Save", + "edit": "Edit", + "delete": "Delete", + "next": "Next", + "finish": "Finish", + "close": "Close", + "submit": "Submit", + "deploy": "Deploy", + "synced": "Synced", + "home": "Home", + "modeling": "Modeling" + }, + "setup": { + "connection": { + "displayName": "Display name", + "host": "Host", + "port": "Port", + "username": "Username", + "password": "Password", + "database": "Database name", + "useSSL": "Use SSL", + "schema": "Schema", + "catalog": "Catalog" + } + }, + "modeling": { + "metadata": { + "title": "Edit metadata", + "name": "Name", + "description": "Description", + "updateSuccess": "Successfully updated model metadata." + }, + "relationships": { + "add": "Add relationship", + "edit": "Update relationship", + "delete": "Delete relationship", + "deleteConfirm": "Are you sure you want to delete this relationship?", + "createSuccess": "Successfully created relationship.", + "updateSuccess": "Successfully updated relationship.", + "deleteSuccess": "Successfully deleted relationship." + }, + "deploy": { + "undeployedChanges": "Undeployed changes", + "deploying": "Deploying..." + } + }, + "views": { + "saveAs": "Save as View", + "saveSuccess": "Successfully created view.", + "updateSuccess": "Successfully updated view metadata.", + "deployNotice": "After saving, make sure you go to \"Modeling Page\" to deploy all saved views." + }, + "calculatedFields": { + "add": "Add calculated field", + "edit": "Edit calculated field", + "delete": "Delete calculated field", + "createSuccess": "Successfully created calculated field.", + "updateSuccess": "Successfully updated calculated field.", + "deleteSuccess": "Successfully deleted calculated field." + } +} \ No newline at end of file diff --git a/src/i18n/translations/es.json b/src/i18n/translations/es.json new file mode 100644 index 0000000000..9fa89f3ccf --- /dev/null +++ b/src/i18n/translations/es.json @@ -0,0 +1,68 @@ +{ + "common": { + "welcome": "Bienvenido", + "login": "Iniciar Sesión", + "signup": "Registrarse", + "logout": "Cerrar Sesión", + "cancel": "Cancelar", + "save": "Guardar", + "edit": "Editar", + "delete": "Eliminar", + "next": "Siguiente", + "finish": "Finalizar", + "close": "Cerrar", + "submit": "Enviar", + "deploy": "Desplegar", + "synced": "Sincronizado", + "home": "Inicio", + "modeling": "Modelado" + }, + "setup": { + "connection": { + "displayName": "Nombre para mostrar", + "host": "Host", + "port": "Puerto", + "username": "Usuario", + "password": "Contraseña", + "database": "Nombre de base de datos", + "useSSL": "Usar SSL", + "schema": "Esquema", + "catalog": "Catálogo" + } + }, + "modeling": { + "metadata": { + "title": "Editar metadatos", + "name": "Nombre", + "description": "Descripción", + "updateSuccess": "Metadatos del modelo actualizados exitosamente." + }, + "relationships": { + "add": "Agregar relación", + "edit": "Actualizar relación", + "delete": "Eliminar relación", + "deleteConfirm": "¿Estás seguro de que deseas eliminar esta relación?", + "createSuccess": "Relación creada exitosamente.", + "updateSuccess": "Relación actualizada exitosamente.", + "deleteSuccess": "Relación eliminada exitosamente." + }, + "deploy": { + "undeployedChanges": "Cambios sin desplegar", + "deploying": "Desplegando..." + } + }, + "views": { + "saveAs": "Guardar como Vista", + "saveSuccess": "Vista creada exitosamente.", + "updateSuccess": "Metadatos de la vista actualizados exitosamente.", + "deployNotice": "Después de guardar, asegúrate de ir a la \"Página de Modelado\" para desplegar todas las vistas guardadas." + }, + "calculatedFields": { + "add": "Agregar campo calculado", + "edit": "Editar campo calculado", + "delete": "Eliminar campo calculado", + "createSuccess": "Campo calculado creado exitosamente.", + "updateSuccess": "Campo calculado actualizado exitosamente.", + "deleteSuccess": "Campo calculado eliminado exitosamente." + } +} \ No newline at end of file diff --git a/src/i18n/translations/it.json b/src/i18n/translations/it.json new file mode 100644 index 0000000000..98d6d40ec9 --- /dev/null +++ b/src/i18n/translations/it.json @@ -0,0 +1,68 @@ +{ + "common": { + "welcome": "Benvenuto", + "login": "Accedi", + "signup": "Registrati", + "logout": "Disconnetti", + "cancel": "Annulla", + "save": "Salva", + "edit": "Modifica", + "delete": "Elimina", + "next": "Avanti", + "finish": "Fine", + "close": "Chiudi", + "submit": "Invia", + "deploy": "Distribuisci", + "synced": "Sincronizzato", + "home": "Home", + "modeling": "Modellazione" + }, + "setup": { + "connection": { + "displayName": "Nome visualizzato", + "host": "Host", + "port": "Porta", + "username": "Nome utente", + "password": "Password", + "database": "Nome database", + "useSSL": "Usa SSL", + "schema": "Schema", + "catalog": "Catalogo" + } + }, + "modeling": { + "metadata": { + "title": "Modifica metadati", + "name": "Nome", + "description": "Descrizione", + "updateSuccess": "Metadati del modello aggiornati con successo." + }, + "relationships": { + "add": "Aggiungi relazione", + "edit": "Aggiorna relazione", + "delete": "Elimina relazione", + "deleteConfirm": "Sei sicuro di voler eliminare questa relazione?", + "createSuccess": "Relazione creata con successo.", + "updateSuccess": "Relazione aggiornata con successo.", + "deleteSuccess": "Relazione eliminata con successo." + }, + "deploy": { + "undeployedChanges": "Modifiche non distribuite", + "deploying": "Distribuzione in corso..." + } + }, + "views": { + "saveAs": "Salva come Vista", + "saveSuccess": "Vista creata con successo.", + "updateSuccess": "Metadati della vista aggiornati con successo.", + "deployNotice": "Dopo il salvataggio, assicurati di andare alla \"Pagina di Modellazione\" per distribuire tutte le viste salvate." + }, + "calculatedFields": { + "add": "Aggiungi campo calcolato", + "edit": "Modifica campo calcolato", + "delete": "Elimina campo calcolato", + "createSuccess": "Campo calcolato creato con successo.", + "updateSuccess": "Campo calcolato aggiornato con successo.", + "deleteSuccess": "Campo calcolato eliminato con successo." + } +} \ No newline at end of file diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000000..c83f9977ad --- /dev/null +++ b/src/index.js @@ -0,0 +1 @@ +import './i18n/config'; \ No newline at end of file