Solution (#50): Help translate the explorer — add a locale#56
Conversation
📝 WalkthroughWalkthroughThis PR adds a new Spanish localization file, Estimated code review effort: 1 (Trivial) | ~2 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Biome (2.5.1)locales/es.jsonFile contains syntax errors that prevent linting: Line 1: unexpected character 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@locales/es.json`:
- Around line 2-31: The Spanish locale file is currently unreachable because the
locale registry only exposes the existing languages through Lang::ALL and raw()
in src/i18n/mod.rs. Update the Lang enum/switching logic there to add Spanish as
a supported locale, and make sure the new es entry is returned by the raw()
mapping so this file can actually be selected and loaded.
- Around line 2-31: The Spanish locale is nested under header/sidebar/footer,
but the i18n loader in src/i18n/mod.rs only keeps top-level string entries and
Navbar reads flat keys like nav.dashboard and nav.assets. Flatten
locales/es.json into the same top-level key structure used by the loader and UI,
replacing the nested sections with direct string keys so the translated values
are actually available at runtime.
- Line 1: The Spanish locale file currently starts with a comment marker, which
makes it invalid JSON and prevents it from loading. Remove the leading # and
keep the file as a valid JSON object matching the structure used by the English
locale so the locale parser can read it successfully.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 8db65bb0-7310-4f29-a93f-0a6087d54e43
📒 Files selected for processing (2)
hlocales/es.json
| @@ -0,0 +1,31 @@ | |||
| # Copy the English locale to Spanish | |||
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Remove the leading # — this file is not valid JSON.
The parser will fail on line 1, so the locale cannot be loaded at all.
Fix
-# Copy the English locale to Spanish
{🧰 Tools
🪛 Biome (2.5.1)
[error] 1-1: unexpected character #
(parse)
[error] 1-1: String values must be double quoted.
(parse)
[error] 1-1: String values must be double quoted.
(parse)
[error] 1-1: String values must be double quoted.
(parse)
[error] 1-1: String values must be double quoted.
(parse)
[error] 1-1: String values must be double quoted.
(parse)
[error] 1-1: String values must be double quoted.
(parse)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@locales/es.json` at line 1, The Spanish locale file currently starts with a
comment marker, which makes it invalid JSON and prevents it from loading. Remove
the leading # and keep the file as a valid JSON object matching the structure
used by the English locale so the locale parser can read it successfully.
Source: Linters/SAST tools
| { | ||
| "title": "Explorador", | ||
| "header": { | ||
| "title": "Explorador", | ||
| "description": "Explorador de datos" | ||
| }, | ||
| "sidebar": { | ||
| "title": "Menú", | ||
| "items": [ | ||
| { | ||
| "title": "Inicio", | ||
| "icon": "home", | ||
| "url": "/" | ||
| }, | ||
| { | ||
| "title": "Datos", | ||
| "icon": "database", | ||
| "url": "/data" | ||
| }, | ||
| { | ||
| "title": "Configuración", | ||
| "icon": "cog", | ||
| "url": "/settings" | ||
| } | ||
| ] | ||
| }, | ||
| "footer": { | ||
| "text": "Copyright 2023" | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Register Spanish in the locale registry, or this file stays unreachable.
src/i18n/mod.rs currently hardcodes only en, id, and zh in Lang::ALL / raw(), so es.json is never selected or loaded. The new locale needs to be wired into that enum + switcher path as part of this PR.
🧰 Tools
🪛 Biome (2.5.1)
[error] 2-31: End of file expected
(parse)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@locales/es.json` around lines 2 - 31, The Spanish locale file is currently
unreachable because the locale registry only exposes the existing languages
through Lang::ALL and raw() in src/i18n/mod.rs. Update the Lang enum/switching
logic there to add Spanish as a supported locale, and make sure the new es entry
is returned by the raw() mapping so this file can actually be selected and
loaded.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Flatten the locale to the keys the i18n loader actually reads.
src/i18n/mod.rs only retains top-level string values, and Navbar looks up flat keys like nav.dashboard / nav.assets. This nested header/sidebar/footer structure will be discarded, so most of the UI will fall back to raw keys.
Example
- "header": {
- "title": "Explorador",
- "description": "Explorador de datos"
- },
- "sidebar": {
- "title": "Menú",
- "items": [
- ...
- ]
- }
+ "header.title": "Explorador",
+ "header.description": "Explorador de datos",
+ "nav.dashboard": "Inicio",
+ "nav.assets": "Datos",
+ "nav.lab": "Laboratorio"🧰 Tools
🪛 Biome (2.5.1)
[error] 2-31: End of file expected
(parse)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@locales/es.json` around lines 2 - 31, The Spanish locale is nested under
header/sidebar/footer, but the i18n loader in src/i18n/mod.rs only keeps
top-level string entries and Navbar reads flat keys like nav.dashboard and
nav.assets. Flatten locales/es.json into the same top-level key structure used
by the loader and UI, replacing the nested sections with direct string keys so
the translated values are actually available at runtime.
This PR adds a Spanish locale to the Sentrix Explorer, enabling users to switch to Spanish and have a more localized experience. Changes include:
locales/es.jsonfile with Spanish translationsTo test this PR, please follow these steps:
npm installnpm run startto start the explorerPlease review and test this PR before merging.
Summary by CodeRabbit