From 899f468d2b516ea39b85c9f826501be99d29833d Mon Sep 17 00:00:00 2001 From: Benjamin Fan Date: Thu, 1 May 2025 12:00:37 -0700 Subject: [PATCH] fix(scripts,config): Update collection i18n during reconfigure --- config/templates/collection-i18n.mustache | 9 +++++++++ scripts/reconfigure.mjs | 11 +++++++++++ 2 files changed, 20 insertions(+) create mode 100644 config/templates/collection-i18n.mustache diff --git a/config/templates/collection-i18n.mustache b/config/templates/collection-i18n.mustache new file mode 100644 index 00000000000..8e2109316de --- /dev/null +++ b/config/templates/collection-i18n.mustache @@ -0,0 +1,9 @@ +// Designs +{{{ designI18n }}} + +/* + * Export the translations + */ +export const i18n = { + {{ designList }} +} diff --git a/scripts/reconfigure.mjs b/scripts/reconfigure.mjs index 14676f809f0..f5553fad003 100644 --- a/scripts/reconfigure.mjs +++ b/scripts/reconfigure.mjs @@ -51,6 +51,7 @@ const repo = { collection: { pkg: readTemplateFile('collection-pkg.mustache'), hook: readTemplateFile('collection-hook.mustache'), + i18n: readTemplateFile('collection-i18n.mustache'), }, }, contributors: SITEBUILD ? null : fs.readFileSync(path.join(root, 'CONTRIBUTORS.md'), 'utf-8'), @@ -189,6 +190,16 @@ await writeFile( 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( ['packages', 'react', 'hooks', 'useDesign', 'index.mjs'], mustache.render(repo.templates.collection.hook, {