Skip to content

Commit

Permalink
Add current locale
Browse files Browse the repository at this point in the history
  • Loading branch information
qathom committed Jan 14, 2018
1 parent 4318f07 commit 7ff1a84
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/js/core/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
;(function (window, document) {

var jsonCache = null;
var localeUsed = null;
var currentLocale = null;

var opts = {
localeFallback: null,
Expand Down Expand Up @@ -133,6 +133,8 @@
opts[prop] = options[prop];
}

currentLocale = opts.localeFallback

if(typeof options.use !== 'undefined') {
opts.loadJson = false
}
Expand All @@ -155,6 +157,8 @@

var locale = opts.localePreferred ? opts.localePreferred : opts.localeFallback;

currentLocale = locale

if(opts.loadJson) {
// JSON
if(jsonCache !== null) {
Expand All @@ -181,7 +185,6 @@
try {
var json = JSON.parse(xhr.responseText);
jsonCache = json;
localeUsed = locale;
callback(jsonCache);
} catch (e) {
fallback();
Expand Down Expand Up @@ -347,8 +350,8 @@
getLocale: function () {
return getLocale();
},
getLoadedLocale: function () {
return localeUsed;
getCurrentLocale: function () {
return currentLocale;
}
};
};
Expand Down

0 comments on commit 7ff1a84

Please sign in to comment.