chore: remove necessary code

This commit is contained in:
lleohao
2024-09-07 14:32:36 +00:00
parent 1b0760f5af
commit 637cd15ab4
2 changed files with 0 additions and 65 deletions

View File

@ -25,9 +25,3 @@ If you are developing a production application, we recommend updating the config
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
## Add i18n namespaces
`node scripts/i18n-tools.js add-ns <namespcaes>`
For example `node scripts/i18n-tools.js add-ns login`

View File

@ -1,59 +0,0 @@
const fs = require("node:fs");
const path = require("node:path");
const localsPath = path.join(__dirname, "../public/locales");
const supportLanguages = ["en", "zh"];
const supportCommands = ["add-ns"];
function ensureLanguageDirectories() {
if (!fs.existsSync(localsPath)) {
fs.mkdirSync(localsPath, { recursive: true });
}
supportLanguages.forEach((lang) => {
const langPath = path.join(localsPath, lang);
if (!fs.existsSync(langPath)) {
fs.mkdirSync(langPath);
}
});
}
function addNamespaces(namespaces) {
supportLanguages.forEach((lang) => {
const langPath = path.join(localsPath, lang);
namespaces.forEach((ns) => {
const nsFilePath = path.join(langPath, `${ns}.json`);
if (!fs.existsSync(nsFilePath)) {
fs.writeFileSync(nsFilePath, "{}", "utf8");
console.log(`Created empty ${ns}.json file in ${lang} directory`);
} else {
console.log(
`${ns}.json file already exists in ${lang} directory, skipping creation`,
);
}
});
});
}
ensureLanguageDirectories();
const [command, ...params] = process.argv.slice(2);
if (!supportCommands.includes(command)) {
console.warn(
`Only support the follow commands: ${supportCommands.join(" ")} `,
);
console.log();
}
switch (command) {
case "add-ns":
addNamespaces(params);
break;
default:
console.warn("You should input a command");
}