Skip to content

Commit

Permalink
fix: merge resources correctly on multiple lazy loading (#1809)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon authored Jan 22, 2023
1 parent e93cc24 commit 5bd81af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
22 changes: 8 additions & 14 deletions src/runtime/internal.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */

import { isArray, isString, isFunction, isObject, hasOwn } from '@intlify/shared'
import { isArray, isString, isFunction, isObject } from '@intlify/shared'
import {
findBrowserLocale,
getLocalesRegex,
Expand Down Expand Up @@ -94,20 +94,14 @@ export function parseAcceptLanguage(input: string): string[] {
return input.split(',').map(tag => tag.split(';')[0])
}

const isNotObjectOrIsArray = (val: unknown) => !isObject(val) || isArray(val)

function deepCopy(src: any, des: any) {
if (isNotObjectOrIsArray(src) || isNotObjectOrIsArray(des)) {
return
}

function deepCopy(src: Record<string, any>, des: Record<string, any>) {
for (const key in src) {
if (hasOwn(src, key)) {
if (isNotObjectOrIsArray(src[key]) || isNotObjectOrIsArray(des[key])) {
des[key] = src[key]
} else {
deepCopy(src[key], des[key])
}
if (isObject(src[key])) {
if (!isObject(des[key])) des[key] = {}

deepCopy(src[key], des[key])
} else {
des[key] = src[key]
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { promises as fs, constants as FS_CONSTANTS } from 'node:fs'
import { resolveFiles } from '@nuxt/kit'
import { parse, parse as parsePath, resolve } from 'pathe'
import { parse as parsePath, resolve } from 'pathe'
import { encodePath } from 'ufo'
import { resolveLockfile } from 'pkg-types'
import { isObject, isString } from '@intlify/shared'
import { isString } from '@intlify/shared'
import { NUXT_I18N_MODULE_ID } from './constants'

import type { LocaleObject } from 'vue-i18n-routing'
Expand Down

0 comments on commit 5bd81af

Please sign in to comment.