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

Initial work for l10n - views #1145

Merged
merged 21 commits into from
Aug 14, 2023
Merged

Initial work for l10n - views #1145

merged 21 commits into from
Aug 14, 2023

Conversation

worksofliam
Copy link
Contributor

@worksofliam worksofliam commented Mar 19, 2023

Changes

Shows off a possible way to support l10n. I am using a custom implementation instead of the VS Code l10n API due to the fact the configuration files use the base message as the base text and the id for the locale in other languages. This uses just an ID and then falls back to the default (en) if cannot be found in the target locale.

I made that decision based on this thread: microsoft/vscode-discussions#517

This will not handle the package.json and we will have to use the VS Code method to do that (perhaps a separate PR also.)

Looking for feedback on:

  • The interfaces
  • The t method

Signed-off-by: Liam Allan <[email protected]>
@worksofliam worksofliam linked an issue Mar 19, 2023 that may be closed by this pull request
@chrjorgensen
Copy link
Collaborator

@worksofliam @sebjulliand
I started translating texts to my own locale Danish, thus beginning the journey to have C4i fully support l10n.

The t function works fine - I just changed the replace() with RegExp to replaceAll() (had to upgrade from ES2019 to ES2021).

What about panel texts? Menu items? Command names? Tooltips?
There are texts in many places other than in the code. Do we convert all? And how?

@worksofliam
Copy link
Contributor Author

@chrjorgensen

Great works! And nice cleaning. Not so bad moving to a new version of ES2019.

Do we convert all? And how?

Yeah.. this is going to be a challenge. It wouldn't be the end of the world if we missed some. A good way to get more contributors I think 😄

@chrjorgensen
Copy link
Collaborator

@worksofliam @sebjulliand
I changed the locale to a configuration setting, thus able to select a different language not related to VS Code. If no locale has been selected, it will use the env language as before. The locale is set only once and change will require restart.
Any comments on this? Good? Bad? Anything missed? Any opinions are welcome...

@chrjorgensen
Copy link
Collaborator

@sebjulliand In this work all files containing texts will have to be changed, including the JavaScript files. You're planning to convert these into TypeScript - will we collide on this? How do we avoid most collisions?

This localization project is a massive task that will take a long time to finish. And I'm off on vacation after next week. What are your thoughts on this?

@chrjorgensen chrjorgensen self-assigned this Jul 7, 2023
@chrjorgensen
Copy link
Collaborator

@sebjulliand Nice change in b41cc5a - thanks! 😃

@chrjorgensen chrjorgensen marked this pull request as ready for review July 23, 2023 20:52
@chrjorgensen
Copy link
Collaborator

@worksofliam @sebjulliand All views have now been localized - next up are/would be the webviews.
It would be great with a review and I have changed the PR from draft to ready for review...

How far should we go with this before merging into master branch? The longer we wait the more likely it is to have collisions for this PR or other PR's in the works.

@chrjorgensen chrjorgensen requested review from chrjorgensen and removed request for chrjorgensen July 23, 2023 20:52
@chrjorgensen chrjorgensen changed the title Proposal: Initial work for l10n Initial work for l10n - views Jul 23, 2023

export type Locale = {[id: string]: string};

const currentLocale = String(GlobalConfiguration.get(`locale`) || env.language);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We really should be letting VS Code decide what the locale is. This will always default to English.

@worksofliam worksofliam added this to the 2.1.0 milestone Aug 11, 2023
@worksofliam
Copy link
Contributor Author

@chrjorgensen I added some code to make the default locale whatever VS Code is using, and then also added a handler so when the config changes it updates our internal locale reference.

@sebjulliand Over to you for French!

@sebjulliand
Copy link
Collaborator

french-it-up

@worksofliam
Copy link
Contributor Author

@chrjorgensen merge when you feel comfortable…

src/locale/ids/fr.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@chrjorgensen chrjorgensen left a comment

Choose a reason for hiding this comment

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

@sebjulliand Perfect - approving and merging.

@chrjorgensen chrjorgensen merged commit 90eaade into master Aug 14, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multi-language support
3 participants