mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-20 13:00:39 +00:00
Update localization files for backup destinations and API client credentials
- Changed references from E3 to S3 in Russian, Simplified Chinese, and Traditional Chinese localization files. - Updated the corresponding keys and descriptions to reflect the change in backup destination protocols. - Improved the Vite configuration to dynamically match locale files, simplifying the code for locale handling.
This commit is contained in:
@@ -4,6 +4,14 @@ const vm = require('vm');
|
||||
|
||||
const localeDir = path.join(__dirname, '..', 'webapp', 'src', 'lib', 'i18n', 'locales');
|
||||
|
||||
const localeFiles = [
|
||||
['en', 'en.ts', 'en', 'English'],
|
||||
['zh-CN', 'zh-CN.ts', 'zhCN', 'Simplified Chinese'],
|
||||
['zh-TW', 'zh-TW.ts', 'zhTW', 'Traditional Chinese'],
|
||||
['ru', 'ru.ts', 'ru', 'Russian'],
|
||||
['es', 'es.ts', 'es', 'Spanish'],
|
||||
];
|
||||
|
||||
function readLocale(fileName, variableName) {
|
||||
let code = fs.readFileSync(path.join(localeDir, fileName), 'utf8');
|
||||
code = code
|
||||
@@ -26,6 +34,7 @@ function writeLocale(fileName, variableName, table, header) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
localeFiles,
|
||||
localeDir,
|
||||
readLocale,
|
||||
writeLocale,
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
const { readLocale } = require('./i18n-utils.cjs');
|
||||
|
||||
const localeFiles = [
|
||||
['en', 'en.ts', 'en'],
|
||||
['zh-CN', 'zh-CN.ts', 'zhCN'],
|
||||
['zh-TW', 'zh-TW.ts', 'zhTW'],
|
||||
['ru', 'ru.ts', 'ru'],
|
||||
];
|
||||
const { localeFiles, readLocale } = require('./i18n-utils.cjs');
|
||||
|
||||
const locales = Object.fromEntries(
|
||||
localeFiles.map(([locale, fileName, variableName]) => [locale, readLocale(fileName, variableName)])
|
||||
@@ -14,6 +7,17 @@ const base = locales.en;
|
||||
const baseKeys = Object.keys(base).sort();
|
||||
const placeholderRe = /\{\w+\}/g;
|
||||
const errors = [];
|
||||
const intentionallyEnglishKeys = new Set([
|
||||
'txt_backup_destination_detail_note',
|
||||
'txt_backup_protocol_webdav',
|
||||
'txt_backup_protocol_s3',
|
||||
'txt_backup_recommend_group_webdav',
|
||||
'txt_backup_recommend_group_s3',
|
||||
'txt_backup_destination_name_default_webdav',
|
||||
'txt_backup_destination_name_default_s3',
|
||||
'txt_dash',
|
||||
'txt_text_3',
|
||||
]);
|
||||
|
||||
for (const [locale, table] of Object.entries(locales)) {
|
||||
const keys = Object.keys(table).sort();
|
||||
@@ -30,6 +34,17 @@ for (const [locale, table] of Object.entries(locales)) {
|
||||
errors.push({ locale, key, basePlaceholders, localePlaceholders });
|
||||
}
|
||||
}
|
||||
|
||||
if (locale !== 'en') {
|
||||
const sameAsEnglish = baseKeys.filter((key) => table[key] === base[key] && !intentionallyEnglishKeys.has(key));
|
||||
if (sameAsEnglish.length > 40) {
|
||||
errors.push({
|
||||
locale,
|
||||
sameAsEnglishCount: sameAsEnglish.length,
|
||||
sameAsEnglishSample: sameAsEnglish.slice(0, 25),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user