1
0
mirror of https://github.com/excalidraw/excalidraw.git synced 2024-11-10 11:35:52 +01:00
excalidraw/scripts/build-locales-coverage.js

38 lines
1.1 KiB
JavaScript
Raw Normal View History

Add script to calculate percentage of translation (#1826) * add script to calculate percentage of translation * test translation change * change translation * test * change translation * Calculate percentages of each translation file * test * Calculate percentages of each translation file * change translation * test * test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * fix workflow * test * test again * Calculate percentages of each translation file * Calculate percentages of each translation file * test * refactor * change build logic * fix types, move English first * docs added * test translation file * test * test * test * test * test * test * test * test * test * test * test * test * Calculate percentages of each translation file * let this be the final test please * Calculate percentages of each translation file * test * test * Test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * test * Auto commit: Calculate translation coverage * test * test * test * test * Auto commit: Calculate translation coverage * test * only on master * test * test * Auto commit: Calculate translation coverage * switch to master branch Co-authored-by: i18n automation <runner@fv-az76.2iswp1o5zimezclxzdlwqia2gf.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az129.idlktykl4ure3gqe2lnji05orb.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az76.pjgcdo5npjpenpqz2nk0ztqvxd.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az33.senarqq4ucbulg04aytwntvgah.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az51.icvemaqob4xunfekbtdiz2tu2c.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az78.gikxu4m3dpiulftj3bftpuu3ee.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az121.cqdewbghluceforu5pkvpnveec.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az139.jsbds1i2htye3fh1bzwbe4ugmf.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az50.0bg2cysi0dkefjvuua0a0kbd1h.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az51.nhi3in4tbx4ehjtltcwuwbwsua.cx.internal.cloudapp.net>
2020-06-30 20:28:19 +02:00
const { readdirSync, writeFileSync } = require("fs");
const files = readdirSync(`${__dirname}/../packages/excalidraw/locales`);
Add script to calculate percentage of translation (#1826) * add script to calculate percentage of translation * test translation change * change translation * test * change translation * Calculate percentages of each translation file * test * Calculate percentages of each translation file * change translation * test * test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * fix workflow * test * test again * Calculate percentages of each translation file * Calculate percentages of each translation file * test * refactor * change build logic * fix types, move English first * docs added * test translation file * test * test * test * test * test * test * test * test * test * test * test * test * Calculate percentages of each translation file * let this be the final test please * Calculate percentages of each translation file * test * test * Test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * test * Auto commit: Calculate translation coverage * test * test * test * test * Auto commit: Calculate translation coverage * test * only on master * test * test * Auto commit: Calculate translation coverage * switch to master branch Co-authored-by: i18n automation <runner@fv-az76.2iswp1o5zimezclxzdlwqia2gf.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az129.idlktykl4ure3gqe2lnji05orb.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az76.pjgcdo5npjpenpqz2nk0ztqvxd.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az33.senarqq4ucbulg04aytwntvgah.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az51.icvemaqob4xunfekbtdiz2tu2c.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az78.gikxu4m3dpiulftj3bftpuu3ee.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az121.cqdewbghluceforu5pkvpnveec.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az139.jsbds1i2htye3fh1bzwbe4ugmf.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az50.0bg2cysi0dkefjvuua0a0kbd1h.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az51.nhi3in4tbx4ehjtltcwuwbwsua.cx.internal.cloudapp.net>
2020-06-30 20:28:19 +02:00
const flatten = (object = {}, result = {}, extraKey = "") => {
for (const key in object) {
if (typeof object[key] !== "object") {
result[extraKey + key] = object[key];
} else {
flatten(object[key], result, `${extraKey}${key}.`);
}
}
return result;
};
Add script to calculate percentage of translation (#1826) * add script to calculate percentage of translation * test translation change * change translation * test * change translation * Calculate percentages of each translation file * test * Calculate percentages of each translation file * change translation * test * test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * fix workflow * test * test again * Calculate percentages of each translation file * Calculate percentages of each translation file * test * refactor * change build logic * fix types, move English first * docs added * test translation file * test * test * test * test * test * test * test * test * test * test * test * test * Calculate percentages of each translation file * let this be the final test please * Calculate percentages of each translation file * test * test * Test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * test * Auto commit: Calculate translation coverage * test * test * test * test * Auto commit: Calculate translation coverage * test * only on master * test * test * Auto commit: Calculate translation coverage * switch to master branch Co-authored-by: i18n automation <runner@fv-az76.2iswp1o5zimezclxzdlwqia2gf.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az129.idlktykl4ure3gqe2lnji05orb.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az76.pjgcdo5npjpenpqz2nk0ztqvxd.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az33.senarqq4ucbulg04aytwntvgah.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az51.icvemaqob4xunfekbtdiz2tu2c.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az78.gikxu4m3dpiulftj3bftpuu3ee.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az121.cqdewbghluceforu5pkvpnveec.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az139.jsbds1i2htye3fh1bzwbe4ugmf.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az50.0bg2cysi0dkefjvuua0a0kbd1h.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az51.nhi3in4tbx4ehjtltcwuwbwsua.cx.internal.cloudapp.net>
2020-06-30 20:28:19 +02:00
const locales = files.filter(
(file) => file !== "README.md" && file !== "percentages.json",
);
const percentages = {};
for (let index = 0; index < locales.length; index++) {
const currentLocale = locales[index];
const data = flatten(
require(`${__dirname}/../packages/excalidraw/locales/${currentLocale}`),
);
Add script to calculate percentage of translation (#1826) * add script to calculate percentage of translation * test translation change * change translation * test * change translation * Calculate percentages of each translation file * test * Calculate percentages of each translation file * change translation * test * test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * fix workflow * test * test again * Calculate percentages of each translation file * Calculate percentages of each translation file * test * refactor * change build logic * fix types, move English first * docs added * test translation file * test * test * test * test * test * test * test * test * test * test * test * test * Calculate percentages of each translation file * let this be the final test please * Calculate percentages of each translation file * test * test * Test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * test * Auto commit: Calculate translation coverage * test * test * test * test * Auto commit: Calculate translation coverage * test * only on master * test * test * Auto commit: Calculate translation coverage * switch to master branch Co-authored-by: i18n automation <runner@fv-az76.2iswp1o5zimezclxzdlwqia2gf.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az129.idlktykl4ure3gqe2lnji05orb.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az76.pjgcdo5npjpenpqz2nk0ztqvxd.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az33.senarqq4ucbulg04aytwntvgah.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az51.icvemaqob4xunfekbtdiz2tu2c.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az78.gikxu4m3dpiulftj3bftpuu3ee.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az121.cqdewbghluceforu5pkvpnveec.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az139.jsbds1i2htye3fh1bzwbe4ugmf.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az50.0bg2cysi0dkefjvuua0a0kbd1h.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az51.nhi3in4tbx4ehjtltcwuwbwsua.cx.internal.cloudapp.net>
2020-06-30 20:28:19 +02:00
const allKeys = Object.keys(data);
const translatedKeys = allKeys.filter((item) => data[item] !== "");
const percentage = Math.floor((100 * translatedKeys.length) / allKeys.length);
percentages[currentLocale.replace(".json", "")] = percentage;
Add script to calculate percentage of translation (#1826) * add script to calculate percentage of translation * test translation change * change translation * test * change translation * Calculate percentages of each translation file * test * Calculate percentages of each translation file * change translation * test * test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * fix workflow * test * test again * Calculate percentages of each translation file * Calculate percentages of each translation file * test * refactor * change build logic * fix types, move English first * docs added * test translation file * test * test * test * test * test * test * test * test * test * test * test * test * Calculate percentages of each translation file * let this be the final test please * Calculate percentages of each translation file * test * test * Test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * test * Auto commit: Calculate translation coverage * test * test * test * test * Auto commit: Calculate translation coverage * test * only on master * test * test * Auto commit: Calculate translation coverage * switch to master branch Co-authored-by: i18n automation <runner@fv-az76.2iswp1o5zimezclxzdlwqia2gf.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az129.idlktykl4ure3gqe2lnji05orb.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az76.pjgcdo5npjpenpqz2nk0ztqvxd.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az33.senarqq4ucbulg04aytwntvgah.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az51.icvemaqob4xunfekbtdiz2tu2c.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az78.gikxu4m3dpiulftj3bftpuu3ee.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az121.cqdewbghluceforu5pkvpnveec.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az139.jsbds1i2htye3fh1bzwbe4ugmf.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az50.0bg2cysi0dkefjvuua0a0kbd1h.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az51.nhi3in4tbx4ehjtltcwuwbwsua.cx.internal.cloudapp.net>
2020-06-30 20:28:19 +02:00
}
writeFileSync(
`${__dirname}/../packages/excalidraw/locales/percentages.json`,
2020-07-07 17:30:58 +02:00
`${JSON.stringify(percentages, null, 2)}\n`,
Add script to calculate percentage of translation (#1826) * add script to calculate percentage of translation * test translation change * change translation * test * change translation * Calculate percentages of each translation file * test * Calculate percentages of each translation file * change translation * test * test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * fix workflow * test * test again * Calculate percentages of each translation file * Calculate percentages of each translation file * test * refactor * change build logic * fix types, move English first * docs added * test translation file * test * test * test * test * test * test * test * test * test * test * test * test * Calculate percentages of each translation file * let this be the final test please * Calculate percentages of each translation file * test * test * Test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * test * Calculate percentages of each translation file * test * Auto commit: Calculate translation coverage * test * test * test * test * Auto commit: Calculate translation coverage * test * only on master * test * test * Auto commit: Calculate translation coverage * switch to master branch Co-authored-by: i18n automation <runner@fv-az76.2iswp1o5zimezclxzdlwqia2gf.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az129.idlktykl4ure3gqe2lnji05orb.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az76.pjgcdo5npjpenpqz2nk0ztqvxd.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az33.senarqq4ucbulg04aytwntvgah.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az51.icvemaqob4xunfekbtdiz2tu2c.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az78.gikxu4m3dpiulftj3bftpuu3ee.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az121.cqdewbghluceforu5pkvpnveec.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az139.jsbds1i2htye3fh1bzwbe4ugmf.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az50.0bg2cysi0dkefjvuua0a0kbd1h.cx.internal.cloudapp.net> Co-authored-by: i18n automation <runner@fv-az51.nhi3in4tbx4ehjtltcwuwbwsua.cx.internal.cloudapp.net>
2020-06-30 20:28:19 +02:00
"utf8",
);