-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Guideline for i18n engine #20620
Guideline for i18n engine #20620
Conversation
💚 Build Succeeded |
💚 Build Succeeded |
💔 Build Failed |
retest |
💔 Build Failed |
retest |
💔 Build Failed |
💔 Build Failed |
💚 Build Succeeded |
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doc is really helpful, thanks for putting it together! I put a couple note inline, but some of my comments apply more globally so I figured I would list them here than repeating them over and over inline.
-
I think we should be consistent with the "message ids" name. In some places we say "message ids", in others "The IDs (names) chosen for message keys", and sometimes "key ID". Since we're using a
<FormattedMessage />
component with anid
prop, I think "message id" is the most logical choice. -
Would you mind replacing all of the
“”
(fancy quotes) with simple quote marks"
? -
Nit: Inline code snippets only need two backtick (`) in special cases, would you mind converting the unnecessary double-backticks to singles?
-
Optional Nit: In several places inline code snippets and quotes are mixed. I think most cases should be either one or the other.
-
Question: Is it too late to discuss the format for complex messages? What if instead of:
kbn.management.editIndexPattern.scripted.deprecationLangLabel.deprecationLangDetail kbn.management.editIndexPattern.scripted.deprecationLangLabel.painlessLink
we did something like:
kbn.management.editIndexPattern.scripted.deprecationLangLabel kbn.management.editIndexPattern.scripted.deprecationLangLabel.painlessLink
This structure is a little less redundant and I think it indicates that the the
deprecationLangLabel
message is complex, and thepainlessLink
message goes within it.
packages/kbn-i18n/GUIDELINE.md
Outdated
This phrase contains a variable, which represents languages list, and a link (``Painless``). For such cases we divide the message into two parts: the main message, which contains placeholders, and additional message, which represents inner message. | ||
|
||
It is used the following id naming structure: | ||
1) the main message id has the type on the second-to-last position, thereby identifying a divided phrase, and the last segment ends with ``Detail``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure what second-to-last
is referring to here.
packages/kbn-i18n/GUIDELINE.md
Outdated
|
||
After translation we get the following structure: | ||
```js | ||
<FormattedMessage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm super excited by this 😄
packages/kbn-i18n/GUIDELINE.md
Outdated
|
||
Each message id should end with a type of the message. For example: | ||
|
||
- for header: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this section would be more effective if we just listed the message ids and the types. Showing full examples is a little out of scope for what this section is trying to document and makes the actual content a little harder to spot. I think a table presents the information quite nicely:
type | example message id |
---|---|
header | kbn.management.createIndexPatternHeader |
label | kbn.management.createIndexPatternLabel |
button | kbn.management.editIndexPattern.scripted.addFieldButton |
drop down | kbn.management.editIndexPattern.fields.allTypesDropDown |
placeholder | kbn.management.createIndexPattern.stepTime.options.patternPlaceholder |
aria-label attribute |
kbn.management.editIndexPattern.removeAria |
tooltip | kbn.management.editIndexPattern.removeTooltip |
error message | kbn.management.createIndexPattern.step.invalidCharactersErrorMessage |
toggleSwitch | kbn.management.createIndexPattern.includeSystemIndicesToggleSwitch |
packages/kbn-i18n/GUIDELINE.md
Outdated
i18n-values="{ conflictFieldsLength: conflictFields.length }"></span> | ||
``` | ||
|
||
In case when `conflictFieldsLength` has value 1, the result string will be `"A field is defined as several types (string, integer, etc) across the indices that match this pattern."`. In case when `conflictFieldsLength` has value 2 or more, the result string - `"2 fields are defined as several types (string, integer, etc) across the indices that match this pattern."`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case when
conflictFieldsLength
has value 1
How about
When `conflictFieldsLength` equals 1
or
In cases where the `conflictFieldsLength` has a value of 1
Same for "In case when conflictFieldsLength
has value 2"
packages/kbn-i18n/GUIDELINE.md
Outdated
|
||
### Unit tests | ||
|
||
Additional adjustments in unit tests are needed only for those components where `injectI18n` component is used. Due to `injectI18n` wraps the target component and passes `intl` via `props`, in tests it is requires to render the target component with `intl` object. That required the rendering the target component using `shallowWithIntl` function from `'test_utils/enzyme_helpers'`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional adjustments in unit tests are needed only for those components where
injectI18n
component is used. Due toinjectI18n
wraps the target component and passesintl
viaprops
, in tests it is requires to render the target component withintl
object. That required the rendering the target component usingshallowWithIntl
function from'test_utils/enzyme_helpers'
.
I think this reads better as:
When testing React component that use the injectI18n
higher-order component, use the shallowWithIntl
helper function defined in test_utils/enzyme_helpers
to render the component. This will shallow render the component with Enzyme and inject the necessary context and props to use the intl
mock defined in test_utils/mocks/intl
.
Do you think we should describe what people should do when they want full rendering rather than shallow rendering?
…for js strings, fix description for testing, use uniq "message id" name
@spalger thank you for such detailed review!
|
💔 Build Failed |
💔 Build Failed |
retest |
💔 Build Failed |
packages/kbn-i18n/GUIDELINE.md
Outdated
|
||
```js | ||
<p> | ||
The following deprecated languages are in use: {deprecatedLangsInUse.join(', ')}. Support for these languages will be removed in the next major version of Kibana and Elasticsearch. Convert you scripted fields to <EuiLink href={painlessDocLink}>Painless</EuiLink> to avoid any problems. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
misspelling: Convert your scripted fields
packages/kbn-i18n/GUIDELINE.md
Outdated
This phrase contains a variable, which represents languages list, and a link (`Painless`). For such cases we divide the message into two parts: the main message, which contains placeholders, and additional message, which represents inner message. | ||
|
||
It is used the following message id naming structure: | ||
1) the main message id has the type on the penultimate position, thereby identifying a divided phrase, and the last segment ends with `Detail`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace: extra space before Detail
packages/kbn-i18n/GUIDELINE.md
Outdated
|
||
```js | ||
{ | ||
'kbn.management.editIndexPattern.scripted.deprecationLangLabel.deprecationLangDetail': 'The following deprecated languages are in use: {deprecatedLangsInUse}. Support for these languages will be removed in the next major version of Kibana and Elasticsearch. Convert you scripted fields to {link} to avoid any problems.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
misspelling: your
packages/kbn-i18n/GUIDELINE.md
Outdated
'kbn.management.editIndexPattern.scripted.table.nameDescription' | ||
``` | ||
|
||
- For complex messagges, that is divided into several parts, use the folllowing approach: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammar: that are divided into several parts
misspelling: messages, following
packages/kbn-i18n/GUIDELINE.md
Outdated
- the main message id should have the type on the penultimate position, thereby identifying a divided phrase, and the last segment should end with `Detail`, | ||
- the inner message id should have the type on the penultimate position and the name of the variable from the placeholder in the main message as the last segment that ends with its own type. | ||
|
||
For example before the translation there was a message: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grammar: For example , before (comma reads better)
packages/kbn-i18n/GUIDELINE.md
Outdated
|
||
```js | ||
<strong>Success!</strong> | ||
Your index pattern matches <strong>{exactMatchedIndices.length} {exactMatchedIndices.length > 1 ? 'indices' : 'index'}</strong>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this ternary is wrong for english. plural is used for everything but the number 1. so it should be {exactMatchedIndices.length === 1 ? 'index' : 'indices'}
packages/kbn-i18n/GUIDELINE.md
Outdated
|
||
`The following dialogue box indicates progress. You can close it and the process will continue to run in the background.` | ||
|
||
If this sentence is separated it’s possible that the context of the `'it'` in `'close it'` will be lost. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's a better word to use here than "sentence" to describe a group. How about paragraph? Or "sentence or group of sentences"? Since the example there is actually two sentences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of nits. Curious what you think, and then I can give another pass through
💚 Build Succeeded |
I'm referring to things like I think there's a totally legit argument to be made that comments like:
are identifying a code snippet of a string, as described, so mixing the quotes and code snippet works, but the actual comment is:
where the quotes are on the outside of the code snippet and the That said, I'm being SUPER nit-picky with this one 😝 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this!
* Add Guideline for i18n engine * Update Guideline according to changes in i18n engine. * Update examples in Guideline * typo * improve i18n guideline: add table for better view, use single quotes for js strings, fix description for testing, use uniq "message id" name * fix readme description for guideline Co-authored-by: maryia-lapata "mary.lopato@gmail.com"
* Add Guideline for i18n engine * Update Guideline according to changes in i18n engine. * Update examples in Guideline * typo * improve i18n guideline: add table for better view, use single quotes for js strings, fix description for testing, use uniq "message id" name * fix readme description for guideline Co-authored-by: maryia-lapata "mary.lopato@gmail.com"
6.x/6.5: d7b1802 |
It's a guideline for using
@kbn/i18n
module.#20074