Skip to content

fix(cli): improve locale list parsing in init command#2095

Open
Waqasabid99 wants to merge 4 commits into
lingodotdev:mainfrom
Waqasabid99:main
Open

fix(cli): improve locale list parsing in init command#2095
Waqasabid99 wants to merge 4 commits into
lingodotdev:mainfrom
Waqasabid99:main

Conversation

@Waqasabid99
Copy link
Copy Markdown

@Waqasabid99 Waqasabid99 commented May 26, 2026

Summary

Fixes locale list parsing during lingo init by properly handling comma-separated inputs with spaces and quoted locale values.

Changes

  • Added a shared parseListInput utility for parsing comma/space separated CLI inputs
  • Trim whitespace from parsed values before locale validation
  • Added support for quoted locale inputs such as 'es', 'fr'
  • Improved parsing robustness by supporting both commas and whitespace as separators
  • Improved invalid locale error messaging with clearer formatting examples
  • Reused the parsing utility for both --targets and --paths options

Testing

Business logic tests added:

  • Verified comma-separated locale inputs with spaces (es, fr)
  • Verified quoted locale inputs ('es', 'fr' and "es", "fr")
  • Verified space-separated locale inputs (es fr)
  • Verified parsing filters empty values and trims whitespace correctly
  • Verified shared parsing behavior works for --paths
  • All tests and checks pass locally

Commands executed locally:

pnpm turbo build --force
pnpm turbo test --force
pnpm changeset status --since origin/main

Visuals

image image

Checklist

  • Changeset added
  • Tests cover business logic and edge cases
  • No breaking changes

Closes #2069

Summary by CodeRabbit

  • Bug Fixes
    • Fixed parsing of comma-separated locale inputs that include spaces and quotes during initialization.
    • Improved error messages for invalid locale and bucket format values in the CLI.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 90f28f35-bba2-4036-8037-62c2e85a9e66

📥 Commits

Reviewing files that changed from the base of the PR and between 2cba018 and 1bf8914.

📒 Files selected for processing (2)
  • packages/cli/src/cli/cmd/init.ts
  • packages/cli/src/cli/cmd/parseListInput.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/cli/src/cli/cmd/parseListInput.spec.ts

📝 Walkthrough

Walkthrough

This PR introduces a parseListInput utility to standardize CLI list parsing across the init command. The helper normalizes comma- and whitespace-separated input by trimming values and removing surrounding quotes. It replaces inconsistent ad-hoc splitting logic for --targets locales and --paths inputs, along with interactive custom path entry. Error messages for invalid locale formats are enhanced with clearer multi-line guidance. A comprehensive test suite validates the parsing behavior. A changeset documents the fix.

Changes

CLI input parsing fix

Layer / File(s) Summary
Input parsing utility and test coverage
packages/cli/src/cli/cmd/init.ts, packages/cli/src/cli/cmd/parseListInput.spec.ts
parseListInput utility exported to split on commas or whitespace, trim quotes, and filter empty values. Test suite covers comma-separated, space-separated, quoted, empty, and duplicate-separator inputs.
Error messaging and CLI argument refactoring
packages/cli/src/cli/cmd/init.ts
throwHelpError displays multi-line format guidance. The --targets, --paths (non-interactive), and interactive custom path entry all use parseListInput instead of manual splitting.
Release documentation
.changeset/wicked-baboons-bake.md
Changeset documents patch release for lingo.dev, noting the fix for parsing comma-separated locale inputs with spaces and quotes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • moygospadin

Poem

🐰 A list of locales, spaced with care,
Now parsed with quotes and commas fair,
No hidden spaces to make us fret,
The clearest input parser yet!
Init flows smooth, from here to there.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: improving locale list parsing in the init command to handle comma-separated inputs with spaces.
Description check ✅ Passed The PR description follows the template with all major sections complete: summary, changes, testing with checkboxes, visuals with screenshots, and checklist items.
Linked Issues check ✅ Passed The PR addresses all coding requirements from issue #2069: handles comma-separated inputs with spaces, supports quoted locale inputs, improves error messaging, and applies fixes to multiple CLI options.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing locale list parsing in init command. The changeset file and parseListInput utility align with the stated objectives from issue #2069.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

Copy link
Copy Markdown
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: 3

🧹 Nitpick comments (1)
packages/cli/src/cli/cmd/init.ts (1)

84-85: 💤 Low value

Premature type cast before validation.

The as LocaleCode[] cast occurs before the values are validated by resolveLocaleCode. While this is safe because validation happens immediately afterward (and throwHelpError will terminate if invalid), the cast is technically premature.

♻️ Consider deferring the cast until after validation
 .argParser((value: string) => {
-  const values = parseListInput(value) as LocaleCode[];
+  const values = parseListInput(value);
   values.forEach((value) => {
     try {
       resolveLocaleCode(value);
     } catch (e) {
       throwHelpError("locale", value);
     }
   });
-  return values;
+  return values as LocaleCode[];
 })
🤖 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 `@packages/cli/src/cli/cmd/init.ts` around lines 84 - 85, The premature cast to
LocaleCode[] in the argParser should be removed: have parseListInput(value)
produce a string[] (no "as LocaleCode[]") then validate each entry with
resolveLocaleCode inside the same argParser callback and only cast/return
LocaleCode[] after successful validation; if resolveLocaleCode throws,
propagate/throwHelpError as currently done. Update the argParser callback (the
parseListInput + resolveLocaleCode logic) to defer the LocaleCode[] cast until
after validation completes.
🤖 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 `@demo/new-compiler-vite-react-spa/public/translations/de.json`:
- Around line 5-24: The PR contains only nonfunctional reordering of translation
keys (e.g., "02704ec4e52a", "07d84d34dd3a", "0add30e37450", "2d626508fb8f",
etc.) which adds noise; revert the JSON key order to the original ordering (or
regenerate the translations file from the canonical source) so only actual CLI
parsing changes remain in the diff — undo the reordering changes in this
translations file or restore the previous version of the file containing those
keys in their original order.

In `@demo/new-compiler-vite-react-spa/public/translations/es.json`:
- Around line 5-24: Revert the cosmetic reordering of translation keys in the
es.json locale file so the entries (e.g., "02704ec4e52a", "07d84d34dd3a",
"0add30e37450", "2d626508fb8f", etc.) match the original ordering (and match
de.json/other locales), leaving only the actual CLI parsing changes in the PR;
restore the original key sequence for all three locale files to eliminate diff
noise.

In `@demo/new-compiler-vite-react-spa/public/translations/fr.json`:
- Around line 5-24: Translation entries were reordered in multiple locale files
without content changes causing noisy diffs; revert the ordering-only edits in
the three locale files so their keys and values match the base branch exactly
(restore the original ordering for keys such as "02704ec4e52a", "f11fc78c3ac0",
"de6bfb30be49", etc.), leaving only intentional translation or parsing-related
changes; update the commit to remove these generated reorderings (or reset these
files from the base branch) so the PR focuses solely on the CLI parsing fixes.

---

Nitpick comments:
In `@packages/cli/src/cli/cmd/init.ts`:
- Around line 84-85: The premature cast to LocaleCode[] in the argParser should
be removed: have parseListInput(value) produce a string[] (no "as LocaleCode[]")
then validate each entry with resolveLocaleCode inside the same argParser
callback and only cast/return LocaleCode[] after successful validation; if
resolveLocaleCode throws, propagate/throwHelpError as currently done. Update the
argParser callback (the parseListInput + resolveLocaleCode logic) to defer the
LocaleCode[] cast until after validation completes.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4f8ce68b-b386-4fd7-a719-4639cf612956

📥 Commits

Reviewing files that changed from the base of the PR and between 974f651 and 2cba018.

📒 Files selected for processing (6)
  • .changeset/config.json
  • .changeset/wicked-baboons-bake.md
  • demo/new-compiler-vite-react-spa/public/translations/de.json
  • demo/new-compiler-vite-react-spa/public/translations/es.json
  • demo/new-compiler-vite-react-spa/public/translations/fr.json
  • packages/cli/src/cli/cmd/init.ts

Comment on lines +5 to +24
"02704ec4e52a": "Es extrahiert automatisch Text aus Ihrem JSX und übersetzt ihn in andere Sprachen.",
"07d84d34dd3a": "Fügen Sie einfach die Direktive \"use i18n\" am Anfang Ihrer Komponentendateien hinzu, und der Compiler erledigt den Rest!",
"0add30e37450": "Der Compiler analysiert Ihre React-Komponenten zur Build-Zeit und extrahiert automatisch alle übersetzbaren Strings. Anschließend generiert er Übersetzungen mit Ihrem konfigurierten Übersetzungsanbieter.",
"2d626508fb8f": "Hash-basiertes Übersetzungssystem für stabile Kennungen",
"44a3311c3a4a": "Wie es funktioniert",
"52ed9ee761d8": "Hallo Welt",
"556f5956dca7": "Willkommen zur Lingo.dev Compiler Demo",
"5c15bd35e916": "Um es zu übersetzen, müssen Sie es in '<'>{translatableText} '<'/> einschließen",
"8492c53cfbaf": "Über Lingo.dev",
"8aa4fe3f0590": "Dies ist eine Demo-Anwendung, die den Lingo.dev-Compiler für automatische Übersetzungen in React-Anwendungen präsentiert.",
"af76f667703b": "Hauptfunktionen",
"93b50fe805b7": "Text außerhalb der Komponente wird nicht übersetzt: {externalText}",
"999a96fc5866": "Automatische Extraktion übersetzbarer Texte aus JSX",
"b285bf7876d3": "Build-Zeit-Transformation ohne Laufzeit-Overhead",
"ab0450919701": "Unterstützung für mehrere Bundler (Vite, Webpack, Next.js)",
"2d626508fb8f": "Hash-basiertes Übersetzungssystem für stabile Kennungen",
"aca12d550fe2": "Unterstützung für Server- und Client-Komponenten",
"44a3311c3a4a": "Wie es funktioniert",
"0add30e37450": "Der Compiler analysiert Ihre React-Komponenten zur Build-Zeit und extrahiert automatisch alle übersetzbaren Strings. Anschließend generiert er Übersetzungen mit Ihrem konfigurierten Übersetzungsanbieter.",
"07d84d34dd3a": "Fügen Sie einfach die Direktive \"use i18n\" am Anfang Ihrer Komponentendateien hinzu, und der Compiler erledigt den Rest!",
"af76f667703b": "Hauptfunktionen",
"b285bf7876d3": "Build-Zeit-Transformation ohne Laufzeit-Overhead",
"d756b03ffbf5": "Inhalte, die Text und andere Tags enthalten, werden als eine Einheit übersetzt: {translatableMixedContextFragment}",
"daa4d8839395": "{counter} mal geklickt",
"52ed9ee761d8": "Hallo Welt",
"f11fc78c3ac0": "<b0>Gemischter</b0> Inhalt <i0>Fragment</i0>",
"556f5956dca7": "Willkommen zur Lingo.dev Compiler Demo",
"02704ec4e52a": "Es extrahiert automatisch Text aus Ihrem JSX und übersetzt ihn in andere Sprachen.",
"de6bfb30be49": "Text, der als <code0></code0> eingefügt wird, wird nicht übersetzt: {text}",
"5c15bd35e916": "Um es zu übersetzen, müssen Sie es in '<'>{translatableText} '<'/> einschließen",
"93b50fe805b7": "Text außerhalb der Komponente wird nicht übersetzt: {externalText}",
"d756b03ffbf5": "Inhalte, die Text und andere Tags enthalten, werden als eine Einheit übersetzt: {translatableMixedContextFragment}"
"f11fc78c3ac0": "<b0>Gemischter</b0> Inhalt <i0>Fragment</i0>"
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Unnecessary reordering adds diff noise.

The translation entries in this file have been reordered without any content changes. Since JSON object key order is not semantically significant and the PR focuses on CLI parsing improvements, this reordering appears unrelated to the stated objectives and adds unnecessary diff noise.

Consider reverting these changes unless there's a specific reason for the reordering (e.g., alphabetical sorting for maintainability or auto-generation from the updated init command).

🤖 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 `@demo/new-compiler-vite-react-spa/public/translations/de.json` around lines 5
- 24, The PR contains only nonfunctional reordering of translation keys (e.g.,
"02704ec4e52a", "07d84d34dd3a", "0add30e37450", "2d626508fb8f", etc.) which adds
noise; revert the JSON key order to the original ordering (or regenerate the
translations file from the canonical source) so only actual CLI parsing changes
remain in the diff — undo the reordering changes in this translations file or
restore the previous version of the file containing those keys in their original
order.

Comment on lines +5 to +24
"02704ec4e52a": "Extrae automáticamente texto de tu JSX y lo traduce a otros idiomas.",
"07d84d34dd3a": "¡Simplemente agrega la directiva \"use i18n\" en la parte superior de tus archivos de componentes, y el compilador se encarga del resto!",
"0add30e37450": "El compilador analiza tus componentes de React en tiempo de compilación y extrae automáticamente todas las cadenas traducibles. Luego genera traducciones utilizando tu proveedor de traducción configurado.",
"2d626508fb8f": "Sistema de traducción basado en hash para identificadores estables",
"44a3311c3a4a": "Cómo funciona",
"52ed9ee761d8": "Hola Mundo",
"556f5956dca7": "Bienvenido a la demo de Lingo.dev compiler",
"5c15bd35e916": "Para traducirlo tienes que envolverlo en el '<'>{translatableText} '<'/>",
"8492c53cfbaf": "Acerca de Lingo.dev",
"8aa4fe3f0590": "Esta es una aplicación de demostración que muestra el compilador Lingo.dev para traducciones automáticas en aplicaciones React.",
"af76f667703b": "Características principales",
"93b50fe805b7": "El texto externo al componente no se traduce: {externalText}",
"999a96fc5866": "Extracción automática de texto traducible desde JSX",
"b285bf7876d3": "Transformación en tiempo de compilación sin sobrecarga en tiempo de ejecución",
"ab0450919701": "Soporte para múltiples empaquetadores (Vite, Webpack, Next.js)",
"2d626508fb8f": "Sistema de traducción basado en hash para identificadores estables",
"aca12d550fe2": "Soporte para componentes de servidor y cliente",
"44a3311c3a4a": "Cómo funciona",
"0add30e37450": "El compilador analiza tus componentes de React en tiempo de compilación y extrae automáticamente todas las cadenas traducibles. Luego genera traducciones utilizando tu proveedor de traducción configurado.",
"07d84d34dd3a": "¡Simplemente agrega la directiva \"use i18n\" en la parte superior de tus archivos de componentes, y el compilador se encarga del resto!",
"af76f667703b": "Características principales",
"b285bf7876d3": "Transformación en tiempo de compilación sin sobrecarga en tiempo de ejecución",
"d756b03ffbf5": "El contenido que tiene texto y otras etiquetas dentro se traducirá como una sola entidad: {translatableMixedContextFragment}",
"daa4d8839395": "Clicado {counter} veces",
"52ed9ee761d8": "Hola Mundo",
"f11fc78c3ac0": "Contenido <b0>mixto</b0> <i0>fragmento</i0>",
"556f5956dca7": "Bienvenido a la demo de Lingo.dev compiler",
"02704ec4e52a": "Extrae automáticamente texto de tu JSX y lo traduce a otros idiomas.",
"de6bfb30be49": "El texto insertado como <code0></code0> no se traduce: {text}",
"5c15bd35e916": "Para traducirlo tienes que envolverlo en el '<'>{translatableText} '<'/>",
"93b50fe805b7": "El texto externo al componente no se traduce: {externalText}",
"d756b03ffbf5": "El contenido que tiene texto y otras etiquetas dentro se traducirá como una sola entidad: {translatableMixedContextFragment}"
"f11fc78c3ac0": "Contenido <b0>mixto</b0> <i0>fragmento</i0>"
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Unnecessary reordering adds diff noise.

Similar to de.json, the translation entries have been reordered without content changes. This reordering pattern is consistent across all three locale files but doesn't appear to serve the PR objectives related to CLI parsing improvements.

Consider reverting these cosmetic changes to keep the PR focused and reduce diff noise.

🤖 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 `@demo/new-compiler-vite-react-spa/public/translations/es.json` around lines 5
- 24, Revert the cosmetic reordering of translation keys in the es.json locale
file so the entries (e.g., "02704ec4e52a", "07d84d34dd3a", "0add30e37450",
"2d626508fb8f", etc.) match the original ordering (and match de.json/other
locales), leaving only the actual CLI parsing changes in the PR; restore the
original key sequence for all three locale files to eliminate diff noise.

Comment on lines +5 to +24
"02704ec4e52a": "Il extrait automatiquement le texte de votre JSX et le traduit dans d'autres langues.",
"07d84d34dd3a": "Ajoutez simplement la directive \"use i18n\" en haut de vos fichiers de composants, et le compilateur s'occupe du reste !",
"0add30e37450": "Le compilateur analyse vos composants React au moment de la compilation et extrait automatiquement toutes les chaînes traduisibles. Il génère ensuite des traductions en utilisant votre fournisseur de traduction configuré.",
"2d626508fb8f": "Système de traduction basé sur des hachages pour des identifiants stables",
"44a3311c3a4a": "Comment ça fonctionne",
"52ed9ee761d8": "Bonjour le monde",
"556f5956dca7": "Bienvenue dans la démo du compilateur Lingo.dev",
"5c15bd35e916": "Pour le traduire, vous devez l'envelopper dans le '<'>{translatableText} '<'/>",
"8492c53cfbaf": "À propos de Lingo.dev",
"8aa4fe3f0590": "Ceci est une application de démonstration présentant le compilateur Lingo.dev pour les traductions automatiques dans les applications React.",
"af76f667703b": "Fonctionnalités clés",
"93b50fe805b7": "Le texte externe au composant n'est pas traduit : {externalText}",
"999a96fc5866": "Extraction automatique du texte traduisible à partir de JSX",
"b285bf7876d3": "Transformation au moment de la compilation sans surcharge d'exécution",
"ab0450919701": "Prise en charge de plusieurs bundlers (Vite, Webpack, Next.js)",
"2d626508fb8f": "Système de traduction basé sur des hachages pour des identifiants stables",
"aca12d550fe2": "Prise en charge des composants serveur et client",
"44a3311c3a4a": "Comment ça fonctionne",
"0add30e37450": "Le compilateur analyse vos composants React au moment de la compilation et extrait automatiquement toutes les chaînes traduisibles. Il génère ensuite des traductions en utilisant votre fournisseur de traduction configuré.",
"07d84d34dd3a": "Ajoutez simplement la directive \"use i18n\" en haut de vos fichiers de composants, et le compilateur s'occupe du reste !",
"af76f667703b": "Fonctionnalités clés",
"b285bf7876d3": "Transformation au moment de la compilation sans surcharge d'exécution",
"d756b03ffbf5": "Le contenu qui contient du texte et d'autres balises sera traduit comme une seule entité : {translatableMixedContextFragment}",
"daa4d8839395": "Cliqué {counter} fois",
"52ed9ee761d8": "Bonjour le monde",
"f11fc78c3ac0": "<b0>Contenu</b0> mixte <i0>fragment</i0>",
"556f5956dca7": "Bienvenue dans la démo du compilateur Lingo.dev",
"02704ec4e52a": "Il extrait automatiquement le texte de votre JSX et le traduit dans d'autres langues.",
"de6bfb30be49": "Le texte inséré comme un <code0></code0> n'est pas traduit : {text}",
"5c15bd35e916": "Pour le traduire, vous devez l'envelopper dans le '<'>{translatableText} '<'/>",
"93b50fe805b7": "Le texte externe au composant n'est pas traduit : {externalText}",
"d756b03ffbf5": "Le contenu qui contient du texte et d'autres balises sera traduit comme une seule entité : {translatableMixedContextFragment}"
"f11fc78c3ac0": "<b0>Contenu</b0> mixte <i0>fragment</i0>"
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Unnecessary reordering adds diff noise.

This is the third translation file with identical reordering of entries without content changes. The consistent pattern across all locale files suggests this may have been generated by running a tool, but it still adds significant diff noise unrelated to the PR's CLI parsing improvements.

Consider reverting the changes to all three translation files (de.json, es.json, fr.json) to keep this PR focused on the core parsing logic fixes.

🤖 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 `@demo/new-compiler-vite-react-spa/public/translations/fr.json` around lines 5
- 24, Translation entries were reordered in multiple locale files without
content changes causing noisy diffs; revert the ordering-only edits in the three
locale files so their keys and values match the base branch exactly (restore the
original ordering for keys such as "02704ec4e52a", "f11fc78c3ac0",
"de6bfb30be49", etc.), leaving only intentional translation or parsing-related
changes; update the commit to remove these generated reorderings (or reset these
files from the base branch) so the PR focuses solely on the CLI parsing fixes.

@moygospadin
Copy link
Copy Markdown
Contributor

@Waqasabid99 Hello, please fix codderabbitai suggestions

@Waqasabid99
Copy link
Copy Markdown
Author

@Waqasabid99 Hello, please fix codderabbitai suggestions

done.

@moygospadin moygospadin changed the title #2069 fix(cli): improve locale list parsing in init command fix(cli): improve locale list parsing in init command May 28, 2026
@moygospadin
Copy link
Copy Markdown
Contributor

@Waqasabid99
Thanks for the fix! The parsing logic is correct and resolves #2069 — verified locally that --targets "es, fr, de-AT" now produces ["es", "fr", "de-AT"], and parseListInput handles quoted, mixed, and whitespace-padded inputs cleanly. Full test suite (887/887) passes against your branch, and there are no security concerns (regex is bounded, downstream validation via resolveLocaleCode/fs.statSync is unchanged).

A few things to address before merge:

  1. Tests are claimed but not present in the diff.
    The PR description has six checked items under "Business logic tests added" but no *.spec.ts / *.test.ts was added. Could you add packages/cli/src/cli/cmd/init.spec.ts (or parseListInput.spec.ts) covering at least:

es,fr, es, fr, es fr
'es', 'fr' and "es", "fr"
empty / whitespace-only input → []
duplicate separators (es,,fr) → filtered
outer-quoted list ('es,fr')
These would have caught the original bug and will prevent regressions.

  1. Please revert the unrelated reformat of .changeset/config.json.
    The file was reflowed from 2-space to 4-space indentation and the trailing newline was dropped. It's unrelated to the locale-parsing fix and makes the diff noisier than it needs to be — let's keep this PR scoped to the bug.

Nit (optional): in parseListInput, .trim() is redundant after split(/[,\s]+/) since the regex already consumes surrounding whitespace — you can drop it.

const parseListInput = (value: string): string[] =>
value
.split(/[,\s]+/)
.map((v) => v.replace(/^['"]|['"]$/g, ""))
.filter(Boolean);
Once the config.json revert is in, and tests are added, this is good to merge. Nice catch on improving the error message too — the quoted invalid value will save future users from the same invisible-whitespace pain.

@Waqasabid99
Copy link
Copy Markdown
Author

@Waqasabid99 Thanks for the fix! The parsing logic is correct and resolves

Thanks for the detailed review and verification!

I’ve now:

  • Added tests
  • Reverted the unrelated .changeset/config.json formatting changes
  • Removed the redundant .trim() call as suggested

Appreciate the thorough feedback and validation.

Copy link
Copy Markdown

@SreedharThappeta SreedharThappeta left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lingo init: entering target locales with spaces after commas causes "Invalid locale" error

3 participants