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

Supporting korean (and boilerplates for i18n) #49

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

JUSTIVE
Copy link

@JUSTIVE JUSTIVE commented Apr 25, 2023

I'm supporting text highlighting in the Korean display language, also other expandable locales. (as discussed in #27 ).
This is currently working in progress, not all regexes are replaced with the proper version of its Korean alternatives yet.

Copy link
Owner

@yoavbls yoavbls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution!
It looks good and I think it will be even better if the translations co-existed in the same place for every regex.
@artyom-ar suggested splitting the long chain of replacements into separate functions so we could create a unit test for each one of them.
I thought it would be nice to create functions like this one for example:

function formatReturnValues(message: string, locale: Locale = "en") {
  const regex = {
    en: /(return|operator) '(.*?)'/gi,
    ko: /(반품|연산자) '(.*?)'/gi,
  }[locale];

  return message.replaceAll(
    regex,
    (_, p1: string, p2: string) => `${p1} ${formatTypeScriptBlock("", p2)}`
  );
}

Let me know what you think
It requires a lot of changes and we're moving to a monorepo so coordinating shall be required, Do you available on Discord?

Thanks 🙂

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

Successfully merging this pull request may close these issues.

2 participants