Skip to content

fix: Display native language name instead of English - #3218

Merged
hellofanny merged 3 commits into
feat/multilanguagefrom
fix/selecto-language-label
Feb 20, 2026
Merged

hellofanny merged 3 commits into
feat/multilanguagefrom
fix/selecto-language-label

Conversation

@hellofanny

@hellofanny hellofanny commented Feb 20, 2026 •

Copy link
Copy Markdown
Contributor

What's the purpose of this pull request?

Uses name instead of languageName to display the language's native name.

  • name – native language label: "português", "italiano", "English", "français"
  • languageName – English label: "Portuguese", "Italian", "English", "French"
before now
image image

How to test it?

  • Run the project locally and check if the locale selector shows the language native names.

References

https://vtex.slack.com/archives/C09CZGYTXEE/p1771515982049669

Summary by CodeRabbit

  • Improvements
    • Language selection now shows capitalized native locale names and appends region codes only when needed to disambiguate.
  • Tests
    • Updated test expectations and descriptions to match native-name labeling and capitalization.

@hellofanny
hellofanny requested a review from a team as a code owner February 20, 2026 18:24
@hellofanny
hellofanny requested review from eduardoformiga and lucasfp13 and removed request for a team February 20, 2026 18:24
@hellofanny hellofanny self-assigned this Feb 20, 2026
@hellofanny hellofanny added the enhancement New feature or request label Feb 20, 2026
@coderabbitai

coderabbitai Bot commented Feb 20, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉


Walkthrough

Refactors locale display name handling in the binding selector: adds a helper to capitalize native locale names and switches disambiguation and label construction to use locale.name (native name) with region codes appended only when needed.

Changes

Cohort / File(s) Summary
Localization Binding Selector
packages/core/src/sdk/localization/bindingSelector.ts
Added internal capitalizeFirst helper; changed logic to use locale.name (native name) for disambiguation, counting duplicates by locale.name, and formatting labels with capitalized native name plus region code when necessary.
Tests (label expectations updated)
packages/core/test/sdk/localization/useBindingSelector.test.tsx
Updated test descriptions, comments, and expectations to reflect labels using native names with capitalization (e.g., "Português (BR)" instead of "Portuguese (BR)"). No control-flow changes.
Manifest
package.json
Minor line changes recorded in manifest (metadata-level).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • lemagnetic
  • eduardoformiga
  • lariciamota

Poem

🌍 Native names wake and rise,
First letters crowned in gentle light,
Regions whisper only when tied,
Labels clear and neatly plied,
Small change, clearer sight. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: displaying native language names instead of English translations in the locale selector.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/selecto-language-label

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codesandbox-ci

codesandbox-ci Bot commented Feb 20, 2026 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@hellofanny
hellofanny requested review from lariciamota and lemagnetic and removed request for lucasfp13 February 20, 2026 18:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/core/src/sdk/localization/bindingSelector.ts (1)

6-9: capitalizeFirst: str.charAt(0) is not Unicode-safe for astral-plane characters.

charAt + slice operate on UTF-16 code units. For a locale whose native name starts with a character outside the BMP (an astral-plane codepoint represented as a surrogate pair), the first surrogate would be uppercased in isolation and the second code unit detached, producing a garbled string. For all practical language names today this never triggers, but it's trivial to make it future-proof:

♻️ Spread-based Unicode-safe alternative
 function capitalizeFirst(str: string): string {
   if (!str) return str
-  return str.charAt(0).toUpperCase() + str.slice(1)
+  const [first, ...rest] = [...str]
+  return first.toUpperCase() + rest.join('')
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/src/sdk/localization/bindingSelector.ts` around lines 6 - 9,
The capitalizeFirst function is not Unicode-safe because charAt(0)/slice operate
on UTF-16 code units; update capitalizeFirst to operate on Unicode code points
by converting the string into an array of grapheme/codepoint elements (e.g.,
Array.from or spread [...str]), return early on empty input, uppercase the first
element with toUpperCase(), then rejoin the remainder with join('') to produce a
correct Unicode-safe result; reference the existing function name
capitalizeFirst to locate and replace the implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/core/src/sdk/localization/bindingSelector.ts`:
- Around line 21-35: The tests fail because buildLanguageOptions now returns
native language names (capitalizeFirst(locale.name)) with region disambiguation;
update the assertions in useBindingSelector.test.tsx to match the native names
produced by buildLanguageOptions—change the expectations for languages['pt-BR']
and languages['pt-PT'] to "Português (BR)" and "Português (PT)" respectively,
and change languages['fr-FR'] to "Français" so the test matches the new output
format.

---

Nitpick comments:
In `@packages/core/src/sdk/localization/bindingSelector.ts`:
- Around line 6-9: The capitalizeFirst function is not Unicode-safe because
charAt(0)/slice operate on UTF-16 code units; update capitalizeFirst to operate
on Unicode code points by converting the string into an array of
grapheme/codepoint elements (e.g., Array.from or spread [...str]), return early
on empty input, uppercase the first element with toUpperCase(), then rejoin the
remainder with join('') to produce a correct Unicode-safe result; reference the
existing function name capitalizeFirst to locate and replace the implementation.

@hellofanny
hellofanny merged commit 636fff3 into feat/multilanguage Feb 20, 2026
2 checks passed
@hellofanny
hellofanny deleted the fix/selecto-language-label branch February 20, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants