locales-coverage-description.js 4.8 KB

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