jsverse / transloco

🚀 😍 The internationalization (i18n) library for Angular

Home Page:https://jsverse.github.io/transloco/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug(scope): scoped extractions prefixed not working

mackelito opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Which Transloco package(s) are the source of the bug?

Transloco, Scoped Libs

Is this a regression?

No

Current behavior

Not sure if this is a bug or if I'm using transloco scopes incorrectly.
I have a nx library that contains of 2 components:

  • signingComponent
  • statusComponent

lib/
lib/signingComponent
lib/statusComponent
lib/i18n

    provideTranslocoScope({
      scope: 'signing',
      loader,
    }),

    provideTranslocoScope({
      scope: 'status',
      loader,
    }),

in the i18n file (both share the same en.json file)
We have like keys like

  "button_sign": "Sign",
  "button_cancel": "Cancel",
  "button_back": "Back",
  "button_retry": "Retry",

In the template files the keys are used like this:

<button>{{ t('signing.button_sign') }}</button>
<button>{{ t('status.button_sign') }}</button>

So different scopes use the same key and this works fine
...
But when extracting keys are prefixed eg: "signing.button_sign": "missing key" and that key is not used...

Expected behavior

So what I would need is to not have it prefixed when extracting (or change my implementation so that the prefix is used)

Any suggestions?

Transloco Config

module.exports = {
  langs: ['fi', 'sv'],
  keysManager: {
    input: './',
    output: './lib/i18n',
    sort: true,
    addMissingKeys: true,
    emitErrorOnExtraKeys: true,
    defaultValue: 'lib missing key',
  },
  },
};

Please provide the environment you discovered this bug in

Transloco: 4.3.0
Angular: 17.1.3
Node: 18
Package Manager: NPM 
OS: MacOs

I would like to make a pull request for this bug

Yes 🚀

Hi @mackelito, i have the same issue. Did you ever resolved this?

I have not had the time to look into it more yet.. more pressing issues so we hand to do it manual for now :(

@mackelito If I understand correctly this issue is related to the keys manager is that correct?
TKM is managed in a different repository so please move the issue there.
Feel free to reopen if I misunderstood.

There should be scope support in the TKM but maybe you are facing this issue due to the face that provideTranslocoScope is missing support and will be added soon in a new release.