locales-coverage-description.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. "gl-ES": "Galego",
  120. "he-IL": "עברית",
  121. "hi-IN": "हिन्दी",
  122. "hu-HU": "Magyar",
  123. "id-ID": "Bahasa Indonesia",
  124. "it-IT": "Italiano",
  125. "ja-JP": "日本語",
  126. "kab-KAB": "Taqbaylit",
  127. "kk-KZ": "Қазақ тілі",
  128. "ko-KR": "한국어",
  129. "ku-TR": "Kurdî",
  130. "lt-LT": "Lietuvių",
  131. "lv-LV": "Latviešu",
  132. "my-MM": "Burmese",
  133. "nb-NO": "Norsk bokmål",
  134. "nl-NL": "Nederlands",
  135. "nn-NO": "Norsk nynorsk",
  136. "oc-FR": "Occitan",
  137. "pa-IN": "ਪੰਜਾਬੀ",
  138. "pl-PL": "Polski",
  139. "pt-BR": "Português Brasileiro",
  140. "pt-PT": "Português",
  141. "ro-RO": "Română",
  142. "ru-RU": "Русский",
  143. "si-LK": "සිංහල",
  144. "sk-SK": "Slovenčina",
  145. "sl-SI": "Slovenščina",
  146. "sv-SE": "Svenska",
  147. "ta-IN": "Tamil",
  148. "tr-TR": "Türkçe",
  149. "uk-UA": "Українська",
  150. "zh-CN": "简体中文",
  151. "zh-HK": "繁體中文 (香港)",
  152. "zh-TW": "繁體中文",
  153. "vi-VN": "Tiếng Việt",
  154. "mr-IN": "मराठी",
  155. };
  156. const percentages = fs.readFileSync(
  157. `${__dirname}/../src/locales/percentages.json`,
  158. );
  159. const rowData = JSON.parse(percentages);
  160. const coverages = Object.entries(rowData)
  161. .sort(([, a], [, b]) => b - a)
  162. .reduce((r, [k, v]) => ({ ...r, [k]: v }), {});
  163. const boldIf = (text, condition) => (condition ? `**${text}**` : text);
  164. const printHeader = () => {
  165. let result = "| | Flag | Locale | % |\n";
  166. result += "| :--: | :--: | -- | :--: |";
  167. return result;
  168. };
  169. const printRow = (id, locale, coverage) => {
  170. const isOver = coverage >= THRESSHOLD;
  171. let result = `| ${isOver ? id : "..."} | `;
  172. result += `${locale in flags ? flags[locale] : ""} | `;
  173. const language = locale in languages ? languages[locale] : locale;
  174. if (locale in crowdinMap && crowdinMap[locale]) {
  175. result += `[${boldIf(
  176. language,
  177. isOver,
  178. )}](https://crowdin.com/translate/excalidraw/10/${crowdinMap[locale]}) | `;
  179. } else {
  180. result += `${boldIf(language, isOver)} | `;
  181. }
  182. result += `${coverage === 100 ? "💯" : boldIf(coverage, isOver)} |`;
  183. return result;
  184. };
  185. console.info(
  186. `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.`,
  187. );
  188. console.info("\n\r");
  189. console.info(printHeader());
  190. let index = 1;
  191. for (const coverage in coverages) {
  192. if (coverage === "en") {
  193. continue;
  194. }
  195. console.info(printRow(index, coverage, coverages[coverage]));
  196. index++;
  197. }
  198. console.info("\n\r");
  199. console.info("\\* Languages in **bold** are going to appear on production.");