feat: support useI18n({ messages }) in locale message extraction#695
Draft
jariz wants to merge 1 commit into
Draft
feat: support useI18n({ messages }) in locale message extraction#695jariz wants to merge 1 commit into
jariz wants to merge 1 commit into
Conversation
|
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.
In short, adds supports for
useI18n({ messages }).Read more in the full issue: #694
What's supported
useI18n({ messages: { en: { ... }, ja: { ... } } })const msgs = { ... }; useI18n({ messages: msgs })import messages from './messages.json'; useI18n({ messages })import { messages } from './i18n.js'; useI18n({ messages })import { messages as msgs } from './i18n.js'; useI18n({ messages: msgs })asexpressions:useI18n({ messages: { ... } as const })useI18n()calls in a single file (each produces its own locale message set)<i18n>blocks +useI18n({ messages })+localeDirall merge togethert('form.submit')resolves correctly against nested message objectsWhat's NOT supported (silently skipped)
useI18n({ messages: { ...base, en: { ... } } })— the entire messages object is skipped if any spread is encountered since it's not statically analyzableuseI18n({ messages: { [locale]: { ... } } })— skippeduseI18n({ messages: getMessages() })or any non-identifier, non-object expression — skippedimport * as msgs from '...'— not resolvedconst/let/varin the module scope are collected (sufficient for<script setup>)const a = b; useI18n({ messages: a })wherebis another variable — only one level of indirection is followed`${dynamicLocale}`as values — skipped