tsc-watch icon indicating copy to clipboard operation
tsc-watch copied to clipboard

Incorrect operation for non-English settings

Open sosoba opened this issue 7 years ago • 8 comments

tsc-watch is based on compiler messages regular expressions wich fail when you use --locale typescript option.

sosoba avatar Jan 18 '18 13:01 sosoba

Yeap, that means that we need to copy all the translations from the TypeScript compiler itself (Not optimal, but doable)

gilamran avatar Jan 18 '18 15:01 gilamran

It's also possible to force the --locale to be in English to temporarily fix this.

pronebird avatar Feb 12 '19 17:02 pronebird

@pronebird If someone specifically asked for a locale, changing it back to English would be misleading. The right thing to do is to extract the requested local json from the node_modules\typescript and use that, but it's not simple, as I'm use RegEx and the json holds strings...

gilamran avatar Feb 12 '19 17:02 gilamran

..., as I'm use RegEx and the json holds strings...

@gilamran You can compile regular expressions from strings.

const pattern = "[a-z]+";
const flags = "i";
const exp = new RegExp(pattern, flags);

exp.test('Hello'); // true

trs avatar May 01 '19 19:05 trs

@trs I know that you can do many things with regex... how would this help with Japanese for example?

gilamran avatar May 01 '19 22:05 gilamran

@gilamran I see, I thought the issue was converting a string into a RegExp 😄


Perhaps the expressions can also be associated to a locale object and referenced as such:

// english.json
{
  "compilationCompleteWithErrorRegex": " Found [^0][0-9]* error[s]?\\. Watching for file changes\\."
  ...
}
// japanese.json
{
  "compilationCompleteWithErrorRegex": " 見つかった [^0][0-9]* エラー\\. ファイルの変更を監視する
}
(ignore my ignorance to the language, just Google translated for an example)

Then you would just import the correct expressions file based on the locale.

const expressions = require(`${locale}.json`)

🤷‍♂

trs avatar May 01 '19 22:05 trs

@trs Yeap that's what I wrote in the comment above, we should extract the current locale json from node_modules\typescript and do just that :-) If you want to PR this, it would be gr8!

gilamran avatar May 02 '19 11:05 gilamran

Not for me, sorry! Hopefully someone else can tackle this PR.

trs avatar May 02 '19 19:05 trs