Add i18n files and set first translations

This commit is contained in:
Nicola Benaglia 2025-04-21 13:38:31 +02:00
parent d2a82519ad
commit 3917aef452
8 changed files with 45 additions and 28 deletions

View File

@ -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/<locale>` folder.
See [guidelines](./docs/i18n_languages.md).

10
docs/i18n_languages.md Normal file
View File

@ -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' })}`

View File

@ -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: [

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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}
</Typography>
<>
@ -693,7 +695,7 @@ export const NotAuthenticated = ({
variant="contained"
component="label"
>
Choose custom node
{t('auth:choose_custom_node', { postProcess: 'capitalize' })}
</Button>
</>
<Typography
@ -702,7 +704,8 @@ export const NotAuthenticated = ({
fontSize: '12px',
}}
>
Build version: {manifestData?.version}
{t('auth:build_version', { postProcess: 'capitalize' })}:
{manifestData?.version}
</Typography>
</Box>
</>
@ -788,7 +791,7 @@ export const NotAuthenticated = ({
}}
variant="contained"
>
Choose
{t('core:choose', { postProcess: 'capitalize' })}
</Button>
</Box>
</Box>