mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-11-08 03:15:14 +00:00
React
This commit is contained in:
64
frontend/src/locale/IntlProvider.tsx
Normal file
64
frontend/src/locale/IntlProvider.tsx
Normal file
@@ -0,0 +1,64 @@
|
||||
import { createIntl, createIntlCache } from "react-intl";
|
||||
import langDe from "./lang/de.json";
|
||||
import langEn from "./lang/en.json";
|
||||
import langFa from "./lang/fa.json";
|
||||
import langList from "./lang/lang-list.json";
|
||||
|
||||
// first item of each array should be the language code,
|
||||
// not the country code
|
||||
// Remember when adding to this list, also update check-locales.js script
|
||||
const localeOptions = [
|
||||
["en", "en-US"],
|
||||
["de", "de-DE"],
|
||||
["fa", "fa-IR"],
|
||||
];
|
||||
|
||||
const loadMessages = (locale?: string): typeof langList & typeof langEn => {
|
||||
const thisLocale = locale || "en";
|
||||
switch (thisLocale.slice(0, 2)) {
|
||||
case "de":
|
||||
return Object.assign({}, langList, langEn, langDe);
|
||||
case "fa":
|
||||
return Object.assign({}, langList, langEn, langFa);
|
||||
default:
|
||||
return Object.assign({}, langList, langEn);
|
||||
}
|
||||
};
|
||||
|
||||
const getFlagCodeForLocale = (locale?: string) => {
|
||||
switch (locale) {
|
||||
case "de-DE":
|
||||
case "de":
|
||||
return "DE";
|
||||
case "fa-IR":
|
||||
case "fa":
|
||||
return "IR";
|
||||
default:
|
||||
return "EN";
|
||||
}
|
||||
};
|
||||
|
||||
const getLocale = (short = false) => {
|
||||
let loc = window.localStorage.getItem("locale");
|
||||
if (!loc) {
|
||||
loc = document.documentElement.lang;
|
||||
}
|
||||
if (short) {
|
||||
return loc.slice(0, 2);
|
||||
}
|
||||
return loc;
|
||||
};
|
||||
|
||||
const cache = createIntlCache();
|
||||
|
||||
const initialMessages = loadMessages(getLocale());
|
||||
let intl = createIntl({ locale: getLocale(), messages: initialMessages }, cache);
|
||||
|
||||
const changeLocale = (locale: string): void => {
|
||||
const messages = loadMessages(locale);
|
||||
intl = createIntl({ locale, messages }, cache);
|
||||
window.localStorage.setItem("locale", locale);
|
||||
document.documentElement.lang = locale;
|
||||
};
|
||||
|
||||
export { localeOptions, getFlagCodeForLocale, getLocale, createIntl, changeLocale, intl };
|
||||
23
frontend/src/locale/README.md
Normal file
23
frontend/src/locale/README.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# Internationalisation support
|
||||
|
||||
## Adding new translations
|
||||
|
||||
Modify the files in the `src` folder. Follow the conventions already there.
|
||||
|
||||
|
||||
## After making changes
|
||||
|
||||
You will need to run `yarn locale-compile` in this frontend folder for
|
||||
the new translations to be compiled into the `lang` folder.
|
||||
|
||||
When running in dev mode, this should automatically happen within Vite.
|
||||
|
||||
|
||||
## Checking for missing translations in other languages
|
||||
|
||||
Run `node check-locales.cjs` in this frontend folder.
|
||||
|
||||
|
||||
## Adding new languages
|
||||
|
||||
todo
|
||||
1
frontend/src/locale/index.ts
Normal file
1
frontend/src/locale/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./IntlProvider";
|
||||
3
frontend/src/locale/lang/de.json
Normal file
3
frontend/src/locale/lang/de.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"dashboard.title": "Armaturenbrett"
|
||||
}
|
||||
92
frontend/src/locale/lang/en.json
Normal file
92
frontend/src/locale/lang/en.json
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"access.access-count": "{count} Rules",
|
||||
"access.actions-title": "Access List #{id}",
|
||||
"access.add": "Add Access List",
|
||||
"access.auth-count": "{count} Users",
|
||||
"access.empty": "There are no Access Lists",
|
||||
"access.satisfy-all": "All",
|
||||
"access.satisfy-any": "Any",
|
||||
"access.title": "Access",
|
||||
"action.delete": "Delete",
|
||||
"action.disable": "Disable",
|
||||
"action.edit": "Edit",
|
||||
"action.enable": "Enable",
|
||||
"action.permissions": "Permissions",
|
||||
"administrator": "Administrator",
|
||||
"auditlog.title": "Audit Log",
|
||||
"cancel": "Cancel",
|
||||
"certificates.title": "SSL Certificates",
|
||||
"column.access": "Access",
|
||||
"column.authorization": "Authorization",
|
||||
"column.destination": "Destination",
|
||||
"column.email": "Email",
|
||||
"column.http-code": "Access",
|
||||
"column.incoming-port": "Incoming Port",
|
||||
"column.name": "Name",
|
||||
"column.protocol": "Protocol",
|
||||
"column.roles": "Roles",
|
||||
"column.satisfy": "Satisfy",
|
||||
"column.scheme": "Scheme",
|
||||
"column.source": "Source",
|
||||
"column.ssl": "SSL",
|
||||
"column.status": "Status",
|
||||
"created-on": "Created: {date}",
|
||||
"dashboard.title": "Dashboard",
|
||||
"dead-hosts.actions-title": "404 Host #{id}",
|
||||
"dead-hosts.add": "Add 404 Host",
|
||||
"dead-hosts.count": "{count} 404 Hosts",
|
||||
"dead-hosts.empty": "There are no 404 Hosts",
|
||||
"dead-hosts.title": "404 Hosts",
|
||||
"email-address": "Email address",
|
||||
"empty-subtitle": "Why don't you create one?",
|
||||
"error.invalid-auth": "Invalid email or password",
|
||||
"error.passwords-must-match": "Passwords must match",
|
||||
"footer.github-fork": "Fork me on Github",
|
||||
"hosts.title": "Hosts",
|
||||
"http-only": "HTTP Only",
|
||||
"lets-encrypt": "Let's Encrypt",
|
||||
"loading": "Loading…",
|
||||
"login.title": "Login to your account",
|
||||
"no-permission-error": "You do not have access to view this.",
|
||||
"notfound.action": "Take me home",
|
||||
"notfound.text": "We are sorry but the page you are looking for was not found",
|
||||
"notfound.title": "Oops… You just found an error page",
|
||||
"offline": "Offline",
|
||||
"online": "Online",
|
||||
"password": "Password",
|
||||
"proxy-hosts.actions-title": "Proxy Host #{id}",
|
||||
"proxy-hosts.add": "Add Proxy Host",
|
||||
"proxy-hosts.count": "{count} Proxy Hosts",
|
||||
"proxy-hosts.empty": "There are no Proxy Hosts",
|
||||
"proxy-hosts.title": "Proxy Hosts",
|
||||
"redirection-hosts.actions-title": "Redirection Host #{id}",
|
||||
"redirection-hosts.add": "Add Redirection Host",
|
||||
"redirection-hosts.count": "{count} Redirection Hosts",
|
||||
"redirection-hosts.empty": "There are no Redirection Hosts",
|
||||
"redirection-hosts.title": "Redirection Hosts",
|
||||
"save": "Save",
|
||||
"settings.title": "Settings",
|
||||
"sign-in": "Sign in",
|
||||
"standard-user": "Apache Helicopter",
|
||||
"streams.actions-title": "Stream #{id}",
|
||||
"streams.add": "Add Stream",
|
||||
"streams.count": "{count} Streams",
|
||||
"streams.empty": "There are no Streams",
|
||||
"streams.tcp": "TCP",
|
||||
"streams.title": "Streams",
|
||||
"streams.udp": "UDP",
|
||||
"user.change-password": "Change Password",
|
||||
"user.confirm-password": "Confirm Password",
|
||||
"user.current-password": "Current Password",
|
||||
"user.edit": "Edit User",
|
||||
"user.edit-profile": "Edit Profile",
|
||||
"user.full-name": "Full Name",
|
||||
"user.logout": "Logout",
|
||||
"user.new-password": "New Password",
|
||||
"user.nickname": "Nickname",
|
||||
"user.switch-dark": "Switch to Dark mode",
|
||||
"user.switch-light": "Switch to Light mode",
|
||||
"users.actions-title": "User #{id}",
|
||||
"users.add": "Add User",
|
||||
"users.title": "Users"
|
||||
}
|
||||
3
frontend/src/locale/lang/fa.json
Normal file
3
frontend/src/locale/lang/fa.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"dashboard.title": "داشبورد"
|
||||
}
|
||||
5
frontend/src/locale/lang/lang-list.json
Normal file
5
frontend/src/locale/lang/lang-list.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"locale-de-DE": "Deutsch",
|
||||
"locale-en-US": "English",
|
||||
"locale-fa-IR": "فارسی"
|
||||
}
|
||||
5
frontend/src/locale/src/de.json
Normal file
5
frontend/src/locale/src/de.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"dashboard.title": {
|
||||
"defaultMessage": "Armaturenbrett"
|
||||
}
|
||||
}
|
||||
272
frontend/src/locale/src/en.json
Normal file
272
frontend/src/locale/src/en.json
Normal file
@@ -0,0 +1,272 @@
|
||||
{
|
||||
"access.actions-title": {
|
||||
"defaultMessage": "Access List #{id}"
|
||||
},
|
||||
"access.access-count": {
|
||||
"defaultMessage": "{count} Rules"
|
||||
},
|
||||
"access.add": {
|
||||
"defaultMessage": "Add Access List"
|
||||
},
|
||||
"access.auth-count": {
|
||||
"defaultMessage": "{count} Users"
|
||||
},
|
||||
"access.empty": {
|
||||
"defaultMessage": "There are no Access Lists"
|
||||
},
|
||||
"access.satisfy-all": {
|
||||
"defaultMessage": "All"
|
||||
},
|
||||
"access.satisfy-any": {
|
||||
"defaultMessage": "Any"
|
||||
},
|
||||
"access.title": {
|
||||
"defaultMessage": "Access"
|
||||
},
|
||||
"action.delete": {
|
||||
"defaultMessage": "Delete"
|
||||
},
|
||||
"action.disable": {
|
||||
"defaultMessage": "Disable"
|
||||
},
|
||||
"action.enable": {
|
||||
"defaultMessage": "Enable"
|
||||
},
|
||||
"action.edit": {
|
||||
"defaultMessage": "Edit"
|
||||
},
|
||||
"action.permissions": {
|
||||
"defaultMessage": "Permissions"
|
||||
},
|
||||
"administrator": {
|
||||
"defaultMessage": "Administrator"
|
||||
},
|
||||
"auditlog.title": {
|
||||
"defaultMessage": "Audit Log"
|
||||
},
|
||||
"cancel": {
|
||||
"defaultMessage": "Cancel"
|
||||
},
|
||||
"certificates.title": {
|
||||
"defaultMessage": "SSL Certificates"
|
||||
},
|
||||
"created-on": {
|
||||
"defaultMessage": "Created: {date}"
|
||||
},
|
||||
"column.access": {
|
||||
"defaultMessage": "Access"
|
||||
},
|
||||
"column.authorization": {
|
||||
"defaultMessage": "Authorization"
|
||||
},
|
||||
"column.destination": {
|
||||
"defaultMessage": "Destination"
|
||||
},
|
||||
"column.email": {
|
||||
"defaultMessage": "Email"
|
||||
},
|
||||
"column.http-code": {
|
||||
"defaultMessage": "Access"
|
||||
},
|
||||
"column.incoming-port": {
|
||||
"defaultMessage": "Incoming Port"
|
||||
},
|
||||
"column.name": {
|
||||
"defaultMessage": "Name"
|
||||
},
|
||||
"column.protocol": {
|
||||
"defaultMessage": "Protocol"
|
||||
},
|
||||
"column.roles": {
|
||||
"defaultMessage": "Roles"
|
||||
},
|
||||
"column.satisfy": {
|
||||
"defaultMessage": "Satisfy"
|
||||
},
|
||||
"column.scheme": {
|
||||
"defaultMessage": "Scheme"
|
||||
},
|
||||
"column.status": {
|
||||
"defaultMessage": "Status"
|
||||
},
|
||||
"column.ssl": {
|
||||
"defaultMessage": "SSL"
|
||||
},
|
||||
"column.source": {
|
||||
"defaultMessage": "Source"
|
||||
},
|
||||
"dashboard.title": {
|
||||
"defaultMessage": "Dashboard"
|
||||
},
|
||||
"dead-hosts.actions-title": {
|
||||
"defaultMessage": "404 Host #{id}"
|
||||
},
|
||||
"dead-hosts.add": {
|
||||
"defaultMessage": "Add 404 Host"
|
||||
},
|
||||
"dead-hosts.count": {
|
||||
"defaultMessage": "{count} 404 Hosts"
|
||||
},
|
||||
"dead-hosts.empty": {
|
||||
"defaultMessage": "There are no 404 Hosts"
|
||||
},
|
||||
"dead-hosts.title": {
|
||||
"defaultMessage": "404 Hosts"
|
||||
},
|
||||
"email-address": {
|
||||
"defaultMessage": "Email address"
|
||||
},
|
||||
"error.passwords-must-match": {
|
||||
"defaultMessage": "Passwords must match"
|
||||
},
|
||||
"error.invalid-auth": {
|
||||
"defaultMessage": "Invalid email or password"
|
||||
},
|
||||
"footer.github-fork": {
|
||||
"defaultMessage": "Fork me on Github"
|
||||
},
|
||||
"empty-subtitle": {
|
||||
"defaultMessage": "Why don't you create one?"
|
||||
},
|
||||
"hosts.title": {
|
||||
"defaultMessage": "Hosts"
|
||||
},
|
||||
"http-only": {
|
||||
"defaultMessage": "HTTP Only"
|
||||
},
|
||||
"lets-encrypt": {
|
||||
"defaultMessage": "Let's Encrypt"
|
||||
},
|
||||
"loading": {
|
||||
"defaultMessage": "Loading…"
|
||||
},
|
||||
"login.title": {
|
||||
"defaultMessage": "Login to your account"
|
||||
},
|
||||
"no-permission-error": {
|
||||
"defaultMessage": "You do not have access to view this."
|
||||
},
|
||||
"notfound.action": {
|
||||
"defaultMessage": "Take me home"
|
||||
},
|
||||
"notfound.text": {
|
||||
"defaultMessage": "We are sorry but the page you are looking for was not found"
|
||||
},
|
||||
"notfound.title": {
|
||||
"defaultMessage": "Oops… You just found an error page"
|
||||
},
|
||||
"offline": {
|
||||
"defaultMessage": "Offline"
|
||||
},
|
||||
"online": {
|
||||
"defaultMessage": "Online"
|
||||
},
|
||||
"password": {
|
||||
"defaultMessage": "Password"
|
||||
},
|
||||
"proxy-hosts.actions-title": {
|
||||
"defaultMessage": "Proxy Host #{id}"
|
||||
},
|
||||
"proxy-hosts.add": {
|
||||
"defaultMessage": "Add Proxy Host"
|
||||
},
|
||||
"proxy-hosts.count": {
|
||||
"defaultMessage": "{count} Proxy Hosts"
|
||||
},
|
||||
"proxy-hosts.empty": {
|
||||
"defaultMessage": "There are no Proxy Hosts"
|
||||
},
|
||||
"proxy-hosts.title": {
|
||||
"defaultMessage": "Proxy Hosts"
|
||||
},
|
||||
"redirection-hosts.actions-title": {
|
||||
"defaultMessage": "Redirection Host #{id}"
|
||||
},
|
||||
"redirection-hosts.add": {
|
||||
"defaultMessage": "Add Redirection Host"
|
||||
},
|
||||
"redirection-hosts.count": {
|
||||
"defaultMessage": "{count} Redirection Hosts"
|
||||
},
|
||||
"redirection-hosts.empty": {
|
||||
"defaultMessage": "There are no Redirection Hosts"
|
||||
},
|
||||
"redirection-hosts.title": {
|
||||
"defaultMessage": "Redirection Hosts"
|
||||
},
|
||||
"save": {
|
||||
"defaultMessage": "Save"
|
||||
},
|
||||
"settings.title": {
|
||||
"defaultMessage": "Settings"
|
||||
},
|
||||
"sign-in": {
|
||||
"defaultMessage": "Sign in"
|
||||
},
|
||||
"standard-user": {
|
||||
"defaultMessage": "Apache Helicopter"
|
||||
},
|
||||
"streams.actions-title": {
|
||||
"defaultMessage": "Stream #{id}"
|
||||
},
|
||||
"streams.add": {
|
||||
"defaultMessage": "Add Stream"
|
||||
},
|
||||
"streams.count": {
|
||||
"defaultMessage": "{count} Streams"
|
||||
},
|
||||
"streams.empty": {
|
||||
"defaultMessage": "There are no Streams"
|
||||
},
|
||||
"streams.tcp": {
|
||||
"defaultMessage": "TCP"
|
||||
},
|
||||
"streams.title": {
|
||||
"defaultMessage": "Streams"
|
||||
},
|
||||
"streams.udp": {
|
||||
"defaultMessage": "UDP"
|
||||
},
|
||||
"user.change-password": {
|
||||
"defaultMessage": "Change Password"
|
||||
},
|
||||
"user.confirm-password": {
|
||||
"defaultMessage": "Confirm Password"
|
||||
},
|
||||
"user.current-password": {
|
||||
"defaultMessage": "Current Password"
|
||||
},
|
||||
"user.edit": {
|
||||
"defaultMessage": "Edit User"
|
||||
},
|
||||
"user.edit-profile": {
|
||||
"defaultMessage": "Edit Profile"
|
||||
},
|
||||
"user.full-name": {
|
||||
"defaultMessage": "Full Name"
|
||||
},
|
||||
"user.logout": {
|
||||
"defaultMessage": "Logout"
|
||||
},
|
||||
"user.new-password": {
|
||||
"defaultMessage": "New Password"
|
||||
},
|
||||
"user.nickname": {
|
||||
"defaultMessage": "Nickname"
|
||||
},
|
||||
"user.switch-dark": {
|
||||
"defaultMessage": "Switch to Dark mode"
|
||||
},
|
||||
"user.switch-light": {
|
||||
"defaultMessage": "Switch to Light mode"
|
||||
},
|
||||
"users.actions-title": {
|
||||
"defaultMessage": "User #{id}"
|
||||
},
|
||||
"users.add": {
|
||||
"defaultMessage": "Add User"
|
||||
},
|
||||
"users.title": {
|
||||
"defaultMessage": "Users"
|
||||
}
|
||||
}
|
||||
5
frontend/src/locale/src/fa.json
Normal file
5
frontend/src/locale/src/fa.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"dashboard.title": {
|
||||
"defaultMessage": "داشبورد"
|
||||
}
|
||||
}
|
||||
11
frontend/src/locale/src/lang-list.json
Normal file
11
frontend/src/locale/src/lang-list.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"locale-de-DE": {
|
||||
"defaultMessage": "Deutsch"
|
||||
},
|
||||
"locale-en-US": {
|
||||
"defaultMessage": "English"
|
||||
},
|
||||
"locale-fa-IR": {
|
||||
"defaultMessage": "فارسی"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user