Skip to content

Conversation

@MartinSchoeler
Copy link
Member

@MartinSchoeler MartinSchoeler commented Aug 26, 2025

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 available

I've also added an example fixing a situation mentioned above.

CORE-1358

Summary by CodeRabbit

  • New Features

    • Added an i18n formatter that capitalizes string placeholders so translated terms at sentence starts display with correct capitalization.
  • Translations

    • Updated Brazilian Portuguese encryption messages to use the new capitalization formatter for room type wording, improving natural phrasing without changing behavior.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Aug 26, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Aug 26, 2025

⚠️ No Changeset found

Latest commit: dd3e54c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codecov
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.62%. Comparing base (4775ad1) to head (dd3e54c).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             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     
Flag Coverage Δ
e2e 57.79% <40.00%> (-0.03%) ⬇️
e2e-api 36.00% <ø> (+0.45%) ⬆️
unit 71.23% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MartinSchoeler MartinSchoeler marked this pull request as ready for review September 15, 2025 18:55
@MartinSchoeler MartinSchoeler requested a review from a team as a code owner September 15, 2025 18:55
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 15, 2025

Walkthrough

Registers a new i18n formatter named "capitalize" during i18n initialization and updates two pt-BR translation entries to apply that formatter to the roomType placeholder.

Changes

Cohort / File(s) Summary of Changes
i18n formatter registration
apps/meteor/client/providers/TranslationProvider.tsx
On i18n initialized, registers a capitalize formatter via i18n.services.formatter?.add; returns capitalize(value) for strings, otherwise returns the original value; registration guarded with optional chaining.
pt-BR locale capitalization
packages/i18n/src/locales/pt-BR.i18n.json
Updates Encrypted_RoomType and Encrypted_messages to use {{roomType, capitalize}} and adjusts surrounding spacing/ordering in the translated strings.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my whiskers at strings so bright,
A little hop to start each sentence right.
Formatter set, pt‑BR takes a bow,
Room types standing taller now.
I nibble bugs and bound—encore! 🥕

✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/i18n-capitalize

Comment @coderabbitai help to get the list of available commands and usage tips.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "chore: add capitalization formatter function to i18n" concisely and accurately summarizes the primary change in the PR — adding a capitalization formatter to the i18n system — which matches the code updates registering a formatter and the translation string adjustments. It is specific, clear, and follows conventional commit style so a reviewer scanning history will understand the main intent.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 expectations

The 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

📥 Commits

Reviewing files that changed from the base of the PR and between c5ee569 and ad095ed.

📒 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 casing

Attaching 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 correct

Good use of the capitalize formatter at sentence start and plain {{roomType}} mid‑sentence. No further changes needed here.

@dougfabris dougfabris added this to the 7.11.0 milestone Sep 15, 2025
Copy link
Member

@dougfabris dougfabris left a comment

Choose a reason for hiding this comment

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

@dougfabris dougfabris added the stat: QA assured Means it has been tested and approved by a company insider label Sep 15, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Sep 15, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between eec0ae0 and 441833b.

📒 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

@kodiakhq kodiakhq bot merged commit 1c6ee55 into develop Sep 15, 2025
86 of 90 checks passed
@kodiakhq kodiakhq bot deleted the feat/i18n-capitalize branch September 15, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants