Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions libs/native-federation/src/utils/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,18 @@ export async function translateFederationArtefacts(

const translationOutPath = path.join(outputPath, 'browser', '{{LOCALE}}');

const federationFiles = [
...federationResult.shared.map((s) => s.outFileName),
...federationResult.exposes.map((e) => e.outFileName),
];

// Here, we use a glob with an exhaustive list i/o `"*.js"`
// to improve performance
const sourcePattern = '{' + federationFiles.join(',') + '}';
// Use *.js to translate ALL JS files, including lazy-loaded chunks
// that may contain $localize markers from exposed modules
const sourcePattern = '*.js';

const sourceLocalePath = path.join(outputPath, 'browser', sourceLocale);

const localizeTranslate = path.resolve(
'node_modules/.bin/localize-translate',
);

const cmd = `${localizeTranslate} -r ${sourceLocalePath} -s "${sourcePattern}" -t ${translationFiles} -o ${translationOutPath} --target-locales ${targetLocales} -l ${sourceLocale}`;
// Quote paths to handle spaces (Windows compatibility)
const cmd = `"${localizeTranslate}" -r "${sourceLocalePath}" -s "${sourcePattern}" -t ${translationFiles} -o "${translationOutPath}" --target-locales ${targetLocales} -l ${sourceLocale}`;

ensureDistFolders(locales, outputPath);
copyRemoteEntry(locales, outputPath, sourceLocalePath);
Expand Down