-
Notifications
You must be signed in to change notification settings - Fork 13k
chore: add capitalization formatter function to i18n #36800
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
Conversation
|
Looks like this PR is ready to merge! 🎉 |
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #36800 +/- ##
===========================================
+ Coverage 66.57% 66.62% +0.05%
===========================================
Files 3344 3344
Lines 114634 114639 +5
Branches 21089 21094 +5
===========================================
+ Hits 76314 76378 +64
+ Misses 35635 35549 -86
- Partials 2685 2712 +27
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
WalkthroughRegisters a new i18n formatter named "capitalize" during i18n initialization and updates two pt-BR translation entries to apply that formatter to the Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App as App Startup
participant TP as TranslationProvider
participant I18n as i18n Core
participant View as UI Component
App->>TP: initialize TranslationProvider
TP->>I18n: subscribe to "initialized"
I18n-->>TP: emit initialized
TP->>I18n: add formatter "capitalize"(value)
Note right of I18n #D5E8D4: Formatter registered
View->>I18n: t("Encrypted_messages", { roomType })
I18n->>I18n: if value is string -> apply "capitalize"
I18n-->>View: localized string with capitalized roomType
View-->>App: render localized text
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
✨ Finishing touches🧪 Generate unit tests
Comment Pre-merge checks✅ Passed checks (3 passed)
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/i18n/src/locales/pt-BR.i18n.json (1)
1903-1903: Remove dangling trailing space; verify concatenation expectationsThe value ends with a trailing space, which can cause double spaces when composed with adjacent strings. Also confirm a leading space isn’t required by callers (the old string appeared to include one). Prefer no leading/trailing spaces in i18n values; let templates handle spacing.
Apply this diff:
- "Encrypted_RoomType": "{{roomType, capitalize}} criptografado ", + "Encrypted_RoomType": "{{roomType, capitalize}} criptografado",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/meteor/client/providers/TranslationProvider.tsx(1 hunks)packages/i18n/src/locales/pt-BR.i18n.json(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/meteor/client/providers/TranslationProvider.tsx (1)
apps/meteor/app/utils/lib/i18n.ts (1)
i18n(5-5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Builds matrix rust bindings against alpine
- GitHub Check: CodeQL-Build
- GitHub Check: CodeQL-Build
🔇 Additional comments (2)
apps/meteor/client/providers/TranslationProvider.tsx (1)
115-124: Register formatter deterministically and use locale-aware casingAttaching the listener to 'initialized' risks missing the event — register the formatter immediately and use locale-aware casing (toLocaleUpperCase(lng)). Verify i18next / i18next-formatter are present or add an interpolation.format fallback.
File: apps/meteor/client/providers/TranslationProvider.tsx (lines 115-124)
Apply this diff:
- // In some cases, the language will require a word to be in a different position than the default - // This enables the capitalization of words that are moved to the start of the sentence directly in the translation file - i18n.on('initialized', () => { - i18n.services.formatter?.add('capitalize', (value) => { - if (typeof value !== 'string') { - return value; - } - return value.charAt(0).toUpperCase() + value.slice(1); - }); - }); + // Enables capitalization of words moved to the start of a sentence directly in the translation file. + // Register immediately after init to avoid missing the 'initialized' event. + i18n.services.formatter?.add('capitalize', (value, lng) => { + if (typeof value !== 'string') { + return value; + } + return value.slice(0, 1).toLocaleUpperCase(lng) + value.slice(1); + });packages/i18n/src/locales/pt-BR.i18n.json (1)
1913-1913: Formatter usage looks correctGood use of the capitalize formatter at sentence start and plain {{roomType}} mid‑sentence. No further changes needed here.
dougfabris
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/i18n/src/locales/pt-BR.i18n.json (2)
1896-1896: Trim trailing whitespace.There’s a trailing space at the end of the value; it may leak to UI.
- "Encrypted_RoomType": "{{roomType, capitalize}} criptografado ", + "Encrypted_RoomType": "{{roomType, capitalize}} criptografado",
1906-1907: LGTM; formatter use is correct.Optional: to avoid gender mismatches across room types, consider a neutral phrasing (e.g., “{{roomType, capitalize}} com criptografia de ponta a ponta…”).
Please verify in-app that the new “capitalize” formatter is registered before these keys load so the first token renders capitalized at runtime.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/i18n/src/locales/pt-BR.i18n.json(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: 📦 Build Packages
- GitHub Check: CodeQL-Build
- GitHub Check: CodeQL-Build

Proposed changes (including videos or screenshots)
Adds a function to capitalize words directly from the i18n file, I've added this since sometimes when a language changes, the position of an Interpolated value can move to the start of the sentence, needing capitalization. It would not make sense to add conditional values directly on the logic that calls the
t()function given the amount of languages we have availableI've also added an example fixing a situation mentioned above.
CORE-1358
Summary by CodeRabbit
New Features
Translations