Skip to content

[EUI] Improve EuiFilterButton badge i18n#5061

Merged
cee-chen merged 7 commits intoelastic:masterfrom
cee-chen:filter-button-badge-i18n
Aug 23, 2021
Merged

[EUI] Improve EuiFilterButton badge i18n#5061
cee-chen merged 7 commits intoelastic:masterfrom
cee-chen:filter-button-badge-i18n

Conversation

@cee-chen
Copy link
Contributor

@cee-chen cee-chen commented Aug 20, 2021

Summary

Partially addresses #4786 (Kibana's i18n_eui_mapping.tsx will need to be updated on next release upgrade as well to account for the i18n token changes).

This PR fixes the static active and available strings in our filter badge count aria-label not being properly translated. I originally went with the simpler fix in elastic/kibana#109333, but after feedback from Greg and Alejandro, I decided to remove the original conditional i18n string and instead split it up into 2 separate i18n strings, which I think will get translated more smoothly in different languages (vs. trying to chop it up based on English).

This PR also contains some slightly opinionated code cleanup (mostly variable naming/organization) - I recommend following along by commit!

Checklist

  • Jest unit tests should all pass as before / there should be no functional regression in the current English strings

- [ ] Check against all themes for compatibility in both light and dark modes
- [ ] Checked in mobile
- [ ] Checked in Chrome, Safari, Edge, and Firefox
- [ ] Props have proper autodocs and playground toggles
- [ ] Added documentation
- [ ] Checked Code Sandbox works for the any docs examples
- [ ] Added or updated jest tests
- [ ] Checked for breaking changes and labeled appropriately

  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

- Refactor `activeFilters` to `numActiveFiltersDefined` to be more consistent with existing `numFiltersDefined` var

- pull out showBadge conditional to make reading it a little clearer

- DRY out badgeCount var
- Rather than trying to conditionally chop up the i18n string into parts, it makes more sense (and likely makes for better translations) to have 2 separate labels that render conditionally based on state

+ Switch from i18n render prop to use hook
… together

- this feels more organized and easy to follow distinct groups of logic to me, but happy to revert if others disagree
@cee-chen
Copy link
Contributor Author

@chandlerprall @thompsongl Couple questions for you on this one!

  • Since this affects i18n translations only, does it need to be documented in our CHANGELOG? (It's also an i18n translation on an aria-label, making it kind of an interesting edge case)
  • Just to confirm - Chandler (or whoever is doing the next release) will handle updating the i18ntokens_changelog.json to note the 2 new i18n string and that the old deleted string, is that correct? Or do I need to do that in this PR?

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5061/

@thompsongl
Copy link
Contributor

does it need to be documented in our CHANGELOG?

Yes. Good to note for any consumer that might be using the tokens.

whoever is doing the next release) will handle updating the i18ntokens_changelog.json to note the 2 new i18n string and that the old deleted string, is that correct?

The release script automatically updates i18ntokens.json and i18ntokens_changelog.json, so no need to make updates here.

@cee-chen
Copy link
Contributor Author

Awesome, thanks Greg! I added a changelog entry in bc6a8a1 but not sure I totally nailed it or if it could use work - feel free to leave feedback! 😅

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5061/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5061/

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

LGTM! Converting to useEuiI18n makes this easier to read; thanks!

@cee-chen cee-chen enabled auto-merge (squash) August 23, 2021 14:53
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5061/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments