Skip to content
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

fix(petite-vue-i18n): cannot register correctly message resolver and locale fallbacker #1967

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/guide/advanced/lite.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,13 @@ Then, at the entry point of the application, configure the message resolver and

```js
import { createApp } from 'vue'
import { createI18n } from 'petite-vue-i18n'
import {
createI18n,
registerMessageResolver, // register the message resolver API
resolveValue, // message resolver of vue-i18n which is used by default
registerLocaleFallbacker, // register the locale fallbacker API
} from 'petite-vue-i18n'
import {
resolveValue, // message resolver of vue-i18n which is used by default
fallbackWithLocaleChain // locale fallbacker of vue-i18n which is used by default
} from '@intlify/core-base'

Expand Down
124 changes: 63 additions & 61 deletions packages/petite-vue-i18n/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { getGlobalThis } from '@intlify/shared'
import {
setDevToolsHook,
compile,
registerMessageCompiler,
compile
setDevToolsHook
} from '@intlify/core-base'
import { getGlobalThis } from '@intlify/shared'
import { initDev, initFeatureFlags } from '../../vue-i18n-core/src/misc'

if (__ESM_BUNDLER__ && !__TEST__) {
Expand All @@ -14,96 +14,98 @@ if (__ESM_BUNDLER__ && !__TEST__) {
registerMessageCompiler(compile)

export {
Path,
PathValue,
NamedValue,
Locale,
CompileError,
DateTimeOptions,
FallbackLocale,
LocaleMessageValue,
LocaleMessageDictionary,
LocaleMessageType,
LocaleMessages,
NumberFormat as IntlNumberFormat,
GeneratedTypeConfig,
DateTimeFormat as IntlDateTimeFormat,
DateTimeFormats as IntlDateTimeFormats,
NumberFormats as IntlNumberFormats,
LocaleMatcher as IntlLocaleMatcher,
FormatMatcher as IntlFormatMatcher,
MessageFunction,
MessageFunctions,
PluralizationRule,
LocaleMatcher as IntlLocaleMatcher,
NumberFormat as IntlNumberFormat,
NumberFormats as IntlNumberFormats,
LinkedModifiers,
TranslateOptions,
DateTimeOptions,
NumberOptions,
PostTranslationHandler,
MessageResolver,
Locale,
LocaleMessageDictionary,
LocaleMessages,
LocaleMessageType,
LocaleMessageValue,
MessageCompiler,
MessageCompilerContext,
CompileError,
MessageContext,
MessageFunction,
MessageFunctions,
MessageResolver,
NamedValue,
NumberOptions,
Path,
PathValue,
PluralizationRule,
PostTranslationHandler,
registerLocaleFallbacker,
registerMessageResolver,
RemovedIndexResources,
GeneratedTypeConfig
TranslateOptions
} from '@intlify/core-base'
export {
VueMessageType,
DefineLocaleMessage,
DefaultLocaleMessageSchema,
DefineDateTimeFormat,
DefaultDateTimeFormatSchema,
DefineNumberFormat,
DefaultNumberFormatSchema,
MissingHandler,
ComposerOptions,
Composer,
ComposerCustom,
CustomBlock,
CustomBlocks,
ComposerTranslation,
ComposerDateTimeFormatting,
ComposerNumberFormatting,
ComposerResolveLocaleMessageTranslation
ComposerOptions,
ComposerResolveLocaleMessageTranslation,
ComposerTranslation,
CustomBlock,
CustomBlocks,
DefaultDateTimeFormatSchema,
DefaultLocaleMessageSchema,
DefaultNumberFormatSchema,
DefineDateTimeFormat,
DefineLocaleMessage,
DefineNumberFormat,
MissingHandler,
VueMessageType
} from '../../vue-i18n-core/src/composer'
export {
TranslateResult,
ComposerAdditionalOptions,
ComposerExtender,
createI18n,
ExportedGlobalComposer,
I18n,
I18nAdditionalOptions,
I18nMode,
I18nOptions,
I18nScope,
useI18n,
UseI18nOptions
} from '../../vue-i18n-core/src/i18n'
export {
Choice,
LocaleMessageObject,
PluralizationRulesMap,
WarnHtmlInMessageLevel,
DateTimeFormatResult,
LocaleMessageObject,
NumberFormatResult,
VueI18nOptions,
PluralizationRulesMap,
TranslateResult,
VueI18n,
VueI18nTranslation,
VueI18nTranslationChoice,
VueI18nDateTimeFormatting,
VueI18nExtender,
VueI18nNumberFormatting,
VueI18nOptions,
VueI18nResolveLocaleMessageTranslation,
VueI18nExtender
VueI18nTranslation,
VueI18nTranslationChoice,
WarnHtmlInMessageLevel
} from '../../vue-i18n-core/src/legacy'
export {
createI18n,
useI18n,
I18nOptions,
I18nAdditionalOptions,
I18n,
I18nMode,
I18nScope,
ComposerAdditionalOptions,
UseI18nOptions,
ExportedGlobalComposer,
ComposerExtender
} from '../../vue-i18n-core/src/i18n'
export { I18nPluginOptions } from '../../vue-i18n-core/src/plugin'
export { VERSION } from './../../vue-i18n-core/src/misc'
export { Disposer } from './../../vue-i18n-core/src/types'

export type {
IsNever,
IsEmptyObject,
PickupPaths,
IsNever,
PickupFormatPathKeys,
PickupKeys,
PickupFormatPathKeys
PickupPaths
} from '@intlify/core-base'

// NOTE: experimental !!
Expand Down
124 changes: 63 additions & 61 deletions packages/petite-vue-i18n/src/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { getGlobalThis } from '@intlify/shared'
import {
setDevToolsHook,
compile,
registerMessageCompiler
registerMessageCompiler,
setDevToolsHook
} from '@intlify/core-base'
import { getGlobalThis } from '@intlify/shared'
import { initDev, initFeatureFlags } from '../../vue-i18n-core/src/misc'

if (__ESM_BUNDLER__ && !__TEST__) {
Expand All @@ -14,95 +14,97 @@ if (__ESM_BUNDLER__ && !__TEST__) {
registerMessageCompiler(compile)

export {
Path,
PathValue,
NamedValue,
Locale,
CompileError,
DateTimeOptions,
FallbackLocale,
LocaleMessageValue,
LocaleMessageDictionary,
LocaleMessageType,
LocaleMessages,
NumberFormat as IntlNumberFormat,
DateTimeFormat as IntlDateTimeFormat,
DateTimeFormats as IntlDateTimeFormats,
NumberFormats as IntlNumberFormats,
LocaleMatcher as IntlLocaleMatcher,
FormatMatcher as IntlFormatMatcher,
MessageFunction,
MessageFunctions,
PluralizationRule,
LocaleMatcher as IntlLocaleMatcher,
NumberFormat as IntlNumberFormat,
NumberFormats as IntlNumberFormats,
LinkedModifiers,
TranslateOptions,
DateTimeOptions,
NumberOptions,
PostTranslationHandler,
MessageResolver,
Locale,
LocaleMessageDictionary,
LocaleMessages,
LocaleMessageType,
LocaleMessageValue,
MessageCompiler,
MessageCompilerContext,
CompileError,
MessageContext,
RemovedIndexResources
MessageFunction,
MessageFunctions,
MessageResolver,
NamedValue,
NumberOptions,
Path,
PathValue,
PluralizationRule,
PostTranslationHandler,
registerLocaleFallbacker,
registerMessageResolver,
RemovedIndexResources,
TranslateOptions
} from '@intlify/core-base'
export {
VueMessageType,
DefineLocaleMessage,
DefaultLocaleMessageSchema,
DefineDateTimeFormat,
DefaultDateTimeFormatSchema,
DefineNumberFormat,
DefaultNumberFormatSchema,
MissingHandler,
ComposerOptions,
Composer,
ComposerCustom,
CustomBlock,
CustomBlocks,
ComposerTranslation,
ComposerDateTimeFormatting,
ComposerNumberFormatting,
ComposerResolveLocaleMessageTranslation
ComposerOptions,
ComposerResolveLocaleMessageTranslation,
ComposerTranslation,
CustomBlock,
CustomBlocks,
DefaultDateTimeFormatSchema,
DefaultLocaleMessageSchema,
DefaultNumberFormatSchema,
DefineDateTimeFormat,
DefineLocaleMessage,
DefineNumberFormat,
MissingHandler,
VueMessageType
} from '../../vue-i18n-core/src/composer'
export {
TranslateResult,
ComposerAdditionalOptions,
ComposerExtender,
createI18n,
ExportedGlobalComposer,
I18n,
I18nAdditionalOptions,
I18nMode,
I18nOptions,
I18nScope,
useI18n,
UseI18nOptions
} from '../../vue-i18n-core/src/i18n'
export {
Choice,
LocaleMessageObject,
PluralizationRulesMap,
WarnHtmlInMessageLevel,
DateTimeFormatResult,
LocaleMessageObject,
NumberFormatResult,
VueI18nOptions,
PluralizationRulesMap,
TranslateResult,
VueI18n,
VueI18nTranslation,
VueI18nTranslationChoice,
VueI18nDateTimeFormatting,
VueI18nExtender,
VueI18nNumberFormatting,
VueI18nOptions,
VueI18nResolveLocaleMessageTranslation,
VueI18nExtender
VueI18nTranslation,
VueI18nTranslationChoice,
WarnHtmlInMessageLevel
} from '../../vue-i18n-core/src/legacy'
export {
createI18n,
useI18n,
I18nOptions,
I18nAdditionalOptions,
I18n,
I18nMode,
I18nScope,
ComposerAdditionalOptions,
UseI18nOptions,
ExportedGlobalComposer,
ComposerExtender
} from '../../vue-i18n-core/src/i18n'
export { I18nPluginOptions } from '../../vue-i18n-core/src/plugin'
export { VERSION } from './../../vue-i18n-core/src/misc'
export { Disposer } from './../../vue-i18n-core/src/types'

export type {
IsNever,
IsEmptyObject,
PickupPaths,
IsNever,
PickupFormatPathKeys,
PickupKeys,
PickupFormatPathKeys
PickupPaths
} from '@intlify/core-base'

// NOTE: experimental !!
Expand Down