2020-12-19 19:35:03 +01:00
const fs = require ( "fs" ) ;
const THRESSHOLD = 85 ;
const crowdinMap = {
"ar-SA" : "en-ar" ,
"bg-BG" : "en-bg" ,
"ca-ES" : "en-ca" ,
"de-DE" : "en-de" ,
2021-01-07 10:30:22 +01:00
"el-GR" : "en-el" ,
2020-12-19 19:35:03 +01:00
"es-ES" : "en-es" ,
"fa-IR" : "en-fa" ,
2021-01-07 10:30:22 +01:00
"fi-FI" : "en-fi" ,
2020-12-19 19:35:03 +01:00
"fr-FR" : "en-fr" ,
"he-IL" : "en-he" ,
"hi-IN" : "en-hi" ,
"hu-HU" : "en-hu" ,
"id-ID" : "en-id" ,
"it-IT" : "en-it" ,
2021-01-07 10:30:22 +01:00
"ja-JP" : "en-ja" ,
2021-02-02 10:41:57 +01:00
"kab-KAB" : "en-kab" ,
2020-12-19 19:35:03 +01:00
"ko-KR" : "en-ko" ,
"my-MM" : "en-my" ,
"nb-NO" : "en-nb" ,
"nl-NL" : "en-nl" ,
"nn-NO" : "en-nnno" ,
2021-03-02 09:50:49 +01:00
"oc-FR" : "en-oc" ,
2021-01-07 10:30:22 +01:00
"pa-IN" : "en-pain" ,
2020-12-19 19:35:03 +01:00
"pl-PL" : "en-pl" ,
2020-12-25 11:15:34 +01:00
"pt-BR" : "en-ptbr" ,
2020-12-19 19:35:03 +01:00
"pt-PT" : "en-pt" ,
"ro-RO" : "en-ro" ,
"ru-RU" : "en-ru" ,
"sk-SK" : "en-sk" ,
"sv-SE" : "en-sv" ,
"tr-TR" : "en-tr" ,
"uk-UA" : "en-uk" ,
"zh-CN" : "en-zhcn" ,
"zh-TW" : "en-zhtw" ,
2021-05-06 22:13:35 +02:00
"lv-LV" : "en-lv" ,
2021-07-08 13:09:13 +02:00
"cs-CZ" : "en-cs" ,
"kk-KZ" : "en-kk" ,
2020-12-19 19:35:03 +01:00
} ;
const flags = {
"ar-SA" : "🇸🇦" ,
"bg-BG" : "🇧🇬" ,
2021-02-02 23:06:44 +01:00
"ca-ES" : "🏳" ,
2020-12-19 19:35:03 +01:00
"de-DE" : "🇩🇪" ,
"el-GR" : "🇬🇷" ,
"es-ES" : "🇪🇸" ,
"fa-IR" : "🇮🇷" ,
"fi-FI" : "🇫🇮" ,
"fr-FR" : "🇫🇷" ,
"he-IL" : "🇮🇱" ,
"hi-IN" : "🇮🇳" ,
"hu-HU" : "🇭🇺" ,
"id-ID" : "🇮🇩" ,
"it-IT" : "🇮🇹" ,
"ja-JP" : "🇯🇵" ,
2021-02-02 23:06:44 +01:00
"kab-KAB" : "🏳" ,
2020-12-19 19:35:03 +01:00
"ko-KR" : "🇰🇷" ,
"my-MM" : "🇲🇲" ,
"nb-NO" : "🇳🇴" ,
"nl-NL" : "🇳🇱" ,
"nn-NO" : "🇳🇴" ,
2021-03-02 09:50:49 +01:00
"oc-FR" : "🏳" ,
2021-01-07 10:30:22 +01:00
"pa-IN" : "🇮🇳" ,
2020-12-19 19:35:03 +01:00
"pl-PL" : "🇵🇱" ,
2020-12-25 11:15:34 +01:00
"pt-BR" : "🇧🇷" ,
2020-12-19 19:35:03 +01:00
"pt-PT" : "🇵🇹" ,
"ro-RO" : "🇷🇴" ,
"ru-RU" : "🇷🇺" ,
"sk-SK" : "🇸🇰" ,
"sv-SE" : "🇸🇪" ,
"tr-TR" : "🇹🇷" ,
"uk-UA" : "🇺🇦" ,
"zh-CN" : "🇨🇳" ,
"zh-TW" : "🇹🇼" ,
2021-05-06 22:13:35 +02:00
"lv-LV" : "🇱🇻" ,
2021-05-27 20:09:19 +02:00
"cs-CZ" : "🇨🇿" ,
2021-07-08 13:09:13 +02:00
"kk-KZ" : "🇰🇿" ,
2020-12-19 19:35:03 +01:00
} ;
const languages = {
"ar-SA" : "العربية" ,
"bg-BG" : "Български" ,
2021-01-06 00:46:42 +01:00
"ca-ES" : "Català" ,
2020-12-19 19:35:03 +01:00
"de-DE" : "Deutsch" ,
"el-GR" : "Ελληνικά" ,
"es-ES" : "Español" ,
"fa-IR" : "فارسی" ,
"fi-FI" : "Suomi" ,
"fr-FR" : "Français" ,
"he-IL" : "עברית" ,
"hi-IN" : "हिन्दी" ,
"hu-HU" : "Magyar" ,
"id-ID" : "Bahasa Indonesia" ,
"it-IT" : "Italiano" ,
"ja-JP" : "日本語" ,
2021-02-02 10:35:00 +01:00
"kab-KAB" : "Taqbaylit" ,
2020-12-19 19:35:03 +01:00
"ko-KR" : "한국어" ,
"my-MM" : "Burmese" ,
"nb-NO" : "Norsk bokmål" ,
"nl-NL" : "Nederlands" ,
"nn-NO" : "Norsk nynorsk" ,
2021-03-02 09:50:49 +01:00
"oc-FR" : "Occitan" ,
2021-01-07 10:30:22 +01:00
"pa-IN" : "ਪੰਜਾਬੀ" ,
2020-12-19 19:35:03 +01:00
"pl-PL" : "Polski" ,
2020-12-25 11:15:34 +01:00
"pt-BR" : "Português Brasileiro" ,
2020-12-19 19:35:03 +01:00
"pt-PT" : "Português" ,
"ro-RO" : "Română" ,
"ru-RU" : "Русский" ,
"sk-SK" : "Slovenčina" ,
"sv-SE" : "Svenska" ,
"tr-TR" : "Türkçe" ,
"uk-UA" : "Українська" ,
"zh-CN" : "简体中文" ,
"zh-TW" : "繁體中文" ,
2021-05-06 22:13:35 +02:00
"lv-LV" : "Latviešu" ,
2021-05-27 20:09:19 +02:00
"cs-CZ" : "Česky" ,
2021-07-08 13:09:13 +02:00
"kk-KZ" : "Қазақ тілі" ,
2020-12-19 19:35:03 +01:00
} ;
const percentages = fs . readFileSync (
` ${ _ _dirname } /../src/locales/percentages.json ` ,
) ;
const rowData = JSON . parse ( percentages ) ;
const coverages = Object . entries ( rowData )
. sort ( ( [ , a ] , [ , b ] ) => b - a )
. reduce ( ( r , [ k , v ] ) => ( { ... r , [ k ] : v } ) , { } ) ;
2020-12-19 21:44:01 +01:00
const boldIf = ( text , condition ) => ( condition ? ` ** ${ text } ** ` : text ) ;
2020-12-19 19:35:03 +01:00
const printHeader = ( ) => {
let result = "| | Flag | Locale | % |\n" ;
2020-12-25 11:15:34 +01:00
result += "| :--: | :--: | -- | :--: |" ;
2020-12-19 19:35:03 +01:00
return result ;
} ;
const printRow = ( id , locale , coverage ) => {
2020-12-25 11:15:34 +01:00
const isOver = coverage >= THRESSHOLD ;
let result = ` | ${ isOver ? id : "..." } | ` ;
2020-12-19 19:35:03 +01:00
result += ` ${ locale in flags ? flags [ locale ] : "" } | ` ;
const language = locale in languages ? languages [ locale ] : locale ;
if ( locale in crowdinMap && crowdinMap [ locale ] ) {
2020-12-19 21:44:01 +01:00
result += ` [ ${ boldIf (
language ,
isOver ,
) } ] ( https : //crowdin.com/translate/excalidraw/10/${crowdinMap[locale]}) | `;
2020-12-19 19:35:03 +01:00
} else {
2020-12-19 21:44:01 +01:00
result += ` ${ boldIf ( language , isOver ) } | ` ;
2020-12-19 19:35:03 +01:00
}
2021-01-07 10:30:22 +01:00
result += ` ${ coverage === 100 ? "💯" : boldIf ( coverage , isOver ) } | ` ;
2020-12-19 19:35:03 +01:00
return result ;
} ;
console . info (
2020-12-25 11:15:34 +01:00
` Each language must be at least ** ${ THRESSHOLD } %** translated in order to appear on Excalidraw. Join us on [Crowdin](https://crowdin.com/project/excalidraw) and help us translate your own language. **Can't find yours yet?** Open an [issue](https://github.com/excalidraw/excalidraw/issues/new) and we'll add it to the list. ` ,
2020-12-19 19:35:03 +01:00
) ;
2020-12-19 21:44:01 +01:00
console . info ( "\n\r" ) ;
2020-12-19 19:35:03 +01:00
console . info ( printHeader ( ) ) ;
2020-12-19 21:44:01 +01:00
let index = 1 ;
for ( const coverage in coverages ) {
if ( coverage === "en" ) {
continue ;
}
console . info ( printRow ( index , coverage , coverages [ coverage ] ) ) ;
index ++ ;
2020-12-19 19:35:03 +01:00
}
2020-12-19 21:44:01 +01:00
console . info ( "\n\r" ) ;
console . info ( "\\* Languages in **bold** are going to appear on production." ) ;