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

feat(ui): Add multi-language support for kopia-ui #241

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

Conversation

lupusA
Copy link
Collaborator

@lupusA lupusA commented Mar 8, 2024

Hi,

this PR adds the multi-language support feature to kopia-ui. Users can select their language in the preference tab.
The following languages are supported:

  • English
  • German
  • French
  • Polish
  • Russian
  • Italian
  • Spanish
  • Japanese (Maybe)

This PR also adds new libaries and dependencies (i18next, react-i18next, i18next-http-backend)
The PR will close kopia/kopia#3708 and has a dependency to kopia/kopia#3768.

Tasks to be resolved:

  • Language selector should probably use a flag + always language's own name in own script
  • Language selector should be located in upper-right corner and be always visible so that users can immediately switch to their language with 2 clicks
  • i18next needs to be initialized first before rendering
  • Navbar needs to be refreshed when changing language. Potentially we need a change as the component is updated via context currently.
  • Provide a full (machine-based) translation for the mentioned languages
  • Can we make the drop-down only show the flag icon for the selected language when not expanded?
  • Select component has a bug with empty string (getElementyByID) which needs to be fixed
  • Auto-select the language based on browser/OS regional settings
  • Add a build-test that ensures that all translations are always available in all languages
  • Document the process for adding new text in the UI (which will need translations)
  • Add a translation guide that explains the context in which each text appears (e.g. the word "Stop" can be a verb or a noun)
  • Extract languages and put it in "language.name" that's specified only in a single JSON file
  • Ideally listing language should collect all JSON files to ease the addition of new languages
  • Check for plugin that will flag all string literals that are not translated
  • Check support for localized string formatting

Cheers,

@lupusA lupusA requested a review from jkowalski March 8, 2024 16:56
@jkowalski
Copy link
Contributor

jkowalski commented Mar 9, 2024

This is promising, i took it for a quick spin. Some first impressions/questions/ideas:

  • language selector should probably use a flag + always language's own name in own script (so it's 🇬🇧 English 🇩🇪 Deutsch, 🇵🇱 polski, 🇷🇺 Русский)

  • i don't undeerstand why Language is its own section in Preferences, it probably just makes sense to put the language selector in upper-right corner and be always visible so that folks can immediately switch to their language with 2 clicks.

  • translating some terminology will be hard

  • I will try to translate this into Polish (looks very difficult)

  • can this auto-select the language based on browser/OS regional settings?

  • instead of adding all those languages initially we should start with 3-4 languages folks on core team can speak natively and provide translations for

  • can we add a build-test that ensures that all translations are always available in all languages?

  • we should probably we add a test that ensures all i18n.t have corresponding entries in JSON files? also, dangling translations that are no longer used and/or lists missing words

  • what should be the process for adding new text in the UI (which will need translations)?

  • we should add a translation guide that explains the context in which each text appears (e.g. the word "Stop" can be a verb or a noun)

  • the following should be replaced with a single "language.name" that's specified only in a single JSON file, so that adding a new language requires only specifying its own native name and not updating any other translations.

	"lang.en": "English",
	"lang.de": "German",
	"lang.es": "Spanish",
	"lang.fr": "French",
	"lang.ru": "Russian",
	"lang.jp": "Japanese",
	"lang.it": "Italian",
	"lang.pl": "Polish",
  • ideally listing language should collect all JSON files, instead of hardcoding it, so that it's easier to add new languages.
  • there's a lot of hard cases where we build strings dynamically, including formatting of time, etc, in particular in the policy editor and snapshot list

@jkowalski
Copy link
Contributor

@lupusA this is looking very nice, I found a few minor things:

  1. the language selector needs to be wider and/or have non-breaking spaces between the flag and the text, otherwise i'm seeing this:

image

  1. Can we make the drop-down only show the flag icon for the selected language when not expanded?

  2. After changing the language, some the translations take ~3-5s to change. We probably need to trigger some additional refresh.

@@ -0,0 +1,96 @@
{
"tab.preferences": "Preferencias",
"tab.repository": "Repositorio",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"tab.repository": "Repositorio",
"tab.repository": "Depósito",

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess either one works.

"tab.repository": "Repositorio",
"tab.tasks": "Tareas",
"tab.policies": "Políticas",
"tab.snapshots": "Instantáneas",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure what a good word would be here, but "Instantáneas" does not work.

I would probably say something like "copias de respaldo"

"snapshot.header.snapshot.next": "Siguiente instantánea",
"snapshot.header.snapshot.last": "Última instantánea",
"snapshot.header.snapshot.size": "Tamaño",
"snapshot.header.snapshot.owner": "Propietario",
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is shorter

Suggested change
"snapshot.header.snapshot.owner": "Propietario",
"snapshot.header.snapshot.owner": "Dueño",


"user.interface": "Interfaz de usuario",
"user.interface.appearance": "Apariencia",
"user.interface.appearance.hint": "Selecciona el tamaño de fuente",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"user.interface.appearance.hint": "Selecciona el tamaño de fuente",
"user.interface.appearance.hint": "Selecciona el tamaño de letra",

"repository.event.connection.disconnect": "Desconectar del repositorio",
"repository.event.description.update": "Actualizar descripción",
"repository.feedback.description.required": "La descripción del repositorio es obligatoria",
"repository.feedback.read.only": "El repositorio es de solo lectura",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"repository.feedback.read.only": "El repositorio es de solo lectura",
"repository.feedback.read.only": "El repositorio es de sólo lectura",

@lupusA
Copy link
Collaborator Author

lupusA commented Mar 12, 2024

@lupusA this is looking very nice, I found a few minor things:

1. the language selector needs to be wider and/or have non-breaking spaces between the flag and the text, otherwise i'm seeing this:

image

2. Can we make the drop-down only show the flag icon for the selected language when not expanded?

3. After changing the language, some the translations take ~3-5s to change. We probably need to trigger some additional refresh.

There are a couple of things that aren't perfect right now. I will try to fix them first and add them to the list.
Thanks for the feedback.

Cheers,

@lupusA lupusA self-assigned this Mar 22, 2024
@NavyStack
Copy link

Could you kindly consider adding support for Korean as well? I'll be responsible for translating into Korean.
Additionally, I'm also capable of providing Japanese translations.

@lupusA
Copy link
Collaborator Author

lupusA commented Apr 6, 2024

Hi @NavyStack,

supporting additional languages will be easy. You just have to create a PR with the translation and a little adjustment to the language.json file. Thats all :-)

@NavyStack
Copy link

Thanks! I will make a PR soon.

@lupusA
Copy link
Collaborator Author

lupusA commented Apr 6, 2024

Thanks! I will make a PR soon.

By the way, japenese will be added in the initial commit. But it will be a machine-based translation :-)

Cheers,

@NavyStack
Copy link

@lupusA
Opened a PR that reflects the Korean translation.
Please confirm. lupusA#1

We tried to be consistent with words and distinguish subtle differences in meaning.
Where possible, please put full stops in the original English text.

Thanks.

@hudishijie
Copy link

考虑中文么

@mcthesw
Copy link

mcthesw commented Apr 16, 2024

I can be responsible for translating Simplified Chinese.
Chinese can generally be divided into Simplified Chinese and Traditional Chinese. So how should I fill in the code and value in languages.json? I usually see Simplified Chinese represented as zh-CN and Traditional Chinese represented as zh-HK

@lupusA
Copy link
Collaborator Author

lupusA commented Apr 16, 2024

I will work on it again next week. I am currently busy in private matters.

I need to refactor the translation keys again, to provide a good basis for further translations.

@NavyStack
I will incorporate your changes as well.

@NavyStack
Copy link

@lupusA ,
Don't worry about the Korean translation.
Even if you make a lot of changes, the Korean translation will be quick.

Cheers.

@NavyStack
Copy link

@lupusA I will be reset hard from English key.

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