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

Support more languages and locales #27

Open
JUSTIVE opened this issue Apr 19, 2023 · 10 comments
Open

Support more languages and locales #27

JUSTIVE opened this issue Apr 19, 2023 · 10 comments
Labels
feature request Request a new feature help wanted Extra attention is needed

Comments

@JUSTIVE
Copy link

JUSTIVE commented Apr 19, 2023

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 JUSTIVE changed the title Syntaxes not highlighted on other languages Syntaxes are not highlighted on other languages Apr 19, 2023
@yoavbls yoavbls added bug Something isn't working help wanted Extra attention is needed and removed bug Something isn't working labels Apr 19, 2023
@yoavbls
Copy link
Owner

yoavbls commented Apr 19, 2023

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

@JUSTIVE
Copy link
Author

JUSTIVE commented Apr 20, 2023

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?

@xlboy
Copy link

xlboy commented Apr 20, 2023

This makes me see the hope of other languages

@JUSTIVE
Copy link
Author

JUSTIVE commented Apr 20, 2023

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

@cat-walk
Copy link

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

@JUSTIVE
Copy link
Author

JUSTIVE commented Apr 25, 2023

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

@yoavbls
Copy link
Owner

yoavbls commented Apr 29, 2023

@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 yoavbls added the feature request Request a new feature label May 1, 2023
@yoavbls yoavbls changed the title Syntaxes are not highlighted on other languages Support more languages and locales May 1, 2023
@JUSTIVE
Copy link
Author

JUSTIVE commented May 1, 2023

yes, I'm available on discord, my handle is 비스킷#0869.

@CzarOfScripts
Copy link

@yoavbls, Any progress? Thanks for your input!

@yoavbls
Copy link
Owner

yoavbls commented Sep 18, 2023

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request a new feature help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants