feat: native i18n support for collections#3753
Open
JonathanXDR wants to merge 69 commits into
Open
Conversation
…ollectionLocales pages
edimitchel
reviewed
Mar 31, 2026
edimitchel
approved these changes
Apr 3, 2026
|
This feature is really great and well needed for nuxt content! Thanks @JonathanXDR for the work. |
Author
Author
@narr07 Yes sure! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Linked issue
❓ Type of change
📚 Description
Adds native i18n support to
@nuxt/content, so collections are defined once withi18n: trueand content files use an inlinei18nsection for translations. Only translated strings are specified, everything else is preserved from the default locale.queryCollectionautomatically detects the current locale from@nuxtjs/i18nand returns locale-resolved content with zero configuration.Features
i18n: trueauto-detects locales from@nuxtjs/i18n, or pass{ locales, defaultLocale }explicitlyi18nsection with per-locale overrides; arrays merged by index viadefuByIndex(preserves untranslated fields at every nesting level)queryCollectionreads the current locale from@nuxtjs/i18ntransparently (client:$i18n.locale, server:event.context.nuxtI18n); default locale uses single query, non-default uses two-query fallback mergeuseQueryCollectioncomposable: wrapsqueryCollection+useAsyncDatawith auto cache keys, locale-reactive re-fetching, and generic type overridequeryCollectionLocales: returns all locale variants for a content item (for language switchers and hreflang SEO).stem()convenience method: query data collections by filename without knowing the source directory prefix.locale()explicit override: manual locale control with optional fallback_i18nSourceHashfor detecting outdated translationsSecurity
assertSafeQueryrejects newlines (prevents multi-statement injection)COUNT()field names are quoted (prevents field injection)cleanupQuerystring parser rewritten with proper state machine (fixes triple-quote bypass)Known Limitations
en/products.mdvsde/produkte.md),queryCollectionLocalescannot link them because the stems differ. Same-filename content across locale directories works. This requires coordination with@nuxtjs/i18n(see nuxt-modules/i18n#3028).i18nsection, but there is no mechanism to hide a default-locale field for a specific locale.📝 Checklist
Tests
Documentation
useQueryCollectionandqueryCollectionLocalesutility docs.locale()and.stem()to query-collection API reference