-
Notifications
You must be signed in to change notification settings - Fork 1k
docs: Contribution section - add component localization guide #5915
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
base: v4
Are you sure you want to change the base?
Conversation
commit: |
π WalkthroughWalkthroughThis change adds a new "Add localization support for your component" section to the contribution documentation. The addition includes guidance on implementing localization for components, covering Message typing, locale file locations, a MyButton.vue example, steps for defining messages, optional constraints, translation file structure with sample translations, component usage patterns, and locale creation instructions. The content totals 84 lines and appears in two locations within the document. Estimated code review effortπ― 2 (Simple) | β±οΈ ~10 minutes π₯ Pre-merge checks | β 3β Passed checks (3 passed)
βοΈ Tip: You can configure your own custom pre-merge checks in the settings. β¨ Finishing touchesπ§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
π€ Fix all issues with AI agents
In `@docs/content/docs/1.getting-started/4.contribution.md`:
- Around line 138-147: Tighten the copy in the locale guidance by fixing small
grammar and punctuation issues: change "For Example" to "For example," ensure
"i.e:" becomes "i.e.,", normalize "Translations files" to "translation files",
and standardize spacing around colons and inline code examples (e.g., keep
`MyButton.vue` -> `myButton:` and `myButton?: {`, `buttonText?: string`,
`ariaLabel?: string`). Apply these edits in the component key explanation block
(the sentence starting with "The component key in `locale.ts`") and repeat the
same fixes for the corresponding text referenced on lines 149-151.
| The component key in `locale.ts` must match your component name in camelCase. For Example, `MyButton.vue` -> `myButton:` | ||
| :: | ||
|
|
||
| ::warning | ||
| All entries must be optional by using the `?` TypeScript annotation - i.e: `myButton?: {`, `buttonText?: string`, `ariaLabel?: string` Otherwise, you'll be required to provide translations for every supported locale. | ||
| :: | ||
|
|
||
| ::tip | ||
| You can pick any name you like for your messages. For example: `buttonText` can be `mainText` and `ariaLabel` can be `ariaText` or anything that makes sense for your component | ||
| :: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tighten grammar and punctuation in the new guidance.
These lines have small grammar/punctuation nits (βFor Exampleβ, βi.e:β, βTranslations filesβ). Consider the edits below for clarity.
βοΈ Proposed copy edits
-For Example, `MyButton.vue` -> `myButton:`
+For example, `MyButton.vue` β `myButton:`
-All entries must be optional by using the `?` TypeScript annotation - i.e: `myButton?: {`, `buttonText?: string`, `ariaLabel?: string` Otherwise, you'll be required to provide translations for every supported locale.
+All entries must be optional by using the `?` TypeScript annotation β i.e., `myButton?: {`, `buttonText?: string`, `ariaLabel?: string`. Otherwise, you'll be required to provide translations for every supported locale.
-Translations files are located in `runtime/locale` - Add the locales you want to support for your component:
+Translation files are located in `runtime/locale` β add the locales you want to support for your component:Also applies to: 149-151
π€ Prompt for AI Agents
In `@docs/content/docs/1.getting-started/4.contribution.md` around lines 138 -
147, Tighten the copy in the locale guidance by fixing small grammar and
punctuation issues: change "For Example" to "For example," ensure "i.e:" becomes
"i.e.,", normalize "Translations files" to "translation files", and standardize
spacing around colons and inline code examples (e.g., keep `MyButton.vue` ->
`myButton:` and `myButton?: {`, `buttonText?: string`, `ariaLabel?: string`).
Apply these edits in the component key explanation block (the sentence starting
with "The component key in `locale.ts`") and repeat the same fixes for the
corresponding text referenced on lines 149-151.
π Linked issue
N/A (documentation improvement)
β Type of change
π Description
This PR adds documentation explaining how to add localization support to a custom Nuxt UI component using the built-in locale infrastructure.
The guide covers:
Messagestype inruntime/types/locale.tsto define typed, optional message keys for the componentruntime/locale/*(including the required English entries)useLocale()andt()in the component to render localized stringsNo code changes.
Nuxt UI documents how to create new components, but currently lacks guidance for wiring those components into the locale infrastructure. As a result, contributors typically have to reverse-engineer the existing implementation in the codebase to add translations correctly.
This documentation reduces contributor friction, prevents inconsistent patterns, and makes localization support discoverable.
This added section to the docs allow people to quickly understand and implement a localization support for their component instead of spending time to figure it out themselves, they can use their time to: develop new features, going to the beach ποΈ, dancing in the sunππΊβοΈ, making loveβ₯οΈ etc... more productive activities
π Checklist