Add 'add' command for programmatically adding ARB entries#38
Conversation
- Implemented `add` command in `lib/src/commands/add.dart`. - Added recursive auto-discovery of `.arb` files. - Updated `mergeARBs` primitive to support pretty-printing with 2-space indentation and trailing newline. - Added `AGENTS.md` with instructions for AI agents. - Updated `README.md` and `CHANGELOG.md`. - Bumped version to 0.11.0 in `pubspec.yaml`. - Added comprehensive tests in `test/cli_test.dart`. Co-authored-by: Rodsevich <1907844+Rodsevich@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
…ntax - Reimplemented 'add' command to support `key [locale:value...]` and `--json '<template>' [locale:value...]`. - Added support for `$VAL$` placeholder in JSON templates. - Implemented tail addition by default, with optional `--sort` flag. - Added recursive auto-discovery of `.arb` files and strict locale validation. - Updated `mergeARBs` to support pretty-printing and trailing newline. - Added `AGENTS.md` for AI agents. - Updated `README.md` and `CHANGELOG.md`. - Bumped version to 0.11.0 in `pubspec.yaml`. - Added tests for new functionality and improved existing tests. - Fixed locale detection by adding `@@locale` to `test/samples/unsorted.arb`. Co-authored-by: Rodsevich <1907844+Rodsevich@users.noreply.github.com>
- Reimplemented 'add' command to support `key [locale:value...]` and `--json '<template>' [locale:value...]`. - Added support for `$VAL$` placeholder in JSON templates. - Implemented tail addition by default, with optional `--sort` flag. - Added recursive auto-discovery of `.arb` files and strict locale validation. - Added 'keys' command to list and search keys using regex. - Updated `mergeARBs` and `add` to support pretty-printing and trailing newline. - Created `AGENTS.md` with instructions, complex examples (plurals, select), and agent skills. - Reorganized `README.md` to fix sort command explanation and document new commands. - Bumped version to 0.11.0 in `pubspec.yaml`. - Added comprehensive tests for new functionality in `test/cli_test.dart`. - Fixed locale detection by adding `@@locale` to `test/samples/unsorted.arb`. Co-authored-by: Rodsevich <1907844+Rodsevich@users.noreply.github.com>
| #### Complex syntax (Plurals, Select, etc.) | ||
| For complex ARB values, use the `--json` flag with the `$VAL$` placeholder. | ||
| ```sh | ||
| arb_utils add --json '{"messageCount": "{count, plural, =0{No messages} one{1 message} other{{count} messages}}", "@messageCount": {"description": "Plural message example", "placeholders": {"count": {"type": "int"}}}}' en:'{count, plural, =0{No messages} one{1 message} other{{count} messages}}' es:'{count, plural, =0{No hay mensajes} one{1 mensaje} other{{count} mensajes}}' |
There was a problem hiding this comment.
the proper syntax should be
arb_utils add --json '{"messageCount": "$VAL$", "@messageCount": {"description": "Plural message example", "placeholders": {"count": {"type": "int","example":42}}}}' en:'{count, plural, =0{No messages} one{1 message} other{{count} messages}}' es:'{count, plural, =0{No hay mensajes} one{1 mensaje} other{{count} mensajes}}'
There was a problem hiding this comment.
ensure the command works like this
There was a problem hiding this comment.
Updated the example to use the correct syntax with the
There was a problem hiding this comment.
Acknowleged. The command has been tested to work with this syntax.
|
|
||
| Another example with `select`: | ||
| ```sh | ||
| arb_utils add --json '{"genderSelect": "{gender, select, male{He} female{She} other{They}}", "@genderSelect": {"description": "Select example", "placeholders": {"gender": {"type": "String"}}}}' en:'{gender, select, male{He} female{She} other{They}}' es:'{gender, select, male{Él} female{Ella} other{Ellos}}' |
There was a problem hiding this comment.
should be:
arb_utils add --json '{"genderSelect": "$VAL$", "@genderSelect": {"description": "Select example", "placeholders": {"gender": {"type": "String"}}}}' en:'{gender, select, male{He} female{She} other{They}}' es:'{gender, select, male{Él} female{Ella} other{Ellos}}'
There was a problem hiding this comment.
Updated the select example to use the
- Reimplemented 'add' command with support for human-friendly and JSON template syntax. - Added support for `$VAL$` placeholder in JSON templates with a robust recursive replacement strategy. - Implemented tail addition by default, with optional `--sort` flag. - Added recursive auto-discovery of `.arb` files and strict locale validation. - Added 'keys' command to list and search keys using regex. - Updated `mergeARBs` and `add` to support pretty-printing and trailing newline. - Created `AGENTS.md` with instructions, complex examples (plurals, select), and agent skills. - Reorganized and improved `README.md` to fix sort command explanation and document new commands. - Bumped version to 0.11.0 in `pubspec.yaml`. - Added comprehensive tests for new functionality in `test/cli_test.dart`. - Fixed locale detection by adding `@@locale` to `test/samples/unsorted.arb`. - Optimized `add` command by reducing file I/O operations. Co-authored-by: Rodsevich <1907844+Rodsevich@users.noreply.github.com>
- Updated complex add examples in AGENTS.md to correctly use the $VAL$ placeholder in the JSON template. - Added 'example' field to the count placeholder in the plural example. Co-authored-by: Rodsevich <1907844+Rodsevich@users.noreply.github.com>
- Reimplemented 'add' command with support for human-friendly and JSON template syntax. - Added support for `$VAL$` placeholder in JSON templates with a robust recursive replacement strategy. - Implemented tail addition by default, with optional `--sort` flag. - Added recursive auto-discovery of `.arb` files and strict locale validation. - Added 'keys' command to list and search keys using regex. - Updated `mergeARBs` and `add` to support pretty-printing and trailing newline. - Created `AGENTS.md` with instructions, complex examples (plurals, select), and agent skills. - Reorganized and improved `README.md` to fix sort command explanation and document new commands. - Bumped version to 0.11.0 in `pubspec.yaml`. - Added comprehensive tests for new functionality in `test/cli_test.dart`. - Fixed locale detection by adding `@@locale` to `test/samples/unsorted.arb`. - Optimized `add` command by reducing file I/O operations. - Fixed analyzer warnings and updated tests to include `sort` and `merge` CLI verification. Co-authored-by: Rodsevich <1907844+Rodsevich@users.noreply.github.com>
This PR introduces a new
addcommand to thearb_utilsCLI, designed to simplify the process of adding new translation entries to one or more.arbfiles. This is particularly useful for automation and for AI agents.Key changes:
addcommand: Accepts a JSON string of entries and optional file paths. If no paths are provided, it recursively finds all.arbfiles in the current directory.addandmergecommands now output pretty-printed JSON with 2-space indentation and a trailing newline, ensuring consistency and readability.AGENTS.mdto provide clear instructions for AI agents on how to leverage the tool effectively.README.mdandCHANGELOG.mdto reflect the new feature.addcommand and its auto-discovery feature.PR created automatically by Jules for task 9243076061368503854 started by @Rodsevich