transloco-keys-manager icon indicating copy to clipboard operation
transloco-keys-manager copied to clipboard

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

Open MickL opened this issue 2 years ago • 3 comments

Is there an existing issue for this?

  • [X] 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 avatar Jun 13 '23 13:06 MickL

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

MickL avatar Jun 19 '23 09:06 MickL

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.

bernardVlado avatar Jan 30 '24 12:01 bernardVlado

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,
  },
};

mackelito avatar Jan 30 '24 14:01 mackelito

Ok so there were a couple of issues here:

  1. The documentation isn't clear that the source root is also prefixed.
  2. The debug config didn't print the resolved config since the validation ran first and threw an error.
  3. I've added a fallback so the provided config won't fail

shaharkazaz avatar Jul 18 '24 22:07 shaharkazaz