Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect operation for non-English settings #14

Open
sosoba opened this issue Jan 18, 2018 · 8 comments
Open

Incorrect operation for non-English settings #14

sosoba opened this issue Jan 18, 2018 · 8 comments

Comments

@sosoba
Copy link
Contributor

sosoba commented Jan 18, 2018

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

@gilamran
Copy link
Owner

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

@pronebird
Copy link
Contributor

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

@gilamran
Copy link
Owner

@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...

@trs
Copy link

trs commented May 1, 2019

..., 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

@gilamran
Copy link
Owner

gilamran commented May 1, 2019

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

@trs
Copy link

trs commented May 1, 2019

@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`)

🤷‍♂

@gilamran
Copy link
Owner

gilamran commented May 2, 2019

@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!

@trs
Copy link

trs commented May 2, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants