Add zh-CN.json translations and respective compatibility checks via i18n tools#30378
Conversation
…ations file compatibility check.
|
Pinging @elastic/kibana-platform |
| "x-pack/plugins/infra/server/graphql/types.ts", | ||
| "x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts" | ||
| ], | ||
| "translations": [ |
There was a problem hiding this comment.
note: we need to track these files somewhere for a compatibility checks and automatic fixes.
💚 Build Succeeded |
zh-CN.json translations and respective compatibility via i18n toolszh-CN.json translations and respective compatibility checks via i18n tools
| await readFileAsync(resolve(configPath)) | ||
| ); | ||
|
|
||
| for (const [namespace, path] of Object.entries(additionalConfig.paths || [])) { |
There was a problem hiding this comment.
I think it is neater to merge defaults when defining additionalConfig instead of having || statements in the for statements
|
|
||
| /** | ||
| * Filters out custom paths based on the paths defined in config and that are | ||
| * known to contain 1i8n strings. |
There was a problem hiding this comment.
| * known to contain 1i8n strings. | |
| * known to contain i18n strings. |
| const mockMakeDirAsync = jest.fn(); | ||
| jest.mock('./utils', () => ({ | ||
| // Jest typings don't define `requireActual` for some reason. | ||
| ...(jest as any).requireActual('./utils'), |
There was a problem hiding this comment.
(ignore this; just a general note)
Weird it is in the DefinitelyTyped definition, maybe on a newer version.
There was a problem hiding this comment.
Yeah, we need to update our jest types at some point (and jest as well).
|
|
||
| const missingTranslations = difference(defaultMessagesIds, localizedMessagesIds); | ||
| if (!options.ignoreMissing && missingTranslations.length > 0) { | ||
| errorMessage += `\n${ |
There was a problem hiding this comment.
Maybe moving the missingTranslations definition line inside the options.ignoreMissing condition is better to avoid evaluating for nothing?
💚 Build Succeeded |
Fixes #30143
The only non-dev thing that this PR includes is the file with translations (
zh-CN.json), the rest are changes in i18n dev tools that can help us to maintainzh-CN.jsonin master as compatible to the new changes as possible.List of notable changes:
zh-CN.jsonforward-ported from 6.7 branchi18n_checktoi18n_extractand introduced newi18n_checkbased oni18n_extractandi18n_integrate--ignore-unused,--ignore-missingand--ignore-incompatibleoptions to bothi18n_checkandi18n_integrate(see docs for more details)translationsfield to.i18nrc.jsonto know which files exactly we should use in compatibility checks--targetparameter fori18n_integrateto store all translations inside of a single file to supportx-pack/translations(without this option, translations file is split and distributed across plugin folders based on mappings defined in.i18nrc.json)On CI we'll run (
--ignore-missingto not complain about new non-translated labels):The command above will do the following checks:
translationsfrom.i18nrc.jsonand compare them to the messages extracted and validated at the step above and:2.1 Check for unused translations - if developer removed a label which has corresponding translation they will need to remove this label from translations file as well, semi-automatic for now (see below)
2.2 Check for incompatible translations - if developer, let's say removed or added new parameter to an existing string, they will need to remove this label from translations file.
To fix 2.1 and 2.2 (assuming changes are intentional), one should run the following command:
That is currently expanded into the following command under the hood (simplified):
We can tune defaults once we get feedback, let's see.
To integrate files we receive from translators right now, one can use the following command:
The
ignore-*options shouldn't be used when integrating into the same revision from whichen.jsonwas created otherwise we may miss some errors that were done during translation.