-
Notifications
You must be signed in to change notification settings - Fork 667
Add i18n to topology package #7315
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
Add i18n to topology package #7315
Conversation
|
/retest |
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.
🤔 There is a pattern that can be used here...
Quick search through the codebase got me:
"teams-help": "Optionally list organizations. If specified, only GitHub users that are members of at least one of the listed organizations will be allowed to log in. Cannot be used in combination with <1>teams</1>.",
And:
<Trans i18nKey="teams-help" ns="github-idp-form">
Optionally list organizations. If specified, only GitHub users that are members of at
least one of the listed organizations will be allowed to log in. Cannot be used in
combination with <strong>teams</strong>.
</Trans>
Ref: github-idp-form.tsx
cc @christianvogt might know more -- I'm reverse engineering here.
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.
Interesting, you put t at the start of other methods 🤔
I have no opinion one way or another, just thought it was noteworthy.
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 should be one translation otherwise it won't come out properly in other languages.
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.
Not sure I understand what is happening here... why this change? Seems like new functionality for an I18n PR.
christianvogt
left a comment
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.
Overall I question the use of passing around t over simply using the global translation function when the translation of errors isn't reactive anyways.
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 isn't necessary. It seems like the only reason for translation is related to error messages.
These error messages can be translated using the global i18next object because there's no way these will be reactive anyways to a change in locale. We wouldn't be running the callback again with the new lang so therefore it's a one time translation.
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.
You should use labelKey for actions.
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.
Unnecessary to pass t here because the modal has access to useTranslation or withTranslation.
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.
You should use labelKey for actions.
Same comment for all actions.
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'd prefer to have confirmModal accept a callback which is either executed in the render context so that the function can use useTranslation or it gets passed in the translation function. This would make it easier to use these modal launchers without the need for the consumer to provide it's own t function.
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.
Again it seems we're passing around t to localize the return value of async operations that won't be re-run if the locale changes.
Seems unnecessary to pass t around everywhere for this and instead use the global i18next
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.
The API accepts a ReactNode. TopologyShortcuts can make use of useTranslation
| bodyContent={getTopologyShortcuts(t)} | |
| bodyContent={<TopologyShortcuts />} |
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.
Use useTranslation instead.
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.
Use useTranslation instead.
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.
Actions can use labelKey
dd486e1 to
ef896bb
Compare
|
@andrewballantyne Side bar is part of public/components/overview (not topology). I believe I have addressed other comments. |
ef896bb to
4373009
Compare
|
/retest |
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.
@jeff-phillips-18 Missed this Merge conflict marker encountered.
4373009 to
6f69e98
Compare
andrewballantyne
left a comment
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.
Not sure I misunderstand Trans vs t ... but I think you can use t for all strings, and Trans when React components or DOM elements get in the way
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 we still need the space 🤔
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.
Don't think you need to use Trans on static strings 🤔
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.
Same here
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.
Same here
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.
Same here
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.
Same here
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.
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.
vikram-raj
left a comment
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.
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.
| labelKey: 'Edit Health Checks', | |
| labelKey: 'console-app~Edit Health Checks', |
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.
| return <Link to={href}>{t('topology~{{ready}} of {{desired}} pods', { ready, desired })}</Link>; | |
| return <Link to={href}>{t('topology~{{ready, number}} of {{count, number}} pod', { ready, count: desired })}</Link>; |
6f69e98 to
36e3932
Compare
|
@andrewballantyne @vikram-raj Updated per comments. |
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.
| return <Link to={href}>{t('topology~{{length}} pods', { length: filteredPods.length })}</Link>; | |
| return <Link to={href}>{t('topology~{{count, number}} pod', { count: filteredPods.length })}</Link>; |
andrewballantyne
left a comment
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.
/lgtm
|
/approve |
36e3932 to
e60f94e
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewballantyne, christianvogt, jeff-phillips-18 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |













Fixes: https://issues.redhat.com/browse/ODC-5130