Skip to content

Commit

Permalink
Merge pull request #208 from osela/master
Browse files Browse the repository at this point in the history
Register 'en' locale first
  • Loading branch information
caridy authored Aug 11, 2016
2 parents c4c5186 + 5b759af commit 947fbb8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion locale-data/complete.js

Large diffs are not rendered by default.

23 changes: 17 additions & 6 deletions scripts/build-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,38 @@ let
valCount = 0,
objCount = 0,

fileData = '';
fileData = '',

fileData += '(function(addLocaleData){\n';
locReducedData = {},
locNames = Object.keys(locStringData);

const
defaultLocale = 'en',
defaultLocaleIndex = locNames.indexOf(defaultLocale);

if (defaultLocaleIndex !== -1) {
// Move the default locale to the beginning
locNames.splice(defaultLocaleIndex, 1);
locNames.unshift(defaultLocale);
}

let locReducedData = {};
Object.keys(locStringData).forEach((k) => {
locNames.forEach((k) => {
const c = locStringData[k];
locReducedData[k] = JSON.parse(c, reviver);
});

fileData += '(function(addLocaleData){\n';
fileData += `var a=${JSON.stringify(prims)},b=[];`;
objs.forEach((val, idx) => {
const ref = JSON.stringify(val).replace(/"###(objs|prims)(\[[^#]+)###"/g, replacer);

fileData += `b[${idx}]=${ref};`;
});

for (let k in locReducedData) {
locNames.forEach((k) => {
fileData += `addLocaleData(${locReducedData[k].replace(/###(objs|prims)(\[[^#]+)###/, replacer)});
`;
}
});

fileData += `})(IntlPolyfill.__addLocaleData);`;

Expand Down

0 comments on commit 947fbb8

Please sign in to comment.