jsverse/transloco-keys-manager

Feature: clearer instructions on how to add to a Nx workspace

mackelito opened this issue · 0 comments

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe

In our workspace we have 5 apps and they use feature libraries only (the apps only have 1 component app.component.ts) the rest is features loaded via the app routes.

I would like to have a clear way of extracting all keys and generate a folder that contains the translation files.
A neat feature would be if it could generate a file for each lang that is defined in the loader used for the feature.

Example:
in my lib.routes.ts

export const loader = ['en', 'sv'].reduce((acc, lang) => {
  acc[lang] = () => import(`./i18n/${lang}.json`);
  return acc;
}, {});

providers: [
  provideTranslocoScope({
    scope: ' ', // This needs to be emtpy to not require a prefix in the template
    loader,
  }),
],

Describe the solution you'd like

either we could use the Nx "extract-i18n" target by adding something like this:

      "extract-i18n": {
        "executor": "nx:run-commands",
        "options": {
          "commands": ["npx transloco-keys-manager extract --project my-nice-feature"]
        }
      }

Or even better would to have it generate automatically when adding a new translation string. (eg. adding t('my-string-to-translate´) in a template) Not sure how but perhaps using webpack/esbuild?

Describe alternatives you've considered

No response

Describe alternatives you've considered

using angulars own i18n

Describe alternatives you've considered

using angulars own i18n

Additional context

No response

I would like to make a pull request for this feature

No