Skip to content

Add 'add' command for programmatically adding ARB entries#38

Merged
Rodsevich merged 6 commits into
masterfrom
add-command-feature-9243076061368503854
Apr 8, 2026
Merged

Add 'add' command for programmatically adding ARB entries#38
Rodsevich merged 6 commits into
masterfrom
add-command-feature-9243076061368503854

Conversation

@Rodsevich

Copy link
Copy Markdown
Owner

This PR introduces a new add command to the arb_utils CLI, designed to simplify the process of adding new translation entries to one or more .arb files. This is particularly useful for automation and for AI agents.

Key changes:

  • New add command: Accepts a JSON string of entries and optional file paths. If no paths are provided, it recursively finds all .arb files in the current directory.
  • Pretty-printing: Both add and merge commands now output pretty-printed JSON with 2-space indentation and a trailing newline, ensuring consistency and readability.
  • AI Agent Support: Added AGENTS.md to provide clear instructions for AI agents on how to leverage the tool effectively.
  • Documentation: Updated README.md and CHANGELOG.md to reflect the new feature.
  • Testing: Added unit/integration tests for the new add command and its auto-discovery feature.
  • Versioning: Bumped the project version to 0.11.0.

PR created automatically by Jules for task 9243076061368503854 started by @Rodsevich

- 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>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

google-labs-jules Bot and others added 2 commits April 6, 2026 10:11
…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>
Comment thread AGENTS.md Outdated
#### 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}}'

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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}}'

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

ensure the command works like this

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.

Updated the example to use the correct syntax with the $VAL$ placeholder and included the example for the count placeholder.

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.

Acknowleged. The command has been tested to work with this syntax.

Comment thread AGENTS.md Outdated

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}}'

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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}}'

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.

Updated the select example to use the $VAL$ placeholder in the JSON template.

google-labs-jules Bot and others added 3 commits April 8, 2026 01:00
- 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>
@Rodsevich Rodsevich merged commit 406768c into master Apr 8, 2026
1 check passed
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.

1 participant