jsverse/transloco-keys-manager

Bug: `find` throws "Translations path path provided doesn't exists"

MickL opened this issue ยท 4 comments

MickL commented

Is there an existing issue for this?

  • I have searched the existing issues

Is this a regression?

Yes

Current behavior

Using transloco-keys-manager find I always get the error:

Translations path path provided doesn't exists!

I also tried setting the path specifically with the same error: yarn i18n:find --translations-path src/assets/i18n

Using transloco-keys-manager extract everything works just fine.

Expected behavior

find should work as extract does

Please provide a link to a minimal reproduction of the bug

https://github.com/MickL/transloco-issues/tree/key-manager-find

Transloco Config

module.exports = {
  rootTranslationsPath: 'src/assets/i18n',
  langs: ['de', 'en'],
  keysManager: {
    defaultValue: '{{key}}',
    unflat: true,
    sort: true,
  },
};

Debug Logs

$ DEBUG=* transloco-keys-manager find

๐Ÿž DEBUG - Config:
   Default: {
     input: [ 'app' ],
     output: 'assets/i18n',
     langs: [ 'en' ],
     marker: 't',
     sort: false,
     defaultValue: undefined,
     replace: false,
     removeExtraKeys: false,
     addMissingKeys: false,
     emitErrorOnExtraKeys: false,
     translationsPath: 'assets/i18n',
     fileFormat: 'json'
   } +0ms
   Transloco file: {
     defaultValue: '{{key}}',
     unflat: true,
     sort: true,
     translationsPath: 'src/assets/i18n',
     langs: [ 'de', 'en' ]
   } +1ms
   Inline: { command: 'find' } +0ms
   Merged: {
     input: [ 'app' ],
     output: 'assets/i18n',
     langs: [ 'de', 'en' ],
     marker: 't',
     sort: true,
     defaultValue: '{{key}}',
     replace: false,
     removeExtraKeys: false,
     addMissingKeys: false,
     emitErrorOnExtraKeys: false,
     translationsPath: 'src/assets/i18n',
     fileFormat: 'json',
     unflat: true,
     command: 'find'
   } +0ms
Translations path provided doesn't exist!
โœจ  Done in 0.36s.


---------

$ DEBUG=* transloco-keys-manager extract

๐Ÿž DEBUG - Config:
   Default: {
     input: [ 'app' ],
     output: 'assets/i18n',
     langs: [ 'en' ],
     marker: 't',
     sort: false,
     defaultValue: undefined,
     replace: false,
     removeExtraKeys: false,
     addMissingKeys: false,
     emitErrorOnExtraKeys: false,
     translationsPath: 'assets/i18n',
     fileFormat: 'json'
   } +0ms
   Transloco file: {
     defaultValue: '{{key}}',
     unflat: true,
     sort: true,
     translationsPath: 'src/assets/i18n',
     langs: [ 'de', 'en' ]
   } +1ms
   Inline: { command: 'extract' } +0ms
   Merged: {
     input: [ 'app' ],
     output: 'assets/i18n',
     langs: [ 'de', 'en' ],
     marker: 't',
     sort: true,
     defaultValue: '{{key}}',
     replace: false,
     removeExtraKeys: false,
     addMissingKeys: false,
     emitErrorOnExtraKeys: false,
     translationsPath: 'src/assets/i18n',
     fileFormat: 'json',
     unflat: true,
     command: 'extract'
   } +0ms

Please provide the environment you discovered this bug in

Transloco: 4.2.7
Transloco Keys Manager: 3.7.0
Angular: 16.0.5
Node: 20.3.0
Package Manager: yarn
OS: macOS 13.3.1

Additional context

No response

I would like to make a pull request for this bug

Yes ๐Ÿš€

MickL commented

I have created a repository showcasing that find is not working. Everything is left in default settings, the only things I did:

  • npx @angular/cli new
  • ng add @ngneat/transloco
  • ng g @ngneat/transloco:keys-manager -> This also does NOT work
  • yarn add -D @ngneat/transloco-keys-manager

Please use the following branch: https://github.com/MickL/transloco-issues/tree/key-manager-find

Hi,

try to remove in your transloco.config.js "src/" in rootTranslationsPath so it looks like this:

module.exports = {
  rootTranslationsPath: 'assets/i18n/',
  langs: ['de', 'en'],
  keysManager: {
    defaultValue: '{{key}}',
    unflat: true,
    sort: true,
  },
};

After this change it started to work in my case.

I'm having similar issues but with Input path provided doesn't exist!...
this is inside a nx workspace when trying to extract
"DEBUG=* npx transloco-keys-manager extract --project feature-signing --config ./libs/beta/feature-signing/transloco.config.js"

module.exports = {
  langs: ['en', 'sv', ''jp],
  keysManager: {
    input: 'lib/',
    output: 'lib/i18n',
    addMissingKeys: true,
    emitErrorOnExtraKeys: true,
  },
};