Open JUSTIVE opened 1 year ago
Thank you for opening the issue!
I wasn't even aware that tsc
have a locale
flag. I saw that VSCode provides it by default if the locale is supported, the languages generated by this:
https://github.com/microsoft/TypeScript/blob/main/scripts/generateLocalizedDiagnosticMessages.mjs
So I think the easiest option is to maintain a mapping between language words the English words we use at the regexes here https://github.com/yoavbls/pretty-ts-errors/blob/main/src/format/formatDiagnosticMessage.ts
I'll start by making types of regexes. for example,
export type FormatDiagnosticMessageTarget =
| "DeclareModuleSnippet"
| "MissingPropsError"
| "TypePairs"
| "TypeAnnotationOptions"
| "Overloaded"
| "SimpleStrings"
| "Types"
| "ReversedTypes"
| "SimpleTypesRest"
| "TypescriptKeywords"
| "ReturnValues"
| "RegularCodeBlocks";
(I have no clue what kind of those regexes are, but I guessed from your very detailly described comments)
and making some constants with type at /src/format/i18n
type LocaleFormatDiagnosticMessageTarget = Record<FormatDiagnosticMessageTarget, RegExp>
// en.ts
const en:LocaleFormatDiagnosticMessageTarget = {
DeclareModuleSnippet: /'(declare module )'(.*)';'/g,
...
}
Which will be constructed like Record<SupportedLocale, LocaleFormatDiagnosticMessageTarget>.
What do you think of it?
This makes me see the hope of other languages
btw, it would be great to have a detailed contribution document. I'm trying to find out how to test & watch in the development environment.
and also example codes which generates each error messages
Has the same request, hope to support Chinese in the future version~
@yoavbls I'm keep struggling on executing this repository in development environment. I'm novice to vscode extension, so could you help me how to do it?
@JUSTIVE Sorry for my late response and thank you for all the effort and the contribution even though there is no contribution guide. I'm working on migration to a monorepo so things will change. After that, I will add a simple contribution guide with a debugging explanation. Until then, we can talk about the multi-language implementation and how to debug and test things on messaging, Are you available on Discord?
yes, I'm available on discord, my handle is λΉμ€ν·#0869
.
@yoavbls, Any progress? Thanks for your input!
@CzarOfScripts Sorry, no progress happened. I'm still looking for a feasible method to implement it. Maybe as a TypeScript server LSP plugin. JetBrains are doing something with the LSP and I wish I knew what
Syntax highlighting should be fixed in other languages(Korean, in this case). If you're unfamiliar with other languages that reproduce these kinds of issues, I'll try to contribute PR with this issue.