Skip to content

Build with localize throws error under Windows #879

@CappuccinoDiAigner

Description

@CappuccinoDiAigner

With what library do you have an issue?

native-federation

Reproduction of the bug/regression with instructions

Running ng build with a configuration that contains "localize: true" throws the following error:
(I removed the shared packages to shorten the error message)

 ERRR  Command failed: node node_modules/.bin/localize-translate -r dist\native-federation-test\browser\en -s "{}" -t "src/locale/messages.de.xlf" -o dist\native-federation-test\browser\{{LOCALE}} --target-locales de -l en
C:\Projects\native-federation-test\node_modules\.bin\localize-translate:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at wrapSafe (node:internal/modules/cjs/loader:1662:18)
    at Module._compile (node:internal/modules/cjs/loader:1704:20)
    at Object..js (node:internal/modules/cjs/loader:1895:10)
    at Module.load (node:internal/modules/cjs/loader:1465:32)
    at Function._load (node:internal/modules/cjs/loader:1282:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5)
    at node:internal/main/run_main_module:36:49

I looked into the problem and it seems like running the localize-translate script with node doesn't work on my Windows machine.
So instead of using node I directly called the cmd script like this in i18n.js:

        const cmd = `"node_modules/.bin/localize-translate" -r ${sourceLocalePath} -s "${sourcePattern}" -t ${translationFiles} -o ${translationOutPath} --target-locales ${targetLocales} -l ${sourceLocale}`;

That worked like a charm and solved the problem for me.

Expected behavior

Build runs threw without errors

Versions of Native/Module Federation, Angular, Node, Browser, and operating system

Native Federation: 20.0.6
Angular: 19.2.14
Node: 22.16.0
Operation System: Windows 11 Pro

Other information

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions