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>pull/1850/head
parent
e23f7d37b6
commit
8c3549f336
@ -0,0 +1,36 @@
|
|||||||
|
name: Build locales percentages
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "master"
|
||||||
|
paths:
|
||||||
|
- "src/locales/**.json"
|
||||||
|
- "!src/locales/percentages.json"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
locales:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.PUSH_TRANSLATIONS_COVERAGE_PAT }}
|
||||||
|
|
||||||
|
- name: Setup Node.js 12.x
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 12.x
|
||||||
|
|
||||||
|
- name: Create report file
|
||||||
|
run: |
|
||||||
|
npm run locales-coverage
|
||||||
|
FILE_CHANGED=$(git diff src/locales/percentages.json)
|
||||||
|
if [ ! -z "${FILE_CHANGED}" ]; then
|
||||||
|
git config --global user.name 'Kostas Bariotis'
|
||||||
|
git config --global user.email 'konmpar@gmail.com'
|
||||||
|
git add src/locales/percentages.json
|
||||||
|
git commit -am "Auto commit: Calculate translation coverage"
|
||||||
|
git pull origin master --rebase
|
||||||
|
git push
|
||||||
|
fi
|
@ -0,0 +1 @@
|
|||||||
|
src/locales/percentages.json
|
@ -0,0 +1,32 @@
|
|||||||
|
const { readdirSync, writeFileSync } = require("fs");
|
||||||
|
const files = readdirSync(`${__dirname}/../src/locales`);
|
||||||
|
|
||||||
|
const flatten = (object) =>
|
||||||
|
Object.keys(object).reduce(
|
||||||
|
(initial, current) => ({ ...initial, ...object[current] }),
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
|
||||||
|
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}/../src/locales/${currentLocale}`));
|
||||||
|
|
||||||
|
const allKeys = Object.keys(data);
|
||||||
|
const translatedKeys = allKeys.filter((item) => data[item] !== "");
|
||||||
|
|
||||||
|
const percentage = (100 * translatedKeys.length) / allKeys.length;
|
||||||
|
|
||||||
|
percentages[currentLocale.replace(".json", "")] = parseInt(percentage);
|
||||||
|
}
|
||||||
|
|
||||||
|
writeFileSync(
|
||||||
|
`${__dirname}/../src/locales/percentages.json`,
|
||||||
|
JSON.stringify(percentages),
|
||||||
|
"utf8",
|
||||||
|
);
|
@ -1,5 +1,14 @@
|
|||||||
|
## How to contribute
|
||||||
|
|
||||||
Please do not contribute changes directly to these files, as we manage them with Crowdin. Instead:
|
Please do not contribute changes directly to these files, as we manage them with Crowdin. Instead:
|
||||||
|
|
||||||
- to request a new translation, [open an issue](https://github.com/excalidraw/excalidraw/issues/new/choose).
|
- to request a new translation, [open an issue](https://github.com/excalidraw/excalidraw/issues/new/choose).
|
||||||
- to update existing translations, [edit them on Crowdin](https://crowdin.com/translate/excalidraw/10)
|
- to update existing translations, [edit them on Crowdin](https://crowdin.com/translate/excalidraw/10)
|
||||||
and we should have them included in the app soon!
|
and we should have them included in the app soon!
|
||||||
|
|
||||||
|
## Completion of translation
|
||||||
|
|
||||||
|
[percentages.json](./percentages.json) holds a percentage of completion for each language. We generate these
|
||||||
|
automatically [on build time](./../../.github/workflows/locales-coverage.yml) when a new translation PR appears.
|
||||||
|
|
||||||
|
We only make a language available on the app if it exceeds a certain threshold of completion.
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
{"ar-SA":57,"bg-BG":81,"ca-ES":92,"de-DE":99,"el-GR":98,"en":100,"es-ES":97,"fa-IR":99,"fi-FI":100,"fr-FR":99,"he-IL":94,"hi-IN":99,"hu-HU":58,"id-ID":59,"it-IT":97,"ja-JP":77,"ko-KR":72,"nb-NO":99,"nl-NL":85,"pl-PL":99,"pt-PT":100,"ru-RU":81,"sq-AL":42,"tr-TR":98,"uk-UA":99,"zh-CN":99,"zh-TW":99}
|
Loading…
Reference in New Issue