fix(i18n): replace manual pluralize() with i18next count-based plurals#17760
Conversation
Several files in the i18n allowlist still call the manual pluralization helpers
(`pluralize` / `forcePluralize`) from `@app/shared/textUtil`. Those helpers
hardcode English plural rules (a naive `+s` plus a small irregular map), so the
text they produce can never be localized correctly — other locales have
different plural categories and word forms.
Migrate these call sites to i18next's native count-based plural keys
(`_one` / `_other`), letting each locale own its plural forms, and drop the
now-unused textUtil imports:
- entity.types: shared.assetTypeNameCount — entity-count card tooltips in the
application / data product Assets sections and the domain Contents section
- entity.shared.containers: sidebar.entityTypeCount — Container, Domain, and
Lineage sidebar summaries ("{count} {type}"); sidebar.ownership.type.pluralName
— ownership type fallback label
- ingestion: source.entityTypeNameCount — ingestion source facet display name
EN-only (no DE) per the i18n extraction convention.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
🔴 Meticulous spotted visual differences in 16 of 1423 screens tested: view and approve differences detected. Meticulous evaluated ~10 hours of user flows against your PR. Last updated for commit |
Bundle ReportChanges will increase total bundle size by 1.0kB (0.0%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: datahub-react-web-esmAssets Changed:
Files in
Files in
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…g call sites Add the `no-manual-pluralize-in-i18n` ESLint rule (scoped via .eslintrc.js to the i18n allowlist) so the manual pluralization helpers (`pluralize` / `forcePluralize` / `pluralizeIfIrregular`) can't be reintroduced into already-translated files — they hardcode English plural rules and can't be localized. Enabling the rule surfaced two more allowlisted files still using the helpers; migrate them to i18next keys in the `search` namespace: - searchV2/matches/MatchedFieldList.tsx → matches.matchedField.fieldLabelCount (count-based `_one`/`_other`) - searchV2/filters/utils.tsx → filters.pluralizedTypeLabel (always-plural label) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Several files that are already in the i18n allowlist still call the manual
pluralization helpers (
pluralize/forcePluralize/pluralizeIfIrregular)from
@app/shared/textUtil. Those helpers hardcode English plural rules (anaive
+ssuffix plus a small English-only irregular map), so the text theyproduce can never be localized correctly — other locales have different plural
categories and word forms.
This PR:
(
_one/_other) or simple interpolation, so each locale owns its ownplural forms, and removes the now-unused
textUtilimports.no-manual-pluralize-in-i18n(scoped via.eslintrc.jsto the i18n allowlist), so these helpers can't bereintroduced into translated files going forward.
EN-only (no DE) per the i18n extraction convention.
Keys added
entity.types:shared.assetTypeNameCountentity.shared.containers:sidebar.entityTypeCount,sidebar.ownership.type.pluralNameingestion:source.entityTypeNameCountsearch:matches.matchedField.fieldLabelCount,filters.pluralizedTypeLabelFiles migrated
entityV2/application/AssetsSections.tsx,entityV2/dataProduct/AssetsSections.tsx,entityV2/domain/summary/ContentsSection.tsx— entity-count card tooltipsentityV2/shared/containers/profile/sidebar/{Container,Domain,Lineage}/utils.tsx—"{count} {type}" sidebar summaries
entityV2/shared/containers/profile/sidebar/Ownership/ownershipUtils.ts—ownership-type fallback label
ingestV2/source/utils.ts— ingestion source facet display namesearchV2/matches/MatchedFieldList.tsx— matched-field labelsearchV2/filters/utils.tsx— filter option labels (entity type / subtype)Pages to verify
Checklist
tsc --noEmit, and Prettier pass🤖 Generated with Claude Code