vue-translation-manager icon indicating copy to clipboard operation
vue-translation-manager copied to clipboard

Error when a string to translate contains specific characters ?

Open Theo-Fourniez opened this issue 3 years ago • 3 comments

Steps to Reproduce

  1. Have a file containing a problematic string like "String (one / two)"
  2. Run npx vue-translation-manager translate

Context (Environment)

  • Using npm v6.14.15
  • Ubuntu LTS 20.04

Error message

(node:42613) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'toUpperCase' of undefined
    at /home/user/folder/project/Project1/node_modules/vue-translation-manager/index.js:338:49
    at Array.map (<anonymous>)
    at camelCase (/home/user/folder/project/Project1/node_modules/vue-translation-manager/index.js:338:6)
    at TranslationManager.getSuggestedKey (/home/user/folder/project/Project1/node_modules/vue-translation-manager/index.js:212:14)
    at /home/user/folder/project/Project1/node_modules/vue-translation-manager/bin.js:180:31
(Use `node --trace-warnings ...` to show where the warning was created)
(node:42613) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:42613) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Possible Implementation

I'm going to investigate this bug and reply to this issue if I find a fix / open a PR.

Theo-Fourniez avatar Jan 26 '22 10:01 Theo-Fourniez

The issue seems to come from the string that is passed to the camelCase() function. It seems that the '/' in the input string gets removed and replaced by a whitespace.

So the function ends up calling .toUppercase() on a whitespace.

Theo-Fourniez avatar Jan 26 '22 12:01 Theo-Fourniez

I have the same issue: green ( opted out ) converts to green opted with double space.

ebisbe avatar Jun 28 '22 11:06 ebisbe

I have same problem with & character.

BXYMartin avatar Aug 03 '22 21:08 BXYMartin