From: Dessalines Date: Sat, 24 Aug 2019 04:43:12 +0000 (-0700) Subject: Adding a translation report tool. X-Git-Url: http://these/git/%7B%60https:/%7B%60css/themes/%22https:/nerdica.net/%7Bs.link%7D?a=commitdiff_plain;h=0a44ca81b1498b9de9e7ad169cb3fe203184e72b;p=lemmy.git Adding a translation report tool. - Fixes #231 --- diff --git a/README.md b/README.md index 7830991f..7b0ebb4e 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,17 @@ If you'd like to add translations, take a look a look at the [english translatio - Languages supported: English (`en`), Chinese (`zh`), French (`fr`), Spanish (`es`), Swedish (`sv`), German (`de`), Russian (`ru`). +### Report + +lang | missing | percent +--- | --- | --- +es | cross_posts,cross_post,by,to,transfer_community,transfer_site | 96% +de | cross_posts,cross_post,users,settings,subscribed,expires,nsfw,show_nsfw,crypto,monero,joined,by,to,transfer_community,transfer_site | 91% +zh | cross_posts,cross_post,users,settings,nsfw,show_nsfw,monero,by,to,transfer_community,transfer_site | 93% +fr | cross_posts,cross_post,users,settings,nsfw,show_nsfw,monero,by,to,transfer_community,transfer_site | 93% +sv | cross_posts,cross_post,settings,nsfw,show_nsfw,monero,by,to,transfer_community,transfer_site | 94% +ru | cross_posts,cross_post,monero,by,to,transfer_community,transfer_site | 96% + ## Credits Icon made by Andy Cuccaro (@andycuccaro). diff --git a/ui/translation_report.ts b/ui/translation_report.ts new file mode 100644 index 00000000..41d0401e --- /dev/null +++ b/ui/translation_report.ts @@ -0,0 +1,33 @@ +import { en } from './src/translations/en'; +import { es } from './src/translations/es'; +import { de } from './src/translations/de'; +import { zh } from './src/translations/zh'; +import { fr } from './src/translations/fr'; +import { sv } from './src/translations/sv'; +import { ru } from './src/translations/ru'; + +let files = [ + {t: es, n: 'es'}, + {t: de, n: 'de'}, + {t: zh, n: 'zh'}, + {t: fr, n: 'fr'}, + {t: sv, n: 'sv'}, + {t: ru, n: 'ru'}, +]; +let masterKeys = Object.keys(en.translation); + +let report = 'lang | missing | percent\n'; +report += '--- | --- | ---\n'; + +for (let file of files) { + let keys = Object.keys(file.t.translation); + let pct: number = (keys.length / masterKeys.length * 100); + let missing = difference(masterKeys, keys); + report += `${file.n} | ${missing} | ${pct.toFixed(0)}%\n`; +} + +console.log(report); + +function difference(a: Array, b: Array): Array { + return a.filter(x => !b.includes(x)); +}