locales-coverage-description.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. const fs = require("fs");
  2. const THRESSHOLD = 85;
  3. const crowdinMap = {
  4. "ar-SA": "en-ar",
  5. "bg-BG": "en-bg",
  6. "bn-BD": "en-bn",
  7. "ca-ES": "en-ca",
  8. "da-DK": "en-da",
  9. "de-DE": "en-de",
  10. "el-GR": "en-el",
  11. "es-ES": "en-es",
  12. "eu-ES": "en-eu",
  13. "fa-IR": "en-fa",
  14. "fi-FI": "en-fi",
  15. "fr-FR": "en-fr",
  16. "gl-ES": "en-gl",
  17. "he-IL": "en-he",
  18. "hi-IN": "en-hi",
  19. "hu-HU": "en-hu",
  20. "id-ID": "en-id",
  21. "it-IT": "en-it",
  22. "ja-JP": "en-ja",
  23. "kab-KAB": "en-kab",
  24. "ko-KR": "en-ko",
  25. "ku-TR": "en-ku",
  26. "my-MM": "en-my",
  27. "nb-NO": "en-nb",
  28. "nl-NL": "en-nl",
  29. "nn-NO": "en-nnno",
  30. "oc-FR": "en-oc",
  31. "pa-IN": "en-pain",
  32. "pl-PL": "en-pl",
  33. "pt-BR": "en-ptbr",
  34. "pt-PT": "en-pt",
  35. "ro-RO": "en-ro",
  36. "ru-RU": "en-ru",
  37. "si-LK": "en-silk",
  38. "sk-SK": "en-sk",
  39. "sl-SI": "en-sl",
  40. "sv-SE": "en-sv",
  41. "ta-IN": "en-ta",
  42. "tr-TR": "en-tr",
  43. "uk-UA": "en-uk",
  44. "zh-CN": "en-zhcn",
  45. "zh-HK": "en-zhhk",
  46. "zh-TW": "en-zhtw",
  47. "lt-LT": "en-lt",
  48. "lv-LV": "en-lv",
  49. "cs-CZ": "en-cs",
  50. "kk-KZ": "en-kk",
  51. "vi-vn": "en-vi",
  52. "mr-in": "en-mr",
  53. };
  54. const flags = {
  55. "ar-SA": "🇸🇦",
  56. "bg-BG": "🇧🇬",
  57. "bn-BD": "🇧🇩",
  58. "ca-ES": "🏳",
  59. "cs-CZ": "🇨🇿",
  60. "da-DK": "🇩🇰",
  61. "de-DE": "🇩🇪",
  62. "el-GR": "🇬🇷",
  63. "es-ES": "🇪🇸",
  64. "fa-IR": "🇮🇷",
  65. "fi-FI": "🇫🇮",
  66. "fr-FR": "🇫🇷",
  67. "gl-ES": "🇪🇸",
  68. "he-IL": "🇮🇱",
  69. "hi-IN": "🇮🇳",
  70. "hu-HU": "🇭🇺",
  71. "id-ID": "🇮🇩",
  72. "it-IT": "🇮🇹",
  73. "ja-JP": "🇯🇵",
  74. "kab-KAB": "🏳",
  75. "kk-KZ": "🇰🇿",
  76. "ko-KR": "🇰🇷",
  77. "ku-TR": "🏳",
  78. "lt-LT": "🇱🇹",
  79. "lv-LV": "🇱🇻",
  80. "my-MM": "🇲🇲",
  81. "nb-NO": "🇳🇴",
  82. "nl-NL": "🇳🇱",
  83. "nn-NO": "🇳🇴",
  84. "oc-FR": "🏳",
  85. "pa-IN": "🇮🇳",
  86. "pl-PL": "🇵🇱",
  87. "pt-BR": "🇧🇷",
  88. "pt-PT": "🇵🇹",
  89. "ro-RO": "🇷🇴",
  90. "ru-RU": "🇷🇺",
  91. "si-LK": "🇱🇰",
  92. "sk-SK": "🇸🇰",
  93. "sl-SI": "🇸🇮",
  94. "sv-SE": "🇸🇪",
  95. "ta-IN": "🇮🇳",
  96. "tr-TR": "🇹🇷",
  97. "uk-UA": "🇺🇦",
  98. "zh-CN": "🇨🇳",
  99. "zh-HK": "🇭🇰",
  100. "zh-TW": "🇹🇼",
  101. "eu-ES": "🇪🇦",
  102. "vi-VN": "🇻🇳",
  103. "mr-IN": "🇮🇳",
  104. };
  105. const languages = {
  106. "ar-SA": "العربية",
  107. "bg-BG": "Български",
  108. "bn-BD": "Bengali",
  109. "ca-ES": "Català",
  110. "cs-CZ": "Česky",
  111. "da-DK": "Dansk",
  112. "de-DE": "Deutsch",
  113. "el-GR": "Ελληνικά",
  114. "es-ES": "Español",
  115. "eu-ES": "Euskara",
  116. "fa-IR": "فارسی",
  117. "fi-FI": "Suomi",
  118. "fr-FR": "Français",
  119. "he-IL": "עברית",
  120. "hi-IN": "हिन्दी",
  121. "hu-HU": "Magyar",
  122. "id-ID": "Bahasa Indonesia",
  123. "it-IT": "Italiano",
  124. "ja-JP": "日本語",
  125. "kab-KAB": "Taqbaylit",
  126. "kk-KZ": "Қазақ тілі",
  127. "ko-KR": "한국어",
  128. "lt-LT": "Lietuvių",
  129. "lv-LV": "Latviešu",
  130. "my-MM": "Burmese",
  131. "nb-NO": "Norsk bokmål",
  132. "nl-NL": "Nederlands",
  133. "nn-NO": "Norsk nynorsk",
  134. "oc-FR": "Occitan",
  135. "pa-IN": "ਪੰਜਾਬੀ",
  136. "pl-PL": "Polski",
  137. "pt-BR": "Português Brasileiro",
  138. "pt-PT": "Português",
  139. "ro-RO": "Română",
  140. "ru-RU": "Русский",
  141. "si-LK": "සිංහල",
  142. "sk-SK": "Slovenčina",
  143. "sl-SI": "Slovenščina",
  144. "sv-SE": "Svenska",
  145. "ta-IN": "Tamil",
  146. "tr-TR": "Türkçe",
  147. "uk-UA": "Українська",
  148. "zh-CN": "简体中文",
  149. "zh-HK": "繁體中文 (香港)",
  150. "zh-TW": "繁體中文",
  151. "vi-VN": "Tiếng Việt",
  152. "mr-IN": "मराठी",
  153. };
  154. const percentages = fs.readFileSync(
  155. `${__dirname}/../src/locales/percentages.json`,
  156. );
  157. const rowData = JSON.parse(percentages);
  158. const coverages = Object.entries(rowData)
  159. .sort(([, a], [, b]) => b - a)
  160. .reduce((r, [k, v]) => ({ ...r, [k]: v }), {});
  161. const boldIf = (text, condition) => (condition ? `**${text}**` : text);
  162. const printHeader = () => {
  163. let result = "| | Flag | Locale | % |\n";
  164. result += "| :--: | :--: | -- | :--: |";
  165. return result;
  166. };
  167. const printRow = (id, locale, coverage) => {
  168. const isOver = coverage >= THRESSHOLD;
  169. let result = `| ${isOver ? id : "..."} | `;
  170. result += `${locale in flags ? flags[locale] : ""} | `;
  171. const language = locale in languages ? languages[locale] : locale;
  172. if (locale in crowdinMap && crowdinMap[locale]) {
  173. result += `[${boldIf(
  174. language,
  175. isOver,
  176. )}](https://crowdin.com/translate/excalidraw/10/${crowdinMap[locale]}) | `;
  177. } else {
  178. result += `${boldIf(language, isOver)} | `;
  179. }
  180. result += `${coverage === 100 ? "💯" : boldIf(coverage, isOver)} |`;
  181. return result;
  182. };
  183. console.info(
  184. `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.`,
  185. );
  186. console.info("\n\r");
  187. console.info(printHeader());
  188. let index = 1;
  189. for (const coverage in coverages) {
  190. if (coverage === "en") {
  191. continue;
  192. }
  193. console.info(printRow(index, coverage, coverages[coverage]));
  194. index++;
  195. }
  196. console.info("\n\r");
  197. console.info("\\* Languages in **bold** are going to appear on production.");