Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1st i18n compatible #1000

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ejemplo_de_cambio_de_idioma
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useTranslation } from 'react-i18next';

function LanguageSwitcher() {
const { i18n } = useTranslation();

const changeLanguage = (lng) => {
i18n.changeLanguage(lng);
};

return (
<div>
<button onClick={() => changeLanguage('en')}>English</button>
<button onClick={() => changeLanguage('es')}>Español</button>
<button onClick={() => changeLanguage('it')}>Italiano</button>
</div>
);
}

export default LanguageSwitcher;
14 changes: 14 additions & 0 deletions ejemplo_de_uso
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useTranslation } from 'react-i18next';

function MyComponent() {
const { t } = useTranslation();

return (
<div>
<h1>{t('common.welcome')}</h1>
<button>{t('common.login')}</button>
</div>
);
}

export default MyComponent;
7 changes: 7 additions & 0 deletions estructura_de_carpetas
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
src/
├── i18n/
│ ├── config.js
│ └── translations/
│ ├── en.json
│ ├── es.json
│ └── it.json
12 changes: 12 additions & 0 deletions src/components/example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useTranslation } from 'react-i18next';

export const ExampleComponent = () => {
const { t } = useTranslation();

return (
<div>
<button>{t('common.save')}</button>
<button>{t('common.cancel')}</button>
</div>
);
};
31 changes: 31 additions & 0 deletions src/i18n/config.js
Original file line number Diff line number Diff line change
@@ -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;
68 changes: 68 additions & 0 deletions src/i18n/translations/en.json
Original file line number Diff line number Diff line change
@@ -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."
}
}
68 changes: 68 additions & 0 deletions src/i18n/translations/es.json
Original file line number Diff line number Diff line change
@@ -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."
}
}
68 changes: 68 additions & 0 deletions src/i18n/translations/it.json
Original file line number Diff line number Diff line change
@@ -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."
}
}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './i18n/config';