1
0
Fork 0

fix(scripts,config): Update collection i18n during reconfigure

This commit is contained in:
Benjamin Fan 2025-05-01 12:00:37 -07:00 committed by Joost De Cock
parent b6d9526d8b
commit 899f468d2b
2 changed files with 20 additions and 0 deletions

View file

@ -0,0 +1,9 @@
// Designs
{{{ designI18n }}}
/*
* Export the translations
*/
export const i18n = {
{{ designList }}
}

View file

@ -51,6 +51,7 @@ const repo = {
collection: { collection: {
pkg: readTemplateFile('collection-pkg.mustache'), pkg: readTemplateFile('collection-pkg.mustache'),
hook: readTemplateFile('collection-hook.mustache'), hook: readTemplateFile('collection-hook.mustache'),
i18n: readTemplateFile('collection-i18n.mustache'),
}, },
}, },
contributors: SITEBUILD ? null : fs.readFileSync(path.join(root, 'CONTRIBUTORS.md'), 'utf-8'), contributors: SITEBUILD ? null : fs.readFileSync(path.join(root, 'CONTRIBUTORS.md'), 'utf-8'),
@ -189,6 +190,16 @@ await writeFile(
designList: designList.join(',\n '), designList: designList.join(',\n '),
}) })
) )
const designI18n = designList
.map((name) => `import { i18n as ${name} } from '@freesewing/${name}'`)
.join('\n')
await writeFile(
['packages', 'collection', 'src', 'i18n.mjs'],
mustache.render(repo.templates.collection.i18n, {
designI18n,
designList: designList.join(',\n '),
})
)
await writeFile( await writeFile(
['packages', 'react', 'hooks', 'useDesign', 'index.mjs'], ['packages', 'react', 'hooks', 'useDesign', 'index.mjs'],
mustache.render(repo.templates.collection.hook, { mustache.render(repo.templates.collection.hook, {