2020-12-19 19:35:03 +01:00
const fs = require ( "fs" ) ;
const THRESSHOLD = 85 ;
2023-03-11 22:15:52 +01:00
// we're using BCP 47 language tags as keys
// e.g. https://gist.github.com/typpo/b2b828a35e683b9bf8db91b5404f1bd1
2020-12-19 19:35:03 +01:00
const crowdinMap = {
"ar-SA" : "en-ar" ,
"bg-BG" : "en-bg" ,
2021-10-30 18:26:54 +02:00
"bn-BD" : "en-bn" ,
2020-12-19 19:35:03 +01:00
"ca-ES" : "en-ca" ,
2021-10-30 18:26:54 +02:00
"da-DK" : "en-da" ,
2020-12-19 19:35:03 +01:00
"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" ,
2022-01-13 20:06:48 +01:00
"eu-ES" : "en-eu" ,
2020-12-19 19:35:03 +01:00
"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" ,
2022-10-25 12:56:55 +02:00
"gl-ES" : "en-gl" ,
2020-12-19 19:35:03 +01:00
"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" ,
2022-10-25 12:56:55 +02:00
"ku-TR" : "en-ku" ,
2020-12-19 19:35:03 +01:00
"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" ,
2021-10-30 18:26:54 +02:00
"si-LK" : "en-silk" ,
2020-12-19 19:35:03 +01:00
"sk-SK" : "en-sk" ,
2022-07-09 07:58:09 +02:00
"sl-SI" : "en-sl" ,
2020-12-19 19:35:03 +01:00
"sv-SE" : "en-sv" ,
2021-10-30 18:26:54 +02:00
"ta-IN" : "en-ta" ,
2020-12-19 19:35:03 +01:00
"tr-TR" : "en-tr" ,
"uk-UA" : "en-uk" ,
"zh-CN" : "en-zhcn" ,
2021-10-30 18:26:54 +02:00
"zh-HK" : "en-zhhk" ,
2020-12-19 19:35:03 +01:00
"zh-TW" : "en-zhtw" ,
2022-01-13 20:06:48 +01:00
"lt-LT" : "en-lt" ,
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" ,
2022-12-06 13:04:22 +01:00
"vi-VN" : "en-vi" ,
"mr-IN" : "en-mr" ,
2023-03-11 22:15:52 +01:00
"th-TH" : "en-th" ,
2020-12-19 19:35:03 +01:00
} ;
const flags = {
"ar-SA" : "🇸🇦" ,
"bg-BG" : "🇧🇬" ,
2021-10-30 18:26:54 +02:00
"bn-BD" : "🇧🇩" ,
2021-02-02 23:06:44 +01:00
"ca-ES" : "🏳" ,
2021-10-30 18:26:54 +02:00
"cs-CZ" : "🇨🇿" ,
"da-DK" : "🇩🇰" ,
2020-12-19 19:35:03 +01:00
"de-DE" : "🇩🇪" ,
"el-GR" : "🇬🇷" ,
"es-ES" : "🇪🇸" ,
"fa-IR" : "🇮🇷" ,
"fi-FI" : "🇫🇮" ,
"fr-FR" : "🇫🇷" ,
2022-10-25 12:56:55 +02:00
"gl-ES" : "🇪🇸" ,
2020-12-19 19:35:03 +01:00
"he-IL" : "🇮🇱" ,
"hi-IN" : "🇮🇳" ,
"hu-HU" : "🇭🇺" ,
"id-ID" : "🇮🇩" ,
"it-IT" : "🇮🇹" ,
"ja-JP" : "🇯🇵" ,
2021-02-02 23:06:44 +01:00
"kab-KAB" : "🏳" ,
2021-10-30 18:26:54 +02:00
"kk-KZ" : "🇰🇿" ,
2020-12-19 19:35:03 +01:00
"ko-KR" : "🇰🇷" ,
2022-10-25 12:56:55 +02:00
"ku-TR" : "🏳" ,
2022-01-13 20:06:48 +01:00
"lt-LT" : "🇱🇹" ,
2021-10-30 18:26:54 +02:00
"lv-LV" : "🇱🇻" ,
2020-12-19 19:35:03 +01:00
"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" : "🇷🇺" ,
2021-10-30 18:26:54 +02:00
"si-LK" : "🇱🇰" ,
2020-12-19 19:35:03 +01:00
"sk-SK" : "🇸🇰" ,
2022-07-09 07:58:09 +02:00
"sl-SI" : "🇸🇮" ,
2020-12-19 19:35:03 +01:00
"sv-SE" : "🇸🇪" ,
2021-10-30 18:26:54 +02:00
"ta-IN" : "🇮🇳" ,
2020-12-19 19:35:03 +01:00
"tr-TR" : "🇹🇷" ,
"uk-UA" : "🇺🇦" ,
"zh-CN" : "🇨🇳" ,
2021-10-30 18:26:54 +02:00
"zh-HK" : "🇭🇰" ,
2020-12-19 19:35:03 +01:00
"zh-TW" : "🇹🇼" ,
2022-07-21 09:55:30 +02:00
"eu-ES" : "🇪🇦" ,
"vi-VN" : "🇻🇳" ,
"mr-IN" : "🇮🇳" ,
2023-03-11 22:15:52 +01:00
"th-TH" : "🇹🇭" ,
2020-12-19 19:35:03 +01:00
} ;
const languages = {
"ar-SA" : "العربية" ,
"bg-BG" : "Български" ,
2021-10-30 18:26:54 +02:00
"bn-BD" : "Bengali" ,
2021-01-06 00:46:42 +01:00
"ca-ES" : "Català" ,
2021-10-30 18:26:54 +02:00
"cs-CZ" : "Česky" ,
"da-DK" : "Dansk" ,
2020-12-19 19:35:03 +01:00
"de-DE" : "Deutsch" ,
"el-GR" : "Ελληνικά" ,
"es-ES" : "Español" ,
2022-01-13 20:06:48 +01:00
"eu-ES" : "Euskara" ,
2020-12-19 19:35:03 +01:00
"fa-IR" : "فارسی" ,
"fi-FI" : "Suomi" ,
"fr-FR" : "Français" ,
2022-12-06 13:04:22 +01:00
"gl-ES" : "Galego" ,
2020-12-19 19:35:03 +01:00
"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" ,
2021-10-30 18:26:54 +02:00
"kk-KZ" : "Қазақ тілі" ,
2020-12-19 19:35:03 +01:00
"ko-KR" : "한국어" ,
2022-12-06 13:04:22 +01:00
"ku-TR" : "Kurdî" ,
2022-01-13 20:06:48 +01:00
"lt-LT" : "Lietuvių" ,
2021-10-30 18:26:54 +02:00
"lv-LV" : "Latviešu" ,
2020-12-19 19:35:03 +01:00
"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" : "Русский" ,
2021-10-30 18:26:54 +02:00
"si-LK" : "සිංහල" ,
2020-12-19 19:35:03 +01:00
"sk-SK" : "Slovenčina" ,
2022-07-09 07:58:09 +02:00
"sl-SI" : "Slovenščina" ,
2020-12-19 19:35:03 +01:00
"sv-SE" : "Svenska" ,
2021-10-30 18:26:54 +02:00
"ta-IN" : "Tamil" ,
2020-12-19 19:35:03 +01:00
"tr-TR" : "Türkçe" ,
"uk-UA" : "Українська" ,
"zh-CN" : "简体中文" ,
2021-11-04 13:10:21 +01:00
"zh-HK" : "繁體中文 (香港)" ,
2020-12-19 19:35:03 +01:00
"zh-TW" : "繁體中文" ,
2022-07-21 09:55:30 +02:00
"vi-VN" : "Tiếng Việt" ,
"mr-IN" : "मराठी" ,
2023-03-11 22:15:52 +01:00
"th-TH" : "ภาษาไทย" ,
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." ) ;