-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathgulpfile.js
77 lines (66 loc) · 2.61 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const gulp = require('gulp');
const exec = require('child_process').exec;
const numbers = require("cldr-numbers-full/main/en/numbers.json");
const currencies = require("cldr-numbers-full/main/en/currencies.json");
const timeZoneNames = require("cldr-dates-full/main/en/timeZoneNames.json");
const calendar = require("cldr-dates-full/main/en/ca-gregorian.json");
const likelySubtags = require("cldr-core/supplemental/likelySubtags.json");
const currencyData = require("cldr-core/supplemental/currencyData.json");
const weekData = require("cldr-core/supplemental/weekData.json");
const fs = require('fs');
const { toJSObject, buildLocales } = require("./build-locales.js");
const DEFAULT_TERRITORY = '001';
require('@progress/kendo-package-tasks')(gulp, 'kendo-intl');
const cleanupCurrencies = (locale) => {
const currencies = locale.numbers.currencies;
const subset = {};
Object.keys(currencies).forEach(id => {
const data = currencies[id];
if (id === 'USD' || id === 'EUR' || id === 'BGN') {
subset[id] = data;
}
});
locale.numbers.currencies = subset;
return locale;
};
gulp.task("build-default-data", gulp.series("build-npm-package", () => {
const cldr = require("./dist/npm/js/cldr");
cldr.load(likelySubtags, currencyData, weekData, numbers, currencies, timeZoneNames, calendar);
const defaultData = {
en: cleanupCurrencies(cldr.cldr.en),
supplemental: {
likelySubtags: {
en: "en-Latn-US"
},
currencyData: {
region: {
"US": [{
"USD": { "_from": "1792-01-01" }
}]
}
},
weekData: {
firstDay: {
US: cldr.cldr.supplemental.weekData.firstDay.US
},
weekendStart: {
[DEFAULT_TERRITORY]: cldr.cldr.supplemental.weekData.weekendStart[DEFAULT_TERRITORY]
},
weekendEnd: {
[DEFAULT_TERRITORY]: cldr.cldr.supplemental.weekData.weekendEnd[DEFAULT_TERRITORY]
}
}
}
};
fs.writeFileSync('src/cldr/default-data.js', `const defaultData = ${ toJSObject(defaultData) };\nexport default defaultData;`);
}));
gulp.task('clean-locales', (done) => {
exec(`rm -rf locales`, () => {
done();
});
});
gulp.task("build-locales", gulp.series("build-npm-package", 'clean-locales', (done) => {
const intl = require('./dist/npm/js/main');
buildLocales(intl, { destFolder: './locale-tests/locales' });
done();
}));