pretty-ts-errors icon indicating copy to clipboard operation
pretty-ts-errors copied to clipboard

Support more languages and locales

Open JUSTIVE opened this issue 1 year ago β€’ 10 comments

image

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.

JUSTIVE avatar Apr 19 '23 10:04 JUSTIVE

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

yoavbls avatar Apr 19 '23 23:04 yoavbls

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?

JUSTIVE avatar Apr 20 '23 03:04 JUSTIVE

This makes me see the hope of other languages

xlboy avatar Apr 20 '23 04:04 xlboy

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

JUSTIVE avatar Apr 20 '23 04:04 JUSTIVE

Has the same request, hope to support Chinese in the future version~

cat-walk avatar Apr 25 '23 03:04 cat-walk

@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 avatar Apr 25 '23 05:04 JUSTIVE

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

yoavbls avatar Apr 29 '23 18:04 yoavbls

yes, I'm available on discord, my handle is λΉ„μŠ€ν‚·#0869.

JUSTIVE avatar May 01 '23 23:05 JUSTIVE

@yoavbls, Any progress? Thanks for your input!

CzarOfScripts avatar Jul 02 '23 07:07 CzarOfScripts

@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

yoavbls avatar Sep 18 '23 23:09 yoavbls