Skip to content

Commit

Permalink
chore: added vi locale + small things
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Dec 2, 2022
1 parent 6d467a8 commit 5677c59
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/dev_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ The diagnostics reporting button thing (2d?):


After v5.0.0 release:
- [ ] add stats for HWID: `count, q50, q75, q99`. Result will only be valid for servers with netid over 1k but that's fine
- [ ] migrate `!addwl` make possible to `/addwl @mention`
- [ ] no duplicated id type in bans? preparing for the new db migration
- [ ] add a `Wait(0)` on `sv_main.lua` kick/ban handlers? (Issue #639)
Expand Down
2 changes: 1 addition & 1 deletion docs/newDatabase.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ legacyBans: [{
- FIXME: what is the correct handling of license2?
- Any other identifier can be present in more than one player
- Identifier and HWIDs array will contain EVERY id to ever join a server with that specific license
- For hwid matching, add a setting with numbers `3, 5, 7 (default), 11, 13` (13 should be 65% of the median number of hwids)
- For hwid matching, add a setting with numbers `3, 5, 7 (default), 11, 13` (13 should be 65% of the median number of hwids FIXME: this seems to be wrong, check stats)
- If you join an account with new license, but matching identifier with another one, it will be registered as a new account
- If your identifier matches any account that is banned, the ban apllies to you
- make sure the ban message makes clear which identifier matched and that it is from another account (maybe even say the name)
Expand Down
2 changes: 1 addition & 1 deletion locale/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
},
"player_ids": {
"title": "Mostrar/Esconder IDs",
"label": "Toggle showing player IDs (and other info) above the head of all nearby players",
"label": "Ligar/desligar mostrar ID (e outros dados) acima da cabeça dos jogadores próximos",
"alert_show": "Mostrando os NetIDs próximos.",
"alert_hide": "Escondendo os NetIDs próximos."
}
Expand Down
20 changes: 19 additions & 1 deletion scripts/locale-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import fs from 'node:fs';
import path from 'node:path';
import chalk from 'chalk';
import { defaults, defaultsDeep, xor } from 'lodash-es';
import humanizeDuration from 'humanize-duration';

//Prepping
const defaultLang = JSON.parse(fs.readFileSync('./locale/en.json', 'utf8'));
Expand All @@ -10,10 +11,18 @@ const langFiles = fs.readdirSync('./locale/', { withFileTypes: true })
.map((dirent) => dirent.name);
const langs = langFiles.map((fName) => {
const fPath = path.join('./locale/', fName);
let data;
try {
data = JSON.parse(fs.readFileSync(fPath, 'utf8'))
} catch (error) {
console.log(chalk.red(`Failed to load ${fName}:`));
console.log(error.message);
process.exit(1);
}
return {
name: fName,
path: fPath,
data: JSON.parse(fs.readFileSync(fPath, 'utf8')),
data,
};
});

Expand Down Expand Up @@ -91,11 +100,19 @@ function parseLocale(input, prefix = '') {
const diffCommand = () => {
console.log('Diffing language files on \'en.json\' for missing/excess keys, or different special values');
const defaultLangParsed = parseLocale(defaultLang);
const humanizerLocales = humanizeDuration.getSupportedLanguages();


let errors = 0;
langs.forEach(({ name, data }) => {
const parsed = parseLocale(data);

//Testing humanizer-duration key
if(!humanizerLocales.includes(data.$meta.humanizer_language)){
errors++;
console.log(chalk.yellow(`[${name}] $meta.humanizer_language not supported.`));
}

//Testing keys
const diffKeys = xor(Object.keys(defaultLangParsed), Object.keys(parsed));
if (diffKeys.length) {
Expand All @@ -120,6 +137,7 @@ const diffCommand = () => {
//Print result
if (errors) {
console.log(chalk.red(`Errors found: ${errors}`));
process.exit(1);
} else {
console.log(chalk.green('No errors found!'));
}
Expand Down
2 changes: 2 additions & 0 deletions shared/localeMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import lang_sl from "@locale/sl.json";
import lang_sv from "@locale/sv.json";
import lang_th from "@locale/th.json";
import lang_tr from "@locale/tr.json";
import lang_vi from "@locale/vi.json";
import lang_zh from "@locale/zh.json";

export type LocaleType = typeof lang_en;
Expand Down Expand Up @@ -61,6 +62,7 @@ const localeMap: LocaleMapType = {
sv: lang_sv,
th: lang_th,
tr: lang_tr,
vi: lang_vi,
zh: lang_zh,
};

Expand Down

0 comments on commit 5677c59

Please sign in to comment.