Generate LanguageTage.ts

This commit is contained in:
Joseph Garrone 2024-09-21 04:36:48 +02:00
parent aad89a2001
commit eb64886dcf
2 changed files with 17 additions and 1 deletions

View File

@ -139,6 +139,20 @@ async function generateI18nMessages() {
"messages_defaultSet"
);
fs.writeFileSync(
pathJoin(messagesDirPath, "LanguageTag.ts"),
Buffer.from(
[
``,
`export const languageTags = ${JSON.stringify(languages, null, 2)} as const;`,
``,
`export type LanguageTag = typeof languageTags[number];`,
``
].join("\n"),
"utf8"
)
);
const generatedFileHeader = [
`//This code was automatically generated by running ${pathRelative(
thisCodebaseRootDirPath,

View File

@ -29,7 +29,9 @@ export function generateMessageProperties(params: {
Object.fromEntries(
fs
.readdirSync(baseMessagesDirPath)
.filter(baseName => baseName !== "index.ts")
.filter(
basename => basename !== "index.ts" && basename !== "LanguageTag.ts"
)
.map(basename => ({
languageTag: basename.replace(/\.ts$/, ""),
filePath: pathJoin(baseMessagesDirPath, basename)