Skip to content

fix(i18n): load server namespaces by kebab-case#30368

Merged
hyoban merged 1 commit intomainfrom
fix/server-i18n-namespace-loader
Dec 30, 2025
Merged

fix(i18n): load server namespaces by kebab-case#30368
hyoban merged 1 commit intomainfrom
fix/server-i18n-namespace-loader

Conversation

@lyzno1
Copy link
Member

@lyzno1 lyzno1 commented Dec 30, 2025

Summary

  • Load server i18n JSON files by kebab-case filenames while keeping camelCase namespaces internally.

Context

After PR #30336, getTranslation camelCases namespaces before calling loadNamespaces. The server backend then builds import paths like ../i18n/${language}/${namespace}.json, which becomes datasetSettings.json for dataset-settings. That file doesn't exist, so server translations for dashed namespaces fail.

Repro

  1. Ensure the locale cookie is set (e.g., zh-Hans).
  2. Open /datasets/<id>/settings (uses dataset-settings).
  3. Server tries to load datasetSettings.json and misses; translations fall back to keys.

Fix

  • Convert the backend namespace to kebab-case before building the import path.
Copilot AI review requested due to automatic review settings December 30, 2025 07:09
@lyzno1 lyzno1 requested a review from iamjoel as a code owner December 30, 2025 07:09
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Dec 30, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lyzno1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the server-side internationalization (i18n) system where translation files were not being loaded correctly due to a mismatch in naming conventions. Previously, the system attempted to load i18n JSON files using camelCase namespaces, but the physical files were stored in kebab-case. This fix introduces a conversion step to ensure that the server correctly resolves and loads the appropriate translation files, thereby preventing fallback to raw translation keys and ensuring a consistent user experience.

Highlights

  • Internationalization (i18n) Fix: Corrected server-side i18n file loading to use kebab-case filenames for JSON resources, resolving an issue where camelCase namespaces were incorrectly used to construct file paths.
  • Namespace Handling: Ensured that while namespaces are handled internally in camelCase, the actual file lookup for i18n resources on the server now correctly converts them to kebab-case before import.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a bug where server-side internationalization was failing for namespaces named with kebab-case. The fix involves ensuring that namespaces are always converted to kebab-case before being used to construct file paths for loading translation JSON files. This is achieved by importing and using the kebabCase utility. The change is correct, well-targeted, and effectively resolves the issue by aligning server-side behavior with the file naming convention.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a server-side i18n loading issue where translation files with kebab-case names (e.g., dataset-settings.json) fail to load after namespaces are converted to camelCase internally by i18next.

Key Changes:

  • Added kebabCase import from es-toolkit/compat
  • Updated the resourcesToBackend callback to convert namespaces from camelCase back to kebab-case before building file import paths
  • Updated the namespace parameter type to accept both NamespaceCamelCase and NamespaceKebabCase

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 30, 2025
@hyoban hyoban merged commit 9fbc7fa into main Dec 30, 2025
21 checks passed
@hyoban hyoban deleted the fix/server-i18n-namespace-loader branch December 30, 2025 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

3 participants