Skip to content

Commit

Permalink
fix(ui): merge locales
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Apr 30, 2018
1 parent 9d87b35 commit ae552a9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/@vue/cli-ui/src/graphql-api/connectors/locales.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path')
const fs = require('fs')
const globby = require('globby')
const deepmerge = require('deepmerge')
// Connectors
const cwd = require('./cwd')
// Subs
Expand All @@ -17,9 +18,13 @@ function list (context) {
return locales
}

function add ({ lang, strings }, context) {
const locale = { lang, strings }
locales.push(locale)
function add (locale, context) {
const existing = locales.find(l => l.lang === locale.lang)
if (existing) {
existing.strings = deepmerge(existing.strings, locale.strings)
} else {
locales.push(locale)
}
context.pubsub.publish(channels.LOCALE_ADDED, {
localeAdded: locale
})
Expand Down

0 comments on commit ae552a9

Please sign in to comment.