Skip to content

Commit d82ad4e

Browse files
authored
fix: custom block reosurce processing errors (#698)
* fix: __INTLIFY_META__ access error in vue-i18n-bridge closes #692 * fix: createI18n second argument type error * fix: custom block reosurce processing errors closes #693
1 parent 5c61e65 commit d82ad4e

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

packages/vue-i18n-core/src/utils.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
import { isArray, isObject, hasOwn, isPlainObject } from '@intlify/shared'
2+
import {
3+
isArray,
4+
isObject,
5+
hasOwn,
6+
isPlainObject,
7+
isString
8+
} from '@intlify/shared'
39
import { I18nErrorCodes, createI18nError } from './errors'
410

511
import type { Locale, MessageResolver } from '@intlify/core-base'
@@ -83,12 +89,17 @@ export function getLocaleMessages<Messages = {}>(
8389

8490
// merge locale messages of i18n custom block
8591
if (isArray(__i18n)) {
86-
__i18n.forEach(({ locale, resource }) => {
87-
if (locale) {
88-
ret[locale] = ret[locale] || {}
89-
deepCopy(resource, ret[locale])
92+
__i18n.forEach(custom => {
93+
if ('locale' in custom && 'resource' in custom) {
94+
const { locale, resource } = custom
95+
if (locale) {
96+
ret[locale] = ret[locale] || {}
97+
deepCopy(resource, ret[locale])
98+
} else {
99+
deepCopy(resource, ret)
100+
}
90101
} else {
91-
deepCopy(resource, ret)
102+
isString(custom) && deepCopy(JSON.parse(custom), ret)
92103
}
93104
})
94105
}

0 commit comments

Comments
 (0)