Skip to content

Commit

Permalink
Fixed LocalUtils and Setting plugin to display supported locales (#1864)
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap authored and offtherailz committed May 22, 2017
1 parent a3ea7f1 commit 8956ff3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion web/client/plugins/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const {Glyphicon} = require('react-bootstrap');
const assign = require('object-assign');

const SettingsPanel = require('./settings/SettingsPanel');
const LocaleUtils = require('../utils/LocaleUtils');
const {Panel} = require('react-bootstrap');
const Dialog = require('../components/misc/Dialog');

Expand Down Expand Up @@ -85,7 +86,7 @@ const SettingsButton = React.createClass({
},
renderSettings() {
const settingsFirst = {
language: <span><label><Message msgId="language" /></label> <LangBar key="langSelector"/></span>
language: <span><label><Message msgId="language" /></label> <LangBar locales={LocaleUtils.getSupportedLocales()} key="langSelector"/></span>
};
const settingsLast = {
history: <HistoryBar
Expand Down
6 changes: 4 additions & 2 deletions web/client/utils/LocaleUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ const LocaleUtils = {
return LocaleUtils.getLocale(url.parse(window.location.href, true).query);
},
getLocale: function(query) {
const key = Object.keys(supportedLocales)[0];
const defaultLocale = supportedLocales.en ? { key: 'en', locale: supportedLocales.en } : { key, locale: supportedLocales[key] };
let locale = supportedLocales[
LocaleUtils.normalizeLocaleCode(query.locale || (navigator ? navigator.language || navigator.browserLanguage : "en"))
LocaleUtils.normalizeLocaleCode(query.locale || (navigator ? navigator.language || navigator.browserLanguage : defaultLocale.key))
];
return locale ? locale.code : "en-US";
return locale ? locale.code : defaultLocale.locale.code;
},
getSupportedLocales: function() {
return supportedLocales;
Expand Down

0 comments on commit 8956ff3

Please sign in to comment.