Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
"changelog": ["@changesets/changelog-github", { "repo": "lingodotdev/lingo.dev" }],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch"
}
"$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json",
"changelog": [
"@changesets/changelog-github",
{
"repo": "lingodotdev/lingo.dev"
}
],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch"
}
5 changes: 5 additions & 0 deletions .changeset/wicked-baboons-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"lingo.dev": patch
---

Fix parsing of comma-separated locale inputs with spaces and quotes during init
26 changes: 13 additions & 13 deletions demo/new-compiler-vite-react-spa/public/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
"version": 0.1,
"locale": "de",
"entries": {
"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.

}
}
26 changes: 13 additions & 13 deletions demo/new-compiler-vite-react-spa/public/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
"version": 0.1,
"locale": "es",
"entries": {
"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.

}
}
26 changes: 13 additions & 13 deletions demo/new-compiler-vite-react-spa/public/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
"version": 0.1,
"locale": "fr",
"entries": {
"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.

}
}
31 changes: 19 additions & 12 deletions packages/cli/src/cli/cmd/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,25 @@ const throwHelpError = (option: string, value: string) => {
if (value === "help") {
openUrl("/go/call");
}

// Better error message for invalid locale or bucket format inputs, with instructions to get help for supported formats
throw new Error(
`Invalid ${option}: ${value}\n\nDo you need support for ${value} ${option}? Type "help" and we will.`,
`Invalid ${option}: "${value}".\n\n` +
`Accepted formats:\n` +
` es,fr\n` +
` es fr\n` +
` 'es', 'fr'\n\n` +
`If you need support for "${value}" ${option}, type "help" and we will.`,
);
};

// Parses comma or space separated list of values, removing extra whitespace and quotes
const parseListInput = (value: string): string[] =>
value
.split(/[,\s]+/)
.map((v) => v.trim().replace(/^['"]|['"]$/g, ""))
.filter(Boolean);

export default new InteractiveCommand()
.command("init")
.description("Create i18n.json configuration file for a new project")
Expand Down Expand Up @@ -67,10 +81,8 @@ export default new InteractiveCommand()
"-t --targets <locale...>",
"Target languages to translate to. Accepts locale codes like 'es', 'fr', 'de-AT' separated by commas or spaces. Defaults to 'es'",
)
.argParser((value) => {
const values = (
value.includes(",") ? value.split(",") : value.split(" ")
) as LocaleCode[];
.argParser((value: string) => {
const values = parseListInput(value) as LocaleCode[];
values.forEach((value) => {
try {
resolveLocaleCode(value);
Expand Down Expand Up @@ -102,9 +114,7 @@ export default new InteractiveCommand()
)
.argParser((value) => {
if (!value || value.length === 0) return [];
const values = value.includes(",")
? value.split(",")
: value.split(" ");
const values = parseListInput(value);

for (const p of values) {
try {
Expand All @@ -118,7 +128,6 @@ export default new InteractiveCommand()
}
}
return values;

})
.prompt(undefined) // make non-interactive
.default([]),
Expand Down Expand Up @@ -191,9 +200,7 @@ export default new InteractiveCommand()
const customPaths = await input({
message: "Enter paths to use",
});
selectedPatterns = customPaths.includes(",")
? customPaths.split(",")
: customPaths.split(" ");
selectedPatterns = parseListInput(customPaths);
}

newConfig.buckets = {
Expand Down
Loading