Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Update index.js #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/runtime/web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ documentReady().then(() => {
});

function createLocalization(name, resIds, defaultLang, availableLangs) {
function requestBundles(requestedLangs = new Set(navigator.languages)) {
let langs = navigator.languages;

for (let i=0; i < langs.length; i++) {
if (langs[i].indexOf('-') > 0 && availableLangs.has(langs[i]) === false) {
langs[i] = langs[i].substring(0, langs[i].indexOf('-'));
}
}

function requestBundles(requestedLangs = new Set(langs)) {
const newLangs = prioritizeLocales(
defaultLang, availableLangs, requestedLangs
);
Expand Down