From f24f90dadd76918e17d45b1d9d77a57bb4afc99a Mon Sep 17 00:00:00 2001 From: Will Vincent Date: Fri, 28 Oct 2016 03:35:07 -0500 Subject: [PATCH] Better locale check logic. --- app/js/welcome.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/js/welcome.js b/app/js/welcome.js index 08a903d..ee92ddb 100644 --- a/app/js/welcome.js +++ b/app/js/welcome.js @@ -33,7 +33,13 @@ $.each(i18n.fullLocaleList, (i, v) => { }); // Try to figure out user's language -$('#locales-list').val(app.getLocale() ? app.getLocale().split('-')[0] : 'en'); +if (app.getLocale() in i18n.fullLocaleList) { + $('#locales-list').val(app.getLocale()); +} else if (app.getLocale().split('-')[0] in i18n.fullLocaleList) { + $('#locales-list').val(app.getLocale().split('-')[0]); +} else { + $('#locales-list').val('en'); +} /* Go button action */ $('#go').click(() => {