Revert "Use client side translation for public login page"

This reverts commit ac91c1348b.
This commit is contained in:
sledgehammer999 2024-06-16 23:31:19 +03:00
parent ec6eac2ba1
commit e6638f9c19
No known key found for this signature in database
GPG key ID: 6E4A2D025B7CC9A2
64 changed files with 4 additions and 556 deletions

View file

@ -78,11 +78,7 @@ repos:
m4/.* |
src/base/3rdparty/.* |
src/searchengine/nova3/socks.py |
src/webui/www/private/lang/.* |
src/webui/www/private/scripts/lib/.* |
src/webui/www/public/lang/.* |
src/webui/www/public/scripts/lib/.* |
src/webui/www/transifex/.*
src/webui/www/private/scripts/lib/.*
)$
exclude_types:
- ts
@ -106,11 +102,7 @@ repos:
m4/.* |
src/base/3rdparty/.* |
src/searchengine/nova3/socks.py |
src/webui/www/private/lang/.* |
src/webui/www/private/scripts/lib/.* |
src/webui/www/public/lang/.* |
src/webui/www/public/scripts/lib/.* |
src/webui/www/transifex/.*
src/webui/www/private/scripts/lib/.*
)$
exclude_types:
- svg

View file

@ -17,14 +17,6 @@ type = QT
minimum_perc = 23
lang_map = pt: pt_PT, zh: zh_CN
[o:sledgehammer999:p:qbittorrent:r:qbittorrent_webui_json]
file_filter = src/webui/www/transifex/<lang>.json
source_file = src/webui/www/transifex/en.json
source_lang = en
type = KEYVALUEJSON
minimum_perc = 23
lang_map = pt: pt_PT, zh: zh_CN
[o:sledgehammer999:p:qbittorrent:r:qbittorrentdesktop_master]
source_file = dist/unix/org.qbittorrent.qBittorrent.desktop
source_lang = en

View file

@ -6,7 +6,6 @@
"url": "https://github.com/qbittorrent/qBittorrent.git"
},
"scripts": {
"extract_translation": "i18next -c public/i18next-parser.config.mjs public/index.html public/scripts/login.js",
"format": "js-beautify -r private/*.html private/scripts/*.js private/views/*.html public/*.html public/scripts/*.js && prettier --write **.css",
"lint": "eslint private/*.html private/scripts/*.js private/views/*.html public/*.html public/scripts/*.js && stylelint **/*.css && html-validate private public"
},
@ -16,7 +15,6 @@
"eslint-plugin-html": "*",
"eslint-plugin-regexp": "*",
"html-validate": "*",
"i18next-parser": "*",
"js-beautify": "*",
"prettier": "*",
"stylelint": "*",

View file

@ -1,10 +0,0 @@
export default {
createOldCatalogs: false,
failOnWarnings: true,
keySeparator: false,
lineEnding: 'lf',
locales: ['en'],
namespaceSeparator: false,
output: 'public/lang/$LOCALE.json',
sort: true
}

View file

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="${LANG}">
<head>
<meta charset="UTF-8" />
@ -16,8 +16,7 @@
<link rel="stylesheet" type="text/css" href="css/noscript.css?v=${CACHEID}" />
</noscript>
<script defer src="scripts/lib/i18next.min.js"></script>
<script defer src="scripts/login.js?v=${CACHEID}"></script>
<script defer src="scripts/login.js?locale=${LANG}&v=${CACHEID}"></script>
</head>
<body>

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "اسم المستخدم أو كلمة السر غير صالحة.",
"Login": "ولوج",
"Password": "كلمة السر",
"Unable to log in, server is probably unreachable.": "",
"Username": "اسم المستخدم"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "İstifadəçi adı və Şifrə səhvdir.",
"Login": "Giriş",
"Password": "Şifrə",
"Unable to log in, server is probably unreachable.": "",
"Username": "İstifadəçi adı"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Нядзейсныя імя карыстальніка ці пароль.",
"Login": "Логін",
"Password": "Пароль",
"Unable to log in, server is probably unreachable.": "",
"Username": "Імя карыстальніка"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Невалидно потребителско име или парола.",
"Login": "Вход",
"Password": "Парола",
"Unable to log in, server is probably unreachable.": "",
"Username": "Потребителско име"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Nom d'usuari o contrasenya incorrectes.",
"Login": "Inicia sessió",
"Password": "Contrasenya",
"Unable to log in, server is probably unreachable.": "",
"Username": "Nom d'usuari"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Neplatné jméno nebo heslo",
"Login": "Přihlášení",
"Password": "Heslo",
"Unable to log in, server is probably unreachable.": "",
"Username": "Uživatelské jméno"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Ugyldigt brugernavn eller adgangskode.",
"Login": "Login",
"Password": "Adgangskode",
"Unable to log in, server is probably unreachable.": "",
"Username": "Brugernavn"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Ungültiger Benutzername oder Passwort.",
"Login": "Anmelden",
"Password": "Passwort",
"Unable to log in, server is probably unreachable.": "",
"Username": "Benutzername"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Μη έγκυρο Όνομα Χρήστη ή Κωδικός Πρόσβασης.",
"Login": "Σύνδεση",
"Password": "Κωδικός Πρόσβασης",
"Unable to log in, server is probably unreachable.": "",
"Username": "Όνομα χρήστη"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Invalid Username or Password.",
"Login": "Login",
"Password": "Password",
"Unable to log in, server is probably unreachable.": "Unable to log in, server is probably unreachable.",
"Username": "Username"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Invalid Username or Password.",
"Login": "Login",
"Password": "Password",
"Unable to log in, server is probably unreachable.": "",
"Username": "Username"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "",
"Login": "Login",
"Password": "",
"Unable to log in, server is probably unreachable.": "",
"Username": ""
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Malvalida uzantnomo aŭ pasvorto.",
"Login": "Ensaluti",
"Password": "Pasvorto",
"Unable to log in, server is probably unreachable.": "",
"Username": ""
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Nombre de usuario o contraseña inválidos.",
"Login": "Iniciar sesión",
"Password": "Contraseña",
"Unable to log in, server is probably unreachable.": "",
"Username": "Nombre de usuario"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Sobimatu Kasutajanimi või Parool",
"Login": "Logi sisse",
"Password": "Parool",
"Unable to log in, server is probably unreachable.": "",
"Username": "Kasutajanimi"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Erabiltzaile-izen edo Sarhitz baliogabea.",
"Login": "Hasi Saioa",
"Password": "Sarhitza",
"Unable to log in, server is probably unreachable.": "",
"Username": "Erabiltzaile-izena"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "نام کاربری یا کلمه عبور نامعتبر",
"Login": "ورود",
"Password": "کلمه عبور",
"Unable to log in, server is probably unreachable.": "",
"Username": "نام کاربری"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Virheellinen käyttäjätunnus tai salasana.",
"Login": "Kirjaudu",
"Password": "Salasana",
"Unable to log in, server is probably unreachable.": "",
"Username": "Käyttäjänimi"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Nom d'utilisateur ou mot de passe invalide.",
"Login": "Se connecter",
"Password": "Mot de passe",
"Unable to log in, server is probably unreachable.": "",
"Username": "Nom d'utilisateur"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "O usuario ou o contrasinal son incorrectos.",
"Login": "Iniciar sesión",
"Password": "Contrasinal",
"Unable to log in, server is probably unreachable.": "",
"Username": "Nome do usuario"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "שם משתמש או סיסמה בלתי תקפים.",
"Login": "היכנס",
"Password": "סיסמה",
"Unable to log in, server is probably unreachable.": "",
"Username": "שם משתמש"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "यूजरनेम व पासवर्ड अमान्य हैं।",
"Login": "लॉगिन",
"Password": "पासवर्ड",
"Unable to log in, server is probably unreachable.": "",
"Username": "यूजरनेम"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Neispravno korisničko ime ili lozinka",
"Login": "Prijava",
"Password": "Lozinka",
"Unable to log in, server is probably unreachable.": "",
"Username": "Korisničko ime"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Érvénytelen felhasználónév vagy Jelszó.",
"Login": "Bejelentkezés",
"Password": "Jelszó",
"Unable to log in, server is probably unreachable.": "",
"Username": "Felhasználónév"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "",
"Login": "Օգտանուն",
"Password": "Գաղտնաբառ",
"Unable to log in, server is probably unreachable.": "",
"Username": "Մուտքանուն"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Nama Pengguna atau Sandi tidak valid.",
"Login": "Masuk",
"Password": "Sandi",
"Unable to log in, server is probably unreachable.": "",
"Username": "Nama pengguna"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Rangt notandanafn eða lykilorð.",
"Login": "Skrá inn",
"Password": "Lykilorð",
"Unable to log in, server is probably unreachable.": "",
"Username": ""
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Username o password errati.",
"Login": "Login",
"Password": "Password",
"Unable to log in, server is probably unreachable.": "",
"Username": "Nome utente"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "ユーザー名またはパスワーが正しくありません。",
"Login": "ログイン",
"Password": "パスワード",
"Unable to log in, server is probably unreachable.": "",
"Username": "ユーザー名"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "არასწორი მომხმარებლის სახელი ან პაროლი.",
"Login": "შესვლა",
"Password": "პაროლი",
"Unable to log in, server is probably unreachable.": "",
"Username": "მომხმარებლის სახელი"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "사용자 이름/암호가 올바르지 않습니다.",
"Login": "로그인",
"Password": "암호",
"Unable to log in, server is probably unreachable.": "",
"Username": "사용자 이름"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Neteisingas naudotojo vardas ar slaptažodis.",
"Login": "Prisijungimas",
"Password": "Slaptažodis",
"Unable to log in, server is probably unreachable.": "",
"Username": "Naudotojo vardas"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Napareizs slāgvuords voi paroļs",
"Login": "Dasaslāgt",
"Password": "Paroļs",
"Unable to log in, server is probably unreachable.": "",
"Username": "Lītuotuojs"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Nederīgs lietotājvārds vai parole.",
"Login": "Pierakstīties",
"Password": "Parole",
"Unable to log in, server is probably unreachable.": "",
"Username": "Lietotājvārds"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Хэрэглэгчийн нэр эсвэл нууц үг тохирохгүй байна.",
"Login": "Нэвтрэх",
"Password": "Нууц үг",
"Unable to log in, server is probably unreachable.": "",
"Username": "Хэрэглэгчийн нэр"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Nama Pengguna atau Kata Laluan tidak sah.",
"Login": "Daftar Masuk",
"Password": "Kata Laluan",
"Unable to log in, server is probably unreachable.": "",
"Username": "Nama pengguna"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Ugyldig brukernavn eller passord.",
"Login": "Logg inn",
"Password": "Passord",
"Unable to log in, server is probably unreachable.": "",
"Username": "Brukernavn"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Ongeldige gebruikersnaam of wachtwoord.",
"Login": "Login",
"Password": "Wachtwoord",
"Unable to log in, server is probably unreachable.": "",
"Username": "Gebruikersnaam"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Nom d'utilizaire o senhal invalid.",
"Login": "Identificant",
"Password": "Senhal",
"Unable to log in, server is probably unreachable.": "",
"Username": ""
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Nieprawidłowa nazwa użytkownika lub hasło.",
"Login": "Login",
"Password": "Hasło",
"Unable to log in, server is probably unreachable.": "",
"Username": "Nazwa użytkownika"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Nome de usuário ou senha inválidos.",
"Login": "Login",
"Password": "Senha",
"Unable to log in, server is probably unreachable.": "",
"Username": "Nome de usuário"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Palavra-passe ou nome de utilizador inválido.",
"Login": "Iniciar sessão",
"Password": "Palavra-passe",
"Unable to log in, server is probably unreachable.": "",
"Username": "Nome de utilizador"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Numele de utilizator sau parola nu sunt valide.",
"Login": "Autentifică",
"Password": "Parolă",
"Unable to log in, server is probably unreachable.": "",
"Username": "Nume de utilizator"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Неверное имя пользователя или пароль.",
"Login": "Войти",
"Password": "Пароль",
"Unable to log in, server is probably unreachable.": "",
"Username": "Имя пользователя"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Nesprávne užívateľské meno alebo heslo.",
"Login": "Prihlasovacie meno",
"Password": "Heslo",
"Unable to log in, server is probably unreachable.": "",
"Username": "Meno používateľa"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Neveljavno uporabniško ime ali geslo.",
"Login": "Prijava",
"Password": "Geslo",
"Unable to log in, server is probably unreachable.": "",
"Username": "Uporabniško ime"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Неважеће корисничко име или шифра.",
"Login": "Логовање",
"Password": "Шифра",
"Unable to log in, server is probably unreachable.": "",
"Username": "Корисничко име"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Felaktigt användarnamn eller lösenord.",
"Login": "Inloggning",
"Password": "Lösenord",
"Unable to log in, server is probably unreachable.": "",
"Username": "Användarnamn"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง.",
"Login": "ล็อกอิน",
"Password": "รหัสผ่าน",
"Unable to log in, server is probably unreachable.": "",
"Username": "ชื่อผู้ใช้"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Geçersiz Kullanıcı Adı veya Parola.",
"Login": "Oturum Aç",
"Password": "Parola",
"Unable to log in, server is probably unreachable.": "",
"Username": "Kullanıcı adı"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Неправильний логін або пароль.",
"Login": "Логін",
"Password": "Пароль",
"Unable to log in, server is probably unreachable.": "",
"Username": "Ім'я користувача"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Foydalanuvchi ismi yoki parol notogri.",
"Login": "Kirish",
"Password": "Parol",
"Unable to log in, server is probably unreachable.": "",
"Username": ""
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "Tên tài khoản hoặc Mật khẩu không hợp lệ",
"Login": "Đăng nhập",
"Password": "Mật khẩu",
"Unable to log in, server is probably unreachable.": "",
"Username": "Tên tài khoản"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "无效的用户名或密码。",
"Login": "登录",
"Password": "密码",
"Unable to log in, server is probably unreachable.": "",
"Username": "用户名"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "無效用戶名稱或密碼。",
"Login": "登入",
"Password": "密碼",
"Unable to log in, server is probably unreachable.": "",
"Username": "用戶名"
}

View file

@ -1,7 +0,0 @@
{
"Invalid Username or Password.": "無效的使用者名稱或密碼。",
"Login": "登入",
"Password": "密碼",
"Unable to log in, server is probably unreachable.": "",
"Username": "使用者名稱"
}

File diff suppressed because one or more lines are too long

View file

@ -28,77 +28,6 @@
'use strict';
async function setupI18n() {
const languages = (() => {
const langs = new Set();
// list of available languages: https://github.com/qbittorrent/qBittorrent/tree/master/src/webui/www/public/lang
const queryLang = new URLSearchParams(window.location.search).get('lang');
if (queryLang !== null) {
// use the fallback lang if `queryLang` is present but empty
// limit the length of the language string to prevent Client-side Request Forgery
if ((queryLang.length > 0) && (queryLang.length <= 8))
langs.add(queryLang.replace('-', '_'));
}
else {
for (const lang of navigator.languages) {
langs.add(lang.replace('-', '_'));
const idx = lang.indexOf('-');
if (idx > 0)
langs.add(lang.slice(0, idx));
}
}
langs.add('en'); // fallback
return Array.from(langs);
})();
// it is faster to fetch all translation files at once than one by one
const fetches = languages.map(lang => fetch(`lang/${lang}.json`));
const fetchResults = await Promise.allSettled(fetches);
const translations = fetchResults
.map((value, idx) => ({ lang: languages[idx], result: value }))
.filter(v => (v.result.value.status === 200));
const translation = {
lang: (translations.length > 0) ? translations[0].lang.replace('_', '-') : undefined,
data: (translations.length > 0) ? (await translations[0].result.value.json()) : {}
};
// present it to i18next
const i18nextOptions = {
lng: translation.lang,
fallbackLng: false,
load: 'currentOnly',
resources: {
[translation.lang]: { translation: translation.data }
},
returnEmptyString: false
};
i18next.init(i18nextOptions, replaceI18nText);
}
function replaceI18nText() {
const tr = i18next.t; // workaround for warnings from i18next-parser
for (const element of document.getElementsByClassName('qbt-translatable')) {
const translationKey = element.getAttribute('data-i18n');
const translatedValue = tr(translationKey);
switch (element.nodeName) {
case 'INPUT':
element.value = translatedValue;
break;
case 'LABEL':
element.textContent = translatedValue;
break;
default:
console.error(`Unhandled element: ${element}`);
break;
}
}
document.documentElement.lang = i18next.language.split('-')[0];
}
function submitLoginForm(event) {
event.preventDefault();
const errorMsgElement = document.getElementById('error_msg');
@ -133,6 +62,4 @@ document.addEventListener('DOMContentLoaded', () => {
const loginForm = document.getElementById('loginform');
loginForm.setAttribute('method', 'POST');
loginForm.addEventListener('submit', submitLoginForm);
setupI18n();
});

View file

@ -426,63 +426,6 @@
<file>public/images/qbittorrent-tray.svg</file>
<file>public/images/qbittorrent32.png</file>
<file>public/index.html</file>
<file>public/lang/ar.json</file>
<file>public/lang/az@latin.json</file>
<file>public/lang/be.json</file>
<file>public/lang/bg.json</file>
<file>public/lang/ca.json</file>
<file>public/lang/cs.json</file>
<file>public/lang/da.json</file>
<file>public/lang/de.json</file>
<file>public/lang/el.json</file>
<file>public/lang/en.json</file>
<file>public/lang/en_AU.json</file>
<file>public/lang/en_GB.json</file>
<file>public/lang/eo.json</file>
<file>public/lang/es.json</file>
<file>public/lang/et.json</file>
<file>public/lang/eu.json</file>
<file>public/lang/fa.json</file>
<file>public/lang/fi.json</file>
<file>public/lang/fr.json</file>
<file>public/lang/gl.json</file>
<file>public/lang/he.json</file>
<file>public/lang/hi_IN.json</file>
<file>public/lang/hr.json</file>
<file>public/lang/hu.json</file>
<file>public/lang/hy.json</file>
<file>public/lang/id.json</file>
<file>public/lang/is.json</file>
<file>public/lang/it.json</file>
<file>public/lang/ja.json</file>
<file>public/lang/ka.json</file>
<file>public/lang/ko.json</file>
<file>public/lang/lt.json</file>
<file>public/lang/ltg.json</file>
<file>public/lang/lv_LV.json</file>
<file>public/lang/mn_MN.json</file>
<file>public/lang/ms_MY.json</file>
<file>public/lang/nb.json</file>
<file>public/lang/nl.json</file>
<file>public/lang/oc.json</file>
<file>public/lang/pl.json</file>
<file>public/lang/pt_BR.json</file>
<file>public/lang/pt_PT.json</file>
<file>public/lang/ro.json</file>
<file>public/lang/ru.json</file>
<file>public/lang/sk.json</file>
<file>public/lang/sl.json</file>
<file>public/lang/sr.json</file>
<file>public/lang/sv.json</file>
<file>public/lang/th.json</file>
<file>public/lang/tr.json</file>
<file>public/lang/uk.json</file>
<file>public/lang/uz@Latn.json</file>
<file>public/lang/vi.json</file>
<file>public/lang/zh_CN.json</file>
<file>public/lang/zh_HK.json</file>
<file>public/lang/zh_TW.json</file>
<file>public/scripts/lib/i18next.min.js</file>
<file>public/scripts/login.js</file>
</qresource>
</RCC>