diff --git a/README.md b/README.md index 4a62e6d..34cfbbb 100644 --- a/README.md +++ b/README.md @@ -23,3 +23,5 @@ Many additional details and a fully featured wiki will be created over time. Rea Qortal-Hub supports internationalization (i18n) using [i18next](https://www.i18next.com/), allowing seamless translation of UI text into multiple languages. The setup includes modularized translation files, language detection, context and runtime language switching. Files with translation are in `public/locales/` folder. + +See [guidelines](./docs/i18n_languages.md). diff --git a/docs/i18n_languages.md b/docs/i18n_languages.md new file mode 100644 index 0000000..7447193 --- /dev/null +++ b/docs/i18n_languages.md @@ -0,0 +1,10 @@ +# I18N Guidelines + +In JSON file: + +- Keep the file sorted +- Always write in lowercase + +In GUI: + +- If the first letter of the translation must be uppercase, use the postProcess, for example: `{t_auth('advanced_users', { postProcess: 'capitalize' })}` diff --git a/i18n.js b/i18n.js index 09886c5..6f21518 100644 --- a/i18n.js +++ b/i18n.js @@ -28,7 +28,7 @@ i18n debug: isDev, fallbackLng: 'en', ns: ['auth', 'core'], - supportedLngs: ['en', 'it', 'fr', 'es'], + supportedLngs: ['en', 'it'], backend: { backends: [LocalStorageBackend, HttpBackend], backendOptions: [ diff --git a/public/locales/en/auth.json b/public/locales/en/auth.json index 2c0bd67..d68032f 100644 --- a/public/locales/en/auth.json +++ b/public/locales/en/auth.json @@ -2,9 +2,12 @@ "account_many": "accounts", "account_one": "account", "advanced_users": "for advanced users", + "build_version": "build version", + "change_apikey": "change APIkey", + "choose_custom_node": "choose custom node", "create_account": "create account", - "welcome": "Welcome to", + "import_key": "import APIkey", "use_local_node": "use local node", - "change_apikey": "change API key", - "choose_custom_node": "choose custom node" + "using_node": "using node", + "welcome": "welcome to" } diff --git a/public/locales/en/core.json b/public/locales/en/core.json index d8f5ca1..042d80f 100644 --- a/public/locales/en/core.json +++ b/public/locales/en/core.json @@ -1,9 +1,7 @@ { - "add": { - "task": "Add task" - }, - "cancel": "Cancel", - "description": "Description" , - "save": "Save", - "title": "Title" + "cancel": "cancel", + "choose": "choose", + "description": "description", + "save": "save", + "title": "title" } diff --git a/public/locales/it/auth.json b/public/locales/it/auth.json index c72fbc7..fa99817 100644 --- a/public/locales/it/auth.json +++ b/public/locales/it/auth.json @@ -1,10 +1,13 @@ { "account_many": "account", "account_one": "account", - "advanced_users": "Per utenti avanzati", - "change_apikey": "Cambia la chiave API", - "choose_custom_node": "Scegli un nodo custom", + "advanced_users": "per utenti avanzati", + "build_version": "versione build", + "change_apikey": "cambia la chiave API", + "choose_custom_node": "scegli un nodo custom", "create_account": "crea un account", - "use_local_node": "Usa nodo locale", - "welcome": "Benvenuto in" + "import_key": "importa chiave API", + "use_local_node": "usa nodo locale", + "using_node": "nodo in uso", + "welcome": "benvenuto in" } diff --git a/public/locales/it/core.json b/public/locales/it/core.json index d23032e..2ee28d1 100644 --- a/public/locales/it/core.json +++ b/public/locales/it/core.json @@ -1,9 +1,7 @@ { - "add": { - "task": "Aggiungi compito" - }, - "cancel": "Cancella", - "description": "Descrizione" , - "save": "Salva", - "title": "Titolo" + "cancel": "cancella", + "choose": "scegli", + "description": "descrizione", + "save": "salva", + "title": "titolo" } diff --git a/src/ExtStates/NotAuthenticated.tsx b/src/ExtStates/NotAuthenticated.tsx index f1b8ece..b395a50 100644 --- a/src/ExtStates/NotAuthenticated.tsx +++ b/src/ExtStates/NotAuthenticated.tsx @@ -47,6 +47,7 @@ export const HtmlTooltip = styled(({ className, ...props }: TooltipProps) => ( fontSize: theme.typography.pxToRem(12), }, })); + function removeTrailingSlash(url) { return url.replace(/\/+$/, ''); } @@ -85,7 +86,7 @@ export const NotAuthenticated = ({ React.useState(null); const { showTutorial, hasSeenGettingStarted } = useContext(GlobalContext); const theme = useTheme(); - const { t } = useTranslation('auth'); + const { t } = useTranslation(['auth', 'core']); const importedApiKeyRef = useRef(null); const currentNodeRef = useRef(null); @@ -581,7 +582,8 @@ export const NotAuthenticated = ({ visibility: !useLocalNode && 'hidden', }} > - {'Using node: '} {currentNode?.url} + {t('auth:using_node', { postProcess: 'capitalize' })}:{' '} + {currentNode?.url} <> @@ -693,7 +695,7 @@ export const NotAuthenticated = ({ variant="contained" component="label" > - Choose custom node + {t('auth:choose_custom_node', { postProcess: 'capitalize' })} - Build version: {manifestData?.version} + {t('auth:build_version', { postProcess: 'capitalize' })}: + {manifestData?.version} @@ -788,7 +791,7 @@ export const NotAuthenticated = ({ }} variant="contained" > - Choose + {t('core:choose', { postProcess: 'capitalize' })}