Skip to content

Named, list, modifier examples #2186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

mauryapari
Copy link
Contributor

@mauryapari mauryapari commented May 11, 2025

Added documentation and examples for using modifiers with Named, list and literal translations.

Would resolve #1404

Summary by CodeRabbit

  • Documentation

    • Expanded documentation with detailed examples demonstrating the use of string modifiers (.lower, .upper, .capitalize) in linked messages with named, list, and literal interpolations.
  • Tests

    • Added new test cases to verify correct application of string modifiers with various interpolation styles in translations.

Copy link

coderabbitai bot commented May 11, 2025

Walkthrough

The documentation for syntax was expanded to provide detailed examples of using modifiers with named, list, and literal interpolations in linked messages. Additionally, a new test case was added to verify that the translation logic correctly applies these modifiers in various interpolation scenarios.

Changes

Files/Paths Change Summary
docs/guide/essentials/syntax.md Expanded documentation with detailed examples and explanations for using modifiers on named, list, and literal interpolations in linked messages.
packages/vue-i18n-core/test/composer.test.ts Added a new test case to verify correct application of modifiers with named, list, and literal interpolations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Docs
    participant TestSuite
    participant Composer

    User->>Docs: Reads new examples on modifiers with interpolations
    User->>TestSuite: Runs new test case for modifiers
    TestSuite->>Composer: Calls t() with named/list/literal interpolations and modifiers
    Composer-->>TestSuite: Returns transformed strings
    TestSuite-->>User: Displays assertion results
Loading

Assessment against linked issues

Objective Addressed Explanation
Add examples for using modifiers on named, list, or literal values in documentation (#1404)

Suggested labels

Type: Documentation

Suggested reviewers

  • kazupon

Poem

A rabbit hopped through docs so bright,
Adding examples, clear and right.
With tests that check each little case,
Modifiers now fall in place.
Named, list, or literal—no more confusion,
Just translation magic, in perfect profusion!
🐇✨

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 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 bc2ed63 and 42bc36c.

📒 Files selected for processing (2)
  • docs/guide/essentials/syntax.md (1 hunks)
  • packages/vue-i18n-core/test/composer.test.ts (1 hunks)
🔇 Additional comments (6)
docs/guide/essentials/syntax.md (5)

240-241: Clear improvement to the documentation note.

The updated description more explicitly states that all three interpolation types (Named, List, and Literal) can be used with linked messages, improving clarity for developers.


244-263: Well-structured message examples showcasing all modifier use cases.

This code example effectively demonstrates all three pattern types (named, list, and literal) with modifiers in a single, comprehensive example. The message structure is clear and follows established patterns in the rest of the document.


264-279: Clear explanation of named interpolation with modifier.

This section properly explains how the @.lower modifier works with named interpolation, showing both the code usage and the expected output. The explanation of how message.name is linked and transformed is particularly helpful.


281-293: Good explanation of list interpolation with modifiers.

The section effectively explains how list interpolation works with the @.upper and @.capitalize modifiers, including a practical example of passing an array and the resulting transformations.


295-309: Helpful explanation of literal interpolation with modifier.

This section clearly demonstrates how literal interpolation can work with modifiers, showing how to preserve special characters (like @) while still applying transformations to linked content. The example with the email format is particularly relevant.

packages/vue-i18n-core/test/composer.test.ts (1)

362-390: Comprehensive test coverage for modifiers with all interpolation types.

This test case properly validates the functionality described in the documentation, ensuring that:

  1. Named interpolation with the .lower modifier correctly transforms "Alice" to "alice"
  2. List interpolation with the .upper and .capitalize modifiers correctly transforms "bob" to "BOB" and "monday" to "Monday"
  3. Literal interpolation with the .lower modifier correctly transforms "SHOUTING" to "shouting" while preserving the @ character

The test implementation aligns perfectly with the documentation examples, which is excellent for maintaining consistency between code and documentation.

✨ 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 Type: Improvement Includes backwards-compatible fixes 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing labels May 11, 2025
Copy link
Member

@kazupon kazupon left a comment

Choose a reason for hiding this comment

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

Thank you!

Copy link

Size Report

Bundles

File Size Gzip Brotli
core.esm-browser.prod.js 38.05 kB 11.62 kB 10.39 kB
core.global.prod.js 31.11 kB 10.78 kB 9.67 kB
core.runtime.esm-browser.prod.js 23.77 kB 7.71 kB 6.90 kB
core.runtime.global.prod.js 18.08 kB 7.04 kB 6.32 kB
message-compiler.esm-browser.prod.js 19.29 kB 5.76 kB 5.14 kB
message-compiler.global.prod.js 17.32 kB 5.55 kB 4.98 kB
petite-vue-i18n-core.esm-browser.prod.js 20.67 kB 6.96 kB 6.26 kB
petite-vue-i18n-core.global.prod.js 15.63 kB 6.06 kB 5.51 kB
petite-vue-i18n.esm-browser.prod.js 36.98 kB 11.34 kB 10.17 kB
petite-vue-i18n.global.prod.js 29.84 kB 10.19 kB 9.20 kB
petite-vue-i18n.runtime.esm-browser.prod.js 22.55 kB 7.33 kB 6.63 kB
petite-vue-i18n.runtime.global.prod.js 16.83 kB 6.40 kB 5.80 kB
vue-i18n.esm-browser.prod.js 50.68 kB 15.15 kB 13.55 kB
vue-i18n.global.prod.js 40.54 kB 13.61 kB 12.25 kB
vue-i18n.runtime.esm-browser.prod.js 36.25 kB 11.15 kB 10.02 kB
vue-i18n.runtime.global.prod.js 27.53 kB 9.85 kB 8.89 kB

Usages

Name Size Gzip Brotli
packages/size-check-core (@intlify/core) 9.22 kB 3.82 kB 3.46 kB
packages/size-check-petite-vue-i18n (petite-vue-i18n) 77.63 kB 30.24 kB 27.28 kB
packages/size-check-vue-i18n (vue-i18n) 82.85 kB 31.74 kB 28.64 kB

Copy link

pkg-pr-new bot commented May 11, 2025

Open in StackBlitz

@intlify/core

npm i https://pkg.pr.new/@intlify/core@2186

@intlify/core-base

npm i https://pkg.pr.new/@intlify/core-base@2186

@intlify/devtools-types

npm i https://pkg.pr.new/@intlify/devtools-types@2186

@intlify/message-compiler

npm i https://pkg.pr.new/@intlify/message-compiler@2186

petite-vue-i18n

npm i https://pkg.pr.new/petite-vue-i18n@2186

@intlify/shared

npm i https://pkg.pr.new/@intlify/shared@2186

vue-i18n

npm i https://pkg.pr.new/vue-i18n@2186

@intlify/vue-i18n-core

npm i https://pkg.pr.new/@intlify/vue-i18n-core@2186

commit: 42bc36c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing Type: Improvement Includes backwards-compatible fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No examples on using modifiers on the values of named, list, or literals in documentation
2 participants