Skip to content

breaking: change translation reserving keys for arguments - #110

Merged
kazupon merged 3 commits into
mainfrom
breaking/translation-reserved-key
May 5, 2025
Merged

breaking: change translation reserving keys for arguments#110
kazupon merged 3 commits into
mainfrom
breaking/translation-reserved-key

Conversation

@kazupon

@kazupon kazupon commented May 5, 2025

Copy link
Copy Markdown
Owner

Description

Linked Issues

Additional context

Summary by CodeRabbit

  • Documentation

    • Updated documentation to use the new "arg:" prefix for command argument translation keys, replacing the previous "Option:" prefix in all relevant guides and examples.
  • Style

    • Standardized localization key naming conventions across all locale files by switching from "Option:" to "arg:" for command argument descriptions.
    • Minor improvements to Japanese localization phrasing for clarity.
    • Adjusted console output labels to lowercase and refined wording for translation information display.
  • Tests

    • Updated test cases to reflect the new "arg:" prefix in translation keys, ensuring consistency with the revised naming convention.

@coderabbitai

coderabbitai Bot commented May 5, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This change updates the naming convention for localization keys related to command-line argument descriptions throughout the documentation, localization resource files, and codebase. The prefix for these keys is changed from "Option:" to "arg:". All relevant documentation, example JSON files, and test cases are updated to reflect this new convention. The constant defining the prefix is also updated in the source code. No changes are made to the logic, structure, or exported entities of the codebase, except for the constant value.

Changes

Files/Paths Change Summary
docs/guide/essentials/declarative-configuration.md,
docs/guide/essentials/internationalization.md
Updated documentation to use arg: instead of Option: for translation keys; revised examples and text accordingly.
playground/deno/locales/en-US.json,
playground/deno/locales/ja-JP.json,
playground/i18n/locales/en-US.json,
playground/i18n/locales/ja-JP.json
Renamed localization keys from Option:name/Option:type/Option:formal to arg:name/arg:type/arg:formal; minor text edits in Japanese files.
src/constants.ts Changed the value of OPTION_PREFIX from 'Option' to 'arg'.
src/context.test.ts Updated test cases to use the new arg: prefix for translation keys and expected values.
playground/i18n/index.js Modified console output labels from title case with Option: keys to lowercase with arg: keys.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Localization
    User->>CLI: Run command with arguments
    CLI->>Localization: Request description for argument (uses "arg:" prefix)
    Localization-->>CLI: Return localized description
    CLI-->>User: Display argument description/help
Loading

Poem

A prefix once called "Option:" is gone,
Now "arg:" leads the way, marching on!
From docs to tests, the change is clear,
Localization bunnies give a cheer.
With tidy keys and names anew,
The codebase hops—fresh, precise, and true!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ade4ca7 and fa46ecb.

📒 Files selected for processing (1)
  • playground/i18n/index.js (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • playground/i18n/index.js
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@kazupon kazupon added the breaking Includes backwards-incompatible fixes label May 5, 2025
@pkg-pr-new

pkg-pr-new Bot commented May 5, 2025

Copy link
Copy Markdown

Open in StackBlitz

@gunshi/bone

npm i https://pkg.pr.new/@gunshi/bone@110

@gunshi/definition

npm i https://pkg.pr.new/@gunshi/definition@110

gunshi

npm i https://pkg.pr.new/gunshi@110

@gunshi/plugin

npm i https://pkg.pr.new/@gunshi/plugin@110

@gunshi/plugin-completion

npm i https://pkg.pr.new/@gunshi/plugin-completion@110

@gunshi/plugin-dryrun

npm i https://pkg.pr.new/@gunshi/plugin-dryrun@110

@gunshi/plugin-global

npm i https://pkg.pr.new/@gunshi/plugin-global@110

@gunshi/plugin-i18n

npm i https://pkg.pr.new/@gunshi/plugin-i18n@110

@gunshi/plugin-renderer

npm i https://pkg.pr.new/@gunshi/plugin-renderer@110

@gunshi/resources

npm i https://pkg.pr.new/@gunshi/resources@110

@gunshi/shared

npm i https://pkg.pr.new/@gunshi/shared@110

commit: 8b0d0f1

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 5, 2025

Copy link
Copy Markdown

Deploying gunshi with  Cloudflare Pages  Cloudflare Pages

Latest commit: fa46ecb
Status: ✅  Deploy successful!
Preview URL: https://df29fc57.gunshi.pages.dev
Branch Preview URL: https://breaking-translation-reserve.gunshi.pages.dev

View logs

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 872666f and ade4ca7.

📒 Files selected for processing (8)
  • docs/guide/essentials/declarative-configuration.md (1 hunks)
  • docs/guide/essentials/internationalization.md (9 hunks)
  • playground/deno/locales/en-US.json (1 hunks)
  • playground/deno/locales/ja-JP.json (1 hunks)
  • playground/i18n/locales/en-US.json (1 hunks)
  • playground/i18n/locales/ja-JP.json (1 hunks)
  • src/constants.ts (1 hunks)
  • src/context.test.ts (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (20)
playground/deno/locales/en-US.json (1)

4-5: Rename localization keys to use new prefix

The keys "arg:name" and "arg:type" correctly replace the old "Option:" prefixed keys, and the associated values remain unchanged. This aligns with the updated OPTION_PREFIX.

docs/guide/essentials/declarative-configuration.md (1)

165-165: Update negatable option description reference

The documentation now correctly references arg:no-<optionName> instead of Option:no-<optionName> for customizing negatable boolean option messages. This matches the new prefix convention.

playground/i18n/locales/en-US.json (1)

4-5: Apply new prefix to internationalization keys

The JSON keys "arg:name" and "arg:formal" properly adopt the arg: prefix, ensuring consistency across locale files. No changes needed for the values.

playground/deno/locales/ja-JP.json (1)

2-5: Refine Japanese locale keys and descriptions

The "description" string has been improved for clarity, and the keys "arg:name" and "arg:type" correctly replace the old Option: prefix. These updates maintain alignment with the overall prefix change.

playground/i18n/locales/ja-JP.json (2)

2-2: Slight improvement in Japanese wording.

The description has been slightly reworded from "国際化対応の挨拶アプリケーション" to "国際化対応した挨拶アプリケーション," which reads more naturally in Japanese.


4-5: Prefix change from "Option:" to "arg:" for command arguments.

The localization keys for command arguments have been updated from the "Option:" prefix to "arg:" prefix, which aligns with the breaking change mentioned in the PR title. This is consistent with similar changes in other files.

docs/guide/essentials/internationalization.md (8)

40-42: Updated prefix from "Option:" to "arg:" in i18n examples.

Command argument keys in the resource definitions are properly updated to use the new "arg:" prefix.


156-158: Updated prefix in locale file examples.

The JSON sample for English locale files correctly reflects the new "arg:" prefix convention for command arguments.


168-170: Updated prefix in Japanese locale file examples.

The JSON sample for Japanese locale files correctly uses the new "arg:" prefix convention.


250-251: Updated documentation for resource key naming conventions.

The resource key naming conventions section has been appropriately updated to reflect the change from "Option Descriptions" to "Argument Descriptions" with guidance on using the new "arg:" prefix. The example for negatable arguments has also been adjusted accordingly.


271-274: Updated example pattern for resource key naming.

The code example showing key naming conventions correctly uses the "arg:" prefix for target and verbose options, along with the negatable version.


428-430: Updated log statements in comprehensive example.

The log statements in the complete example have been updated to use the new "arg:" prefix when accessing translations.


450-452: Updated example locale files in comprehensive example.

The English locale file example at the end of the documentation is correctly updated to use the "arg:" prefix.


462-464: Updated Japanese locale file in comprehensive example.

The Japanese locale file example at the end of the documentation is correctly updated to use the "arg:" prefix.

src/context.test.ts (6)

299-303: Updated test resource keys to use "arg:" prefix.

The test resource object for Japanese locale now uses the "arg:" prefix for command argument keys, which is consistent with the breaking change introduced in this PR.


350-356: Updated test assertions to use new key format.

The test assertions have been correctly updated to verify translations using the new "arg:" prefixed keys.


376-376: Updated MessageFormat2 adapter test to use "arg:" prefix.

The resource object for MessageFormat2 translation adapter test has been correctly updated to use the "arg:" prefix.


415-416: Updated MessageFormat test to use the new key format.

The MessageFormat test now correctly uses the "arg:foo" key both when creating the MessageFormat instance and when calling ctx.translate.


432-432: Updated Intlify MessageFormat test to use "arg:" prefix.

The resource object for Intlify MessageFormat translation adapter test has been correctly updated to use the "arg:" prefix.


471-471: Updated Intlify MessageFormat assertion to use "arg:" prefix.

The test assertion for Intlify MessageFormat translation now correctly uses the "arg:foo" key.

Comment thread src/constants.ts
export const BUILT_IN_PREFIX = '_'

export const OPTION_PREFIX = 'Option'
export const OPTION_PREFIX = 'arg'

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.

💡 Verification agent

🧩 Analysis chain

Update constant value for translation key prefix

The OPTION_PREFIX constant was correctly updated from 'Option' to 'arg' to reflect the new naming convention for argument keys. Please ensure there are no remaining occurrences of the old Option: prefix across the codebase.


🏁 Script executed:

#!/bin/bash
# Verify no stale "Option:" keys remain
rg -nF '"Option:' .

Length of output: 21


🏁 Script executed:

#!/bin/bash
# Verify no stale "Option:" keys remain anywhere in the codebase
rg -nF "Option:" .

Length of output: 196


Stale Option: occurrences found in playground/i18n/index.js

Please update these to use the new OPTION_PREFIX constant ('arg') or replace "Option:" with "arg:".

• playground/i18n/index.js:56
• playground/i18n/index.js:57

Suggested diff:

- console.log(`Name Option: ${ctx.translate('name')}`)
+ console.log(`Name ${OPTION_PREFIX}: ${ctx.translate('name')}`)

- console.log(`Formal Option: ${ctx.translate('formal')}`)
+ console.log(`Formal ${OPTION_PREFIX}: ${ctx.translate('formal')}`)

Committable suggestion skipped: line range outside the PR's diff.

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

Labels

breaking Includes backwards-incompatible fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant