jsverse / transloco-keys-manager

πŸ¦„ The Key to a Better Translation Experience

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: transloco-keys-manager find not working

vshende2 opened this issue Β· comments

Is there an existing issue for this?

  • I have searched the existing issues

Is this a regression?

No

Current behavior

npm run i18n:find

transloco-keys-manager find

πŸ•΅ πŸ”Ž Starting Search For Missing Keys πŸ” πŸ•΅

  • Extracting Template and Component Keys
    C:\UI_POC\UI\node_modules\esquery\dist\esquery.min.js:1
    .....
    ......
    e [SyntaxError]: Expected " " or "]" but "c" found.
    at Object.parse (C:\UI_POC\UI\node_modules\esquery\dist\esquery.min.js:1:29413)
    ........
    \UI\node_modules@ngneat\transloco-keys-manager\keys-builder\typescript\index.js:1:721) {
    expected: [
    { type: 'literal', text: ' ', ignoreCase: false },
    { type: 'literal', text: ']', ignoreCase: false }
    ],
    found: 'c',
    location: {
    start: { offset: 46, line: 2, column: 9 },
    end: { offset: 47, line: 2, column: 10 }
    }
    }

Expected behavior

It should return missing keys.

Please provide a link to a minimal reproduction of the bug

no-link

Transloco Config

module.exports = {
    rootTranslationsPath: 'assets/i18n/',
    langs: ['en'],
    keysManager: {},
};

Debug Logs

No response

Please provide the environment you discovered this bug in

Transloco: 4.0.0
Transloco Keys Manager:3.3.3
Angular:13.3
Node: 16.1.0
Package Manager: npm
OS:windows 2019 server

Additional context

No response

I would like to make a pull request for this bug

No

@vshende2 Please provide a reproduction.

@shaharkazaz sorry I don't have any demo project to repro. Could you please provide any sample where we can test transloco-keys-manager find command?

@vshende2 Just create a new Angular project and add Transloco and the Transloco keys manager.
You can maybe fork one of the reproductions provided in previous issues.

I have a similar issue where it just outputs "Translations path provided doesn't exists!" even though the path exists.

The extract function works with the settings I have, only the find function doesn't work.

My config:

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

Edit:
Adding -p src/assets/i18n or --translations-path src/assets/i18n to the find command doesn't work either.

@HitomiTenshi This isn't related to this issue. you are welcome to create a new issue and provide a reproduction, otherwise, it won't be resolved.

@shaharkazaz Unfortunately I am not able to create repro sample. I am just trying to use transloco key manager in my project. Please check if below full logs helps to guess the issue:

e [SyntaxError]: Expected " " or "]" but "c" found.
at Object.parse (C:\Workspace\UI_POC\UI\node_modules\esquery\dist\esquery.min.js:1:29413)
at Function.v [as parse] (C:\Workspace\UI_POC\UI\node_modules\esquery\dist\esquery.min.js:1:34883)
at Object.parse (C:\Workspace\UI_POC\UI\node_modules@ngneat\transloco-keys-manager\node_modules@phenomnomnominal\tsquery\dist\src\parse.js:9:34)
at query (C:\Workspace\UI_POC\UI\node_modules@ngneat\transloco-keys-manager\node_modules@phenomnomnominal\tsquery\dist\src\query.js:11:39)
at serviceExtractor (C:\Workspace\UI_POC\UI\node_modules@ngneat\transloco-keys-manager\keys-builder\typescript\service.extractor.js:1:505)
at C:\Workspace\UI_POC\UI\node_modules@ngneat\transloco-keys-manager\keys-builder\typescript\index.js:1:1163
at Array.map ()
at TSExtractor (C:\Workspace\UI_POC\UI\node_modules@ngneat\transloco-keys-manager\keys-builder\typescript\index.js:1:1155)
at extractKeys (C:\Workspace\UI_POC\UI\node_modules@ngneat\transloco-keys-manager\keys-builder\utils\extract-keys.js:1:1011)
at extractTSKeys (C:\Workspace\UI_POC\UI\node_modules@ngneat\transloco-keys-manager\keys-builder\typescript\index.js:1:721) {
expected: [
{ type: 'literal', text: ' ', ignoreCase: false },
{ type: 'literal', text: ']', ignoreCase: false }
],
found: 'c',
location: {
start: { offset: 46, line: 2, column: 9 },
end: { offset: 47, line: 2, column: 10 }
}
}

@vshende2 Please run the command in debug mode

@shaharkazaz I did "i18n:extract": "set DEBUG=* & transloco-keys-manager extract",
"i18n:find": "set DEBUG=* & transloco-keys-manager find"

and it throw same error after below

set DEBUG=* & transloco-keys-manager find

🐞 DEBUG - Config:
Default: {
input: [ 'app' ],
output: 'assets/i18n',
langs: [ 'en' ],
marker: 't',
sort: false,
defaultValue: undefined,
replace: false,
addMissingKeys: false,
emitErrorOnExtraKeys: false,
translationsPath: 'assets/i18n'
} +0ms
Transloco file: { translationsPath: 'assets/i18n/', langs: [ 'de', 'en' ] } +4ms
Inline: { command: 'find' } +1ms
Merged: {
input: [ 'app' ],
output: 'assets/i18n',
langs: [ 'de', 'en' ],
marker: 't',
sort: false,
defaultValue: undefined,
replace: false,
addMissingKeys: false,
emitErrorOnExtraKeys: false,
translationsPath: 'assets/i18n/',
command: 'find'
} +0ms

🐞 DEBUG - Configuration Paths:
Input: [ 'C:\Workspace\UI_POC\UI\main\app' ] +0ms
Output: 'C:\Workspace\UI_POC\UI\main\assets\i18n' +6ms
Translations: 'C:\Workspace\UI_POC\UI\main\assets\i18n' +0ms

🐞 DEBUG - Scopes:
Scopes map: {
abc: 'abc',
xyz: 'xyz'

} +0ms

πŸ•΅ πŸ”Ž Starting Search For Missing Keys πŸ” πŸ•΅

@vshende2 Please update the package to v3.3.5 and run: set DEBUG=extraction & transloco-keys-manager extract this should isolate the problematic file.
Seems like tsquery is failing there for some reason.

@shaharkazaz Thanks. Above solution works for me. πŸ’― ( Is there way to skip problematic file )

@vshende2 Not sure I fully understood your issue, happy it's resolved.