diff --git a/modules/core/context.js b/modules/core/context.js index 5007e9569..a0c8ee52a 100644 --- a/modules/core/context.js +++ b/modules/core/context.js @@ -318,16 +318,22 @@ export function coreContext(root) { return context; }; - context.loadLocale = function(cb) { + context.loadLocale = function(callback) { if (locale && locale !== 'en' && dataLocales.indexOf(locale) !== -1) { localePath = localePath || context.asset('locales/' + locale + '.json'); d3.json(localePath, function(err, result) { - addTranslation(locale, result[locale]); - setLocale(locale); - cb(); + if (!err) { + addTranslation(locale, result[locale]); + setLocale(locale); + } + if (callback) { + callback(err); + } }); } else { - cb(); + if (callback) { + callback(); + } } }; diff --git a/modules/ui/init.js b/modules/ui/init.js index 4f9d682ac..ffa257209 100644 --- a/modules/ui/init.js +++ b/modules/ui/init.js @@ -284,11 +284,16 @@ export function uiInit(context) { } - function ui(node) { + function ui(node, callback) { var container = d3.select(node); context.container(container); - context.loadLocale(function() { - render(container); + context.loadLocale(function(err) { + if (!err) { + render(container); + } + if (callback) { + callback(err); + } }); }