Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Commit 947fbb8

Browse files
authored
Merge pull request #208 from osela/master
Register 'en' locale first
2 parents c4c5186 + 5b759af commit 947fbb8

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

locale-data/complete.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/build-data.js

+17-6
Original file line numberDiff line numberDiff line change
@@ -133,27 +133,38 @@ let
133133
valCount = 0,
134134
objCount = 0,
135135

136-
fileData = '';
136+
fileData = '',
137137

138-
fileData += '(function(addLocaleData){\n';
138+
locReducedData = {},
139+
locNames = Object.keys(locStringData);
140+
141+
const
142+
defaultLocale = 'en',
143+
defaultLocaleIndex = locNames.indexOf(defaultLocale);
144+
145+
if (defaultLocaleIndex !== -1) {
146+
// Move the default locale to the beginning
147+
locNames.splice(defaultLocaleIndex, 1);
148+
locNames.unshift(defaultLocale);
149+
}
139150

140-
let locReducedData = {};
141-
Object.keys(locStringData).forEach((k) => {
151+
locNames.forEach((k) => {
142152
const c = locStringData[k];
143153
locReducedData[k] = JSON.parse(c, reviver);
144154
});
145155

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

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

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

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

0 commit comments

Comments
 (0)