Skip to content

Commit

Permalink
Handle scenario when the user preferred language header is not passed
Browse files Browse the repository at this point in the history
The UI when loading asks i18n plugin which language translation to use
depending on the user preferred language header 'accept-language'.
This commit is to handle scenario where header is not passed. The algorithm
then chooses the default language.
  • Loading branch information
hickeyma committed Dec 13, 2016
1 parent 5f61475 commit 9fbe6d5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ function translate(key) {
async function getTranslationLanguage(acceptLanguages) {
let langStr = '';
let foundLang = false;

if (acceptLanguages === null || acceptLanguages.length <= 0) {
return DEFAULT_LANGUAGE;
}

const acceptLangsLen = acceptLanguages.length;
const registeredLanguages = await i18nPlugin.getRegisteredTranslationLanguages();

Expand Down

0 comments on commit 9fbe6d5

Please sign in to comment.