Skip to content

Commit ae552a9

Browse files
author
Guillaume Chau
committed
fix(ui): merge locales
1 parent 9d87b35 commit ae552a9

File tree

1 file changed

+8
-3
lines changed
  • packages/@vue/cli-ui/src/graphql-api/connectors

1 file changed

+8
-3
lines changed

packages/@vue/cli-ui/src/graphql-api/connectors/locales.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const path = require('path')
22
const fs = require('fs')
33
const globby = require('globby')
4+
const deepmerge = require('deepmerge')
45
// Connectors
56
const cwd = require('./cwd')
67
// Subs
@@ -17,9 +18,13 @@ function list (context) {
1718
return locales
1819
}
1920

20-
function add ({ lang, strings }, context) {
21-
const locale = { lang, strings }
22-
locales.push(locale)
21+
function add (locale, context) {
22+
const existing = locales.find(l => l.lang === locale.lang)
23+
if (existing) {
24+
existing.strings = deepmerge(existing.strings, locale.strings)
25+
} else {
26+
locales.push(locale)
27+
}
2328
context.pubsub.publish(channels.LOCALE_ADDED, {
2429
localeAdded: locale
2530
})

0 commit comments

Comments
 (0)