Add language to frontend settings & correct some translations

This commit is contained in:
Jelcoo
2025-11-13 15:25:12 +01:00
committed by Jamie Curnow
parent 2c6d614597
commit c2177abe39
3 changed files with 29 additions and 10 deletions

View File

@@ -15,6 +15,7 @@ const allLocales = [
["zh", "zh-CN"], ["zh", "zh-CN"],
["pl", "pl-PL"], ["pl", "pl-PL"],
["it", "it-IT"], ["it", "it-IT"],
["nl", "nl-NL"],
]; ];
const ignoreUnused = [ const ignoreUnused = [

View File

@@ -2,14 +2,15 @@ import { createIntl, createIntlCache } from "react-intl";
import langDe from "./lang/de.json"; import langDe from "./lang/de.json";
import langEn from "./lang/en.json"; import langEn from "./lang/en.json";
import langEs from "./lang/es.json"; import langEs from "./lang/es.json";
import langIt from "./lang/it.json";
import langJa from "./lang/ja.json"; import langJa from "./lang/ja.json";
import langList from "./lang/lang-list.json"; import langList from "./lang/lang-list.json";
import langNl from "./lang/nl.json";
import langPl from "./lang/pl.json";
import langRu from "./lang/ru.json"; import langRu from "./lang/ru.json";
import langSk from "./lang/sk.json"; import langSk from "./lang/sk.json";
import langZh from "./lang/zh.json";
import langPl from "./lang/pl.json";
import langIt from "./lang/it.json";
import langVi from "./lang/vi.json"; import langVi from "./lang/vi.json";
import langZh from "./lang/zh.json";
// first item of each array should be the language code, // first item of each array should be the language code,
// not the country code // not the country code
@@ -25,6 +26,7 @@ const localeOptions = [
["pl", "pl-PL"], ["pl", "pl-PL"],
["it", "it-IT"], ["it", "it-IT"],
["vi", "vi-VN"], ["vi", "vi-VN"],
["nl", "nl-NL"],
]; ];
const loadMessages = (locale?: string): typeof langList & typeof langEn => { const loadMessages = (locale?: string): typeof langList & typeof langEn => {
@@ -48,6 +50,8 @@ const loadMessages = (locale?: string): typeof langList & typeof langEn => {
return Object.assign({}, langList, langEn, langIt); return Object.assign({}, langList, langEn, langIt);
case "vi": case "vi":
return Object.assign({}, langList, langEn, langVi); return Object.assign({}, langList, langEn, langVi);
case "nl":
return Object.assign({}, langList, langEn, langNl);
default: default:
return Object.assign({}, langList, langEn); return Object.assign({}, langList, langEn);
} }
@@ -82,6 +86,9 @@ const getFlagCodeForLocale = (locale?: string) => {
case "vi": case "vi":
case "vi-VN": case "vi-VN":
return "VN"; return "VN";
case "nl":
case "nl-NL":
return "NL";
default: default:
return "EN"; return "EN";
} }
@@ -105,7 +112,10 @@ const getLocale = (short = false) => {
const cache = createIntlCache(); const cache = createIntlCache();
const initialMessages = loadMessages(getLocale()); const initialMessages = loadMessages(getLocale());
let intl = createIntl({ locale: getLocale(), messages: initialMessages }, cache); let intl = createIntl(
{ locale: getLocale(), messages: initialMessages },
cache,
);
const changeLocale = (locale: string): void => { const changeLocale = (locale: string): void => {
const messages = loadMessages(locale); const messages = loadMessages(locale);
@@ -145,4 +155,12 @@ const T = ({
); );
}; };
export { localeOptions, getFlagCodeForLocale, getLocale, createIntl, changeLocale, intl, T }; export {
localeOptions,
getFlagCodeForLocale,
getLocale,
createIntl,
changeLocale,
intl,
T,
};

View File

@@ -126,7 +126,7 @@
"defaultMessage": "Laat leeg om de standaardwaarde van de plugin te gebruiken. Aantal seconden om te wachten op DNS propagatie." "defaultMessage": "Laat leeg om de standaardwaarde van de plugin te gebruiken. Aantal seconden om te wachten op DNS propagatie."
}, },
"certificates.dns.provider": { "certificates.dns.provider": {
"defaultMessage": "DNS Aanbieder" "defaultMessage": "DNS Provider"
}, },
"certificates.dns.warning": { "certificates.dns.warning": {
"defaultMessage": "Deze sectie vereist wat informatie over Certbot en zijn DNS plugins. Gebruik de documentatie van de bijbehorende plugins." "defaultMessage": "Deze sectie vereist wat informatie over Certbot en zijn DNS plugins. Gebruik de documentatie van de bijbehorende plugins."
@@ -201,7 +201,7 @@
"defaultMessage": "Protocol" "defaultMessage": "Protocol"
}, },
"column.provider": { "column.provider": {
"defaultMessage": "Aanbieder" "defaultMessage": "Provider"
}, },
"column.roles": { "column.roles": {
"defaultMessage": "Rollen" "defaultMessage": "Rollen"
@@ -504,7 +504,7 @@
"defaultMessage": "Openbaar" "defaultMessage": "Openbaar"
}, },
"redirection-host": { "redirection-host": {
"defaultMessage": "Omleiding Host" "defaultMessage": "Redirection Host"
}, },
"redirection-host.forward-domain": { "redirection-host.forward-domain": {
"defaultMessage": "Doorgestuurd Domein" "defaultMessage": "Doorgestuurd Domein"
@@ -513,10 +513,10 @@
"defaultMessage": "HTTP Code" "defaultMessage": "HTTP Code"
}, },
"redirection-hosts": { "redirection-hosts": {
"defaultMessage": "Omleiding Hosts" "defaultMessage": "Redirection Hosts"
}, },
"redirection-hosts.count": { "redirection-hosts.count": {
"defaultMessage": "{count} {count, plural, one {Omleiding Host} other {Omleiding Hosts}}" "defaultMessage": "{count} {count, plural, one {Redirection Host} other {Redirection Hosts}}"
}, },
"role.admin": { "role.admin": {
"defaultMessage": "Beheerder" "defaultMessage": "Beheerder"