elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.69k stars 8.12k forks source link

[i18n] Missing translation #181771

Open Heenawter opened 4 months ago

Heenawter commented 4 months ago

Describe the bug: Despite existing in the Kibana codebase for 4 years, the following translations are missing:

This is causing a bug in Dashboard (and anywhere where the overlay service's openConfirm is used) where, if a manual translation is not provided, the buttons are not translated:

image

(In the above screenshot, custom Confirm text was provided but custom Cancel text was not). Considering how long ago this code was added, I'm assuming these translations somehow fell through the cracks.

Steps to reproduce:

  1. Change the default language to 'zh-CN' in kibana.yml and launch Kibana
  2. Open a dashboard and cause unsaved changes
  3. Hit the reset button and notice that the Cancel button is not being translated despite being passed through the i18n service with the following key: core.overlays.confirm.cancelButton

Expected behavior: Both the Cancel and Confirm buttons should be translated without the consumer of openConfirm having to provide them - they should only need to provide them if they want custom text

More screenshots:

elasticmachine commented 4 months ago

Pinging @elastic/kibana-core (Team:Core)

afharo commented 4 months ago

I found the reason for the missing translations: Our message extractor checks for the explicit patterns i18n('a.message') or i18n.translate('a.message') (relevant code).

Any places renaming i18n to something else are not caught by our script 🙈 .

Using the regexes \s(?!i18n\.translate)\w+\.translate\( and import { i18n as I found all these occurrences (there might be more, though):

As a quick fix, we could revisit all those usages to follow the expected pattern. But we need to find a way to fix the script.

cc @Bamieh