Add type annotation to generated language files map (#29283)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
207503185e
Коммит
324693c13a
@@ -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 {
|
||||
|
||||
Ссылка в новой задаче
Block a user