-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathlang.js
More file actions
37 lines (32 loc) · 888 Bytes
/
lang.js
File metadata and controls
37 lines (32 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Import Third-party Dependencies
import * as i18n from "@nodesecure/i18n";
import { appCache } from "@nodesecure/cache";
import { select } from "@topcli/prompts";
import kleur from "kleur";
export async function set() {
const langs = await i18n.getLanguages();
const selectedLang = await select(
kleur.green().bold(` ${i18n.getTokenSync("cli.commands.lang.question_text")}`),
{
choices: langs
}
);
await i18n.setLocalLang(selectedLang);
await i18n.getLocalLang();
try {
const config = await appCache.getConfig();
if (config) {
await appCache.updateConfig({
...config,
lang: selectedLang
});
}
}
catch {
// Config does not exist, do nothing
}
console.log(
kleur.white().bold(`\n ${i18n.getTokenSync("cli.commands.lang.new_selection", kleur.yellow().bold(selectedLang))}`)
);
console.log();
}