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

Enhancement: Multilingual UI #598

Closed
gsegit opened this issue Jul 2, 2023 · 12 comments
Closed

Enhancement: Multilingual UI #598

gsegit opened this issue Jul 2, 2023 · 12 comments

Comments

@gsegit
Copy link

gsegit commented Jul 2, 2023

Hi there ;D
Can your Ext be translated into another language, such as my native German ? Is something like that foreseen ?

Greetings from Germany ;D

Bogus

@gsegit gsegit added the enhancement New feature or request label Jul 2, 2023
@estruyf estruyf changed the title Enhancement: Enhancement: Multilingual UI Jul 2, 2023
@estruyf
Copy link
Owner

estruyf commented Jul 2, 2023

Thanks for the suggestion @gsegit. Haven't planned anything for this yet, but if you want or any other of the contributors, I'm welcome to accept PRs for this one.

@estruyf
Copy link
Owner

estruyf commented Jul 3, 2023

I did the initial configuration to allow us to localize the Front Matter UI.

I used the vscode-l10n localization approach to support it, but with a couple of changes, as it only localizes the configuration or anything related to the extension host, not the web views.

To overcome this, I pass the localization bundle to the web view, and once loaded, it can be used in the React codebase as follows:

l10n.t(`header.startup.label`)

The localization files are located in the l10n folder of the issue/598 branch.

You can find two files:

  • bundle.l10n.json - the default EN file
  • bundle.l10n.de.json - the German file

By default, the vscode-l10n dependency will not use a localization file for the default language, but I changed this behavior as I like to use localization keys. This makes it easier to find where it's used in the codebase.

@estruyf
Copy link
Owner

estruyf commented Jul 4, 2023

I have been optimizing the flow. There are two new scripts created:

  • ./scripts/sync-localization.js: This script will sync all the localization keys from EN to the other available languages. When a key is not present, it will be at the EN value + the 🚧 sign. In the future, we might use a service for automatically translating those labels and getting them validated by the users.
  • ./scripts/generate-localization-enum.js: This script created an enum file so that we do not have to guess the keys during the development.

When creating a key, start with the type of web view to where you want to add it. This can be panel or dashboard. Example:

{
  "dashboard.header.createContent": "Create content",
  "dashboard.header.startup.label": "Open on startup?",

  "panel.actions.title": "Actions",
  "panel.actions.openDashboard": "Open dashboard",
  "panel.actions.openPreview": "Open preview",
  "panel.actions.startServer": "Start server",
  "panel.actions.stopServer": "Stop server",
  "panel.actions.createContent": "Create content"
}

Important: Make sure to add the key and label to the EN - bundle.l10n.json file.

If you want to start using the localization labels in the web views, you must include the l10n dependency and LocalizationKey enum.

import * as l10n from "@vscode/l10n"
import { LocalizationKey } from '../../localization';

// Usage
l10n.t(LocalizationKey.panelActionsCreateContent)

@estruyf
Copy link
Owner

estruyf commented Jul 20, 2023

All the hardcoded strings have been moved over to the ./l10n/bundle.l10n.json EN localization file. The file contains the key/values for both the panel and the dashboard webviews.

@estruyf
Copy link
Owner

estruyf commented Jul 22, 2023

Commands and settings have also been localized. To support another language, create a new package.nls.<locale>.json file in the project's root and copy the contents of the package.nls.json file to it.

Todo

@estruyf
Copy link
Owner

estruyf commented Jul 26, 2023

@mayumih387, you can test out the latest v9 beta which includes your Japanese translations.

@mayumih387
Copy link
Contributor

Thank you @estruyf for your review at #598. I'll try the latest v9 beta and see if I can add further translations :)

@estruyf
Copy link
Owner

estruyf commented Aug 3, 2023

@gsegit I have added German translations (via OpenAI). Would you be able to give the latest beta a try and check if they are any good?

@gsegit
Copy link
Author

gsegit commented Aug 21, 2023

@gsegit I have added German translations (via OpenAI). Would you be able to give the latest beta a try and check if they are any good?

Hi there 🌞 sorry for the later answer, but i have total forget my post here 😅 Thanks you for your, i would test the translation in the next days 😎🌞

@gsegit
Copy link
Author

gsegit commented Aug 26, 2023

Hi there ;D
Wow, very great work and now the dokumention in german ;D No, is a joke, but I think you make a very good work and is now more easier to work with hugo or so ;D

Greetings
Gerriet
Have a nice Day ;D

@gsegit
Copy link
Author

gsegit commented Oct 31, 2023

Hi there
The problem is, in german give a formular "Sie" and informular "du", the translation have you make openAI, the KI make no different between sie or du. I like more "du". Better is the strings to write in a file, so can make a better translation, ok that is very hard work, but is better for user.

I hope you understand my englisch 🤣

@estruyf
Copy link
Owner

estruyf commented Oct 31, 2023

A lot of the German translations were manually provided by one of our contributors. If you see some mismatches or where translations can be enhanced, feel free to push changes via a PR, and we will be happy to merge them into the project.

The German translation file can be found here: https://github.com/estruyf/vscode-front-matter/blob/main/l10n/bundle.l10n.de.json

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

No branches or pull requests

3 participants