diff --git a/src/Generator.php b/src/Generator.php index f5d854e..200f0c3 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -357,7 +357,7 @@ private function getUMDModule($body) (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : - (global.vuei18nLocales = factory()); + typeof global.vuei18nLocales === 'undefined' ? global.vuei18nLocales = factory() : Object.keys(factory()).forEach(function (key) {global.vuei18nLocales[key] = factory()[key]}); }(this, (function () { 'use strict'; return {$body} }))); diff --git a/tests/GenerateTest.php b/tests/GenerateTest.php index 85eac85..1f218dc 100644 --- a/tests/GenerateTest.php +++ b/tests/GenerateTest.php @@ -211,7 +211,7 @@ function testBasicWithUMDFormat() '(function (global, factory) {' . PHP_EOL . ' typeof exports === \'object\' && typeof module !== \'undefined\' ? module.exports = factory() :' . PHP_EOL . ' typeof define === \'function\' && define.amd ? define(factory) :' . PHP_EOL - . ' (global.vuei18nLocales = factory());' . PHP_EOL + . ' typeof global.vuei18nLocales === \'undefined\' ? global.vuei18nLocales = factory() : Object.keys(factory()).forEach(function (key) {global.vuei18nLocales[key] = factory()[key]});' . PHP_EOL . '}(this, (function () { \'use strict\';' . PHP_EOL . ' return {' . PHP_EOL . ' "en": {' . PHP_EOL