diff --git a/source/Ox/js/Locale.js b/source/Ox/js/Locale.js index 5a1ef406..0ecc311d 100644 --- a/source/Ox/js/Locale.js +++ b/source/Ox/js/Locale.js @@ -13,7 +13,8 @@ success If true, locale has been set @*/ Ox.setLocale = function(locale, url, callback) { - var isValidLocale = Ox.contains(Object.keys(Ox.LOCALES), locale); + var isValidLocale = Ox.contains(Object.keys(Ox.LOCALE_NAMES), locale), + urls = []; if (arguments.length == 2) { callback = arguments[1]; url = null; @@ -24,20 +25,21 @@ translations = {}; callback(true); } else { - Ox.getJSON( - Ox.PATH + 'Ox/json/locale.' + locale + '.json', - function(data) { - translations = data; - if (url) { - Ox.getJSON(url, function(data) { - Ox.extend(translations, data); - callback(true); - }); - } else { - callback(true); - } + Ox.forEach(Ox.LOCALES, function(locales, module) { + if (Ox.contains(locales, locale)) { + urls.push([ + Ox.PATH + 'Ox' + (module ? '.' + module : '') + + '/json/locale.' + locale + '.json' + ]); } - ); + }); + url && urls.push([url]); + Ox.getJSON(urls, function(data) { + urls.forEach(function(url) { + Ox.extend(translations, data[url]); + callback(true); + }); + }); } } else { callback(isValidLocale);