Add type annotation to generated language files map (#29283)

Этот коммит содержится в:
Claudio Costa
2024-11-15 12:19:40 -06:00
коммит произвёл GitHub
родитель 207503185e
Коммит 324693c13a
2 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@@ -37,11 +37,16 @@ fs.readdirSync('./channels/src/i18n').forEach(file => {
}
});
lines += `
type TranslationsMap = {
[id: string]: string,
};
`;
lines += `\nexport const langIDs = ${JSON.stringify(langIDs)};\n`
lines += `\nexport const langLabels = ${JSON.stringify(langLabels)};\n`
// To generate the file exports we need to do a bit more work to handle ids with dashes and also output a map of literals rather than strings.
lines += '\nexport const langFiles = {' + Object.keys(langFiles).reduce((out, id, idx) => {
lines += '\nexport const langFiles: {[langID: string]: TranslationsMap} = {' + Object.keys(langFiles).reduce((out, id, idx) => {
if (id.includes('-')) {
out += `'${id}':${langFiles[id]}`;
} else {