@esgettext/runtime 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +23 -25
  3. package/{lib-esm → dist}/core/browser-environment.d.ts +1 -0
  4. package/dist/core/browser-environment.d.ts.map +1 -0
  5. package/dist/core/catalog-cache.d.ts +22 -0
  6. package/dist/core/catalog-cache.d.ts.map +1 -0
  7. package/dist/core/catalog-cache.spec.d.ts +2 -0
  8. package/dist/core/catalog-cache.spec.d.ts.map +1 -0
  9. package/dist/core/catalog-format.spec.d.ts +2 -0
  10. package/dist/core/catalog-format.spec.d.ts.map +1 -0
  11. package/dist/core/catalog.d.ts +48 -0
  12. package/dist/core/catalog.d.ts.map +1 -0
  13. package/{lib → dist}/core/data-viewlet.d.ts +11 -0
  14. package/dist/core/data-viewlet.d.ts.map +1 -0
  15. package/dist/core/data-viewlet.spec.d.ts +2 -0
  16. package/dist/core/data-viewlet.spec.d.ts.map +1 -0
  17. package/{lib-esm → dist}/core/explode-locale.d.ts +1 -0
  18. package/dist/core/explode-locale.d.ts.map +1 -0
  19. package/dist/core/explode-locale.spec.d.ts +2 -0
  20. package/dist/core/explode-locale.spec.d.ts.map +1 -0
  21. package/{lib-esm → dist}/core/germanic-plural.d.ts +1 -0
  22. package/dist/core/germanic-plural.d.ts.map +1 -0
  23. package/{lib → dist}/core/gettext-impl.d.ts +1 -0
  24. package/dist/core/gettext-impl.d.ts.map +1 -0
  25. package/dist/core/gettext.spec.d.ts +2 -0
  26. package/dist/core/gettext.spec.d.ts.map +1 -0
  27. package/{lib-esm → dist}/core/index.d.ts +1 -0
  28. package/dist/core/index.d.ts.map +1 -0
  29. package/dist/core/locale-container.d.ts +32 -0
  30. package/dist/core/locale-container.d.ts.map +1 -0
  31. package/dist/core/platform.d.ts +3 -0
  32. package/dist/core/platform.d.ts.map +1 -0
  33. package/{lib → dist}/core/resolve-impl.d.ts +1 -0
  34. package/dist/core/resolve-impl.d.ts.map +1 -0
  35. package/dist/core/resolve.spec.d.ts +2 -0
  36. package/dist/core/resolve.spec.d.ts.map +1 -0
  37. package/{lib-esm → dist}/core/select-locale.d.ts +1 -0
  38. package/dist/core/select-locale.d.ts.map +1 -0
  39. package/dist/core/select-locale.spec.d.ts +2 -0
  40. package/dist/core/select-locale.spec.d.ts.map +1 -0
  41. package/dist/core/set-locale-browser.spec.d.ts +2 -0
  42. package/dist/core/set-locale-browser.spec.d.ts.map +1 -0
  43. package/dist/core/set-locale-node.spec.d.ts +2 -0
  44. package/dist/core/set-locale-node.spec.d.ts.map +1 -0
  45. package/{lib-esm → dist}/core/split-locale.d.ts +1 -0
  46. package/dist/core/split-locale.d.ts.map +1 -0
  47. package/dist/core/split-locale.spec.d.ts +2 -0
  48. package/dist/core/split-locale.spec.d.ts.map +1 -0
  49. package/dist/core/textdomain.d.ts +464 -0
  50. package/dist/core/textdomain.d.ts.map +1 -0
  51. package/dist/core/textdomain.spec.d.ts +2 -0
  52. package/dist/core/textdomain.spec.d.ts.map +1 -0
  53. package/{lib-esm → dist}/core/user-locales.d.ts +1 -0
  54. package/dist/core/user-locales.d.ts.map +1 -0
  55. package/dist/esgettext.cjs.js +1411 -0
  56. package/dist/esgettext.cjs.js.map +1 -0
  57. package/dist/esgettext.esm.js +1406 -0
  58. package/dist/esgettext.esm.js.map +1 -0
  59. package/dist/esgettext.js +1415 -0
  60. package/dist/esgettext.js.map +1 -0
  61. package/dist/esgettext.min.js +2 -0
  62. package/dist/esgettext.min.js.map +1 -0
  63. package/dist/index-browser.d.ts +3 -0
  64. package/dist/index-browser.d.ts.map +1 -0
  65. package/dist/index.d.ts +3 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/parser/index.d.ts +4 -0
  68. package/dist/parser/index.d.ts.map +1 -0
  69. package/{lib-esm → dist}/parser/parse-json-catalog.d.ts +1 -0
  70. package/dist/parser/parse-json-catalog.d.ts.map +1 -0
  71. package/{lib-esm → dist}/parser/parse-mo-catalog.d.ts +1 -0
  72. package/dist/parser/parse-mo-catalog.d.ts.map +1 -0
  73. package/dist/parser/parse-mo-catalog.spec.d.ts +2 -0
  74. package/dist/parser/parse-mo-catalog.spec.d.ts.map +1 -0
  75. package/dist/parser/parse-mo-json-catalog.d.ts +4 -0
  76. package/dist/parser/parse-mo-json-catalog.d.ts.map +1 -0
  77. package/dist/parser/parse-mo-json-catalog.spec.d.ts +2 -0
  78. package/dist/parser/parse-mo-json-catalog.spec.d.ts.map +1 -0
  79. package/{lib/transport/fs.d.ts → dist/transport/fs-browser.d.ts} +2 -1
  80. package/dist/transport/fs-browser.d.ts.map +1 -0
  81. package/{lib-esm → dist}/transport/fs.d.ts +1 -0
  82. package/dist/transport/fs.d.ts.map +1 -0
  83. package/{lib-esm → dist}/transport/http.d.ts +1 -0
  84. package/dist/transport/http.d.ts.map +1 -0
  85. package/dist/transport/http.spec.d.ts +2 -0
  86. package/dist/transport/http.spec.d.ts.map +1 -0
  87. package/{lib → dist}/transport/index.d.ts +2 -1
  88. package/dist/transport/index.d.ts.map +1 -0
  89. package/{lib → dist}/transport/transport.interface.d.ts +1 -0
  90. package/dist/transport/transport.interface.d.ts.map +1 -0
  91. package/package.json +30 -14
  92. package/_bundles/runtime.js +0 -1356
  93. package/_bundles/runtime.js.map +0 -1
  94. package/_bundles/runtime.min.js +0 -2
  95. package/_bundles/runtime.min.js.map +0 -1
  96. package/api-docs/assets/highlight.css +0 -127
  97. package/api-docs/assets/main.js +0 -59
  98. package/api-docs/assets/navigation.js +0 -1
  99. package/api-docs/assets/search.js +0 -1
  100. package/api-docs/assets/style.css +0 -1414
  101. package/api-docs/classes/Textdomain.html +0 -364
  102. package/api-docs/index.html +0 -222
  103. package/api-docs/interfaces/Catalog.html +0 -20
  104. package/api-docs/interfaces/CatalogEntries.html +0 -11
  105. package/api-docs/interfaces/LocaleContainer.html +0 -19
  106. package/api-docs/interfaces/Placeholders.html +0 -9
  107. package/api-docs/modules.html +0 -6
  108. package/lib/core/browser-environment.d.ts +0 -1
  109. package/lib/core/browser-environment.js +0 -12
  110. package/lib/core/browser-environment.js.map +0 -1
  111. package/lib/core/catalog-cache.d.ts +0 -10
  112. package/lib/core/catalog-cache.js +0 -39
  113. package/lib/core/catalog-cache.js.map +0 -1
  114. package/lib/core/catalog-cache.spec.d.ts +0 -1
  115. package/lib/core/catalog-cache.spec.js +0 -24
  116. package/lib/core/catalog-cache.spec.js.map +0 -1
  117. package/lib/core/catalog-format.spec.d.ts +0 -1
  118. package/lib/core/catalog-format.spec.js +0 -35
  119. package/lib/core/catalog-format.spec.js.map +0 -1
  120. package/lib/core/catalog.d.ts +0 -9
  121. package/lib/core/catalog.js +0 -3
  122. package/lib/core/catalog.js.map +0 -1
  123. package/lib/core/data-viewlet.js +0 -57
  124. package/lib/core/data-viewlet.js.map +0 -1
  125. package/lib/core/data-viewlet.spec.d.ts +0 -1
  126. package/lib/core/data-viewlet.spec.js +0 -62
  127. package/lib/core/data-viewlet.spec.js.map +0 -1
  128. package/lib/core/explode-locale.d.ts +0 -3
  129. package/lib/core/explode-locale.js +0 -37
  130. package/lib/core/explode-locale.js.map +0 -1
  131. package/lib/core/explode-locale.spec.d.ts +0 -1
  132. package/lib/core/explode-locale.spec.js +0 -41
  133. package/lib/core/explode-locale.spec.js.map +0 -1
  134. package/lib/core/germanic-plural.d.ts +0 -1
  135. package/lib/core/germanic-plural.js +0 -8
  136. package/lib/core/germanic-plural.js.map +0 -1
  137. package/lib/core/gettext-impl.js +0 -38
  138. package/lib/core/gettext-impl.js.map +0 -1
  139. package/lib/core/gettext.spec.d.ts +0 -1
  140. package/lib/core/gettext.spec.js +0 -391
  141. package/lib/core/gettext.spec.js.map +0 -1
  142. package/lib/core/index.d.ts +0 -4
  143. package/lib/core/index.js +0 -21
  144. package/lib/core/index.js.map +0 -1
  145. package/lib/core/locale-container.d.ts +0 -8
  146. package/lib/core/locale-container.js +0 -3
  147. package/lib/core/locale-container.js.map +0 -1
  148. package/lib/core/path-separator.d.ts +0 -1
  149. package/lib/core/path-separator.js +0 -12
  150. package/lib/core/path-separator.js.map +0 -1
  151. package/lib/core/resolve-impl.js +0 -253
  152. package/lib/core/resolve-impl.js.map +0 -1
  153. package/lib/core/resolve.spec.d.ts +0 -1
  154. package/lib/core/resolve.spec.js +0 -345
  155. package/lib/core/resolve.spec.js.map +0 -1
  156. package/lib/core/select-locale.d.ts +0 -1
  157. package/lib/core/select-locale.js +0 -43
  158. package/lib/core/select-locale.js.map +0 -1
  159. package/lib/core/select-locale.spec.d.ts +0 -1
  160. package/lib/core/select-locale.spec.js +0 -27
  161. package/lib/core/select-locale.spec.js.map +0 -1
  162. package/lib/core/set-locale-browser.spec.d.ts +0 -1
  163. package/lib/core/set-locale-browser.spec.js +0 -17
  164. package/lib/core/set-locale-browser.spec.js.map +0 -1
  165. package/lib/core/set-locale-node.spec.d.ts +0 -1
  166. package/lib/core/set-locale-node.spec.js +0 -26
  167. package/lib/core/set-locale-node.spec.js.map +0 -1
  168. package/lib/core/split-locale.d.ts +0 -7
  169. package/lib/core/split-locale.js +0 -39
  170. package/lib/core/split-locale.js.map +0 -1
  171. package/lib/core/split-locale.spec.d.ts +0 -1
  172. package/lib/core/split-locale.spec.js +0 -59
  173. package/lib/core/split-locale.spec.js.map +0 -1
  174. package/lib/core/textdomain.d.ts +0 -55
  175. package/lib/core/textdomain.js +0 -277
  176. package/lib/core/textdomain.js.map +0 -1
  177. package/lib/core/textdomain.spec.d.ts +0 -1
  178. package/lib/core/textdomain.spec.js +0 -33
  179. package/lib/core/textdomain.spec.js.map +0 -1
  180. package/lib/core/user-locales.d.ts +0 -1
  181. package/lib/core/user-locales.js +0 -12
  182. package/lib/core/user-locales.js.map +0 -1
  183. package/lib/index-browser.d.ts +0 -2
  184. package/lib/index-browser.js +0 -44
  185. package/lib/index-browser.js.map +0 -1
  186. package/lib/index.d.ts +0 -2
  187. package/lib/index.js +0 -37
  188. package/lib/index.js.map +0 -1
  189. package/lib/parser/index.d.ts +0 -2
  190. package/lib/parser/index.js +0 -19
  191. package/lib/parser/index.js.map +0 -1
  192. package/lib/parser/parse-json-catalog.d.ts +0 -3
  193. package/lib/parser/parse-json-catalog.js +0 -37
  194. package/lib/parser/parse-json-catalog.js.map +0 -1
  195. package/lib/parser/parse-json-catalog.spec.d.ts +0 -1
  196. package/lib/parser/parse-json-catalog.spec.js +0 -41
  197. package/lib/parser/parse-json-catalog.spec.js.map +0 -1
  198. package/lib/parser/parse-mo-catalog.d.ts +0 -2
  199. package/lib/parser/parse-mo-catalog.js +0 -86
  200. package/lib/parser/parse-mo-catalog.js.map +0 -1
  201. package/lib/parser/parse-mo-catalog.spec.d.ts +0 -1
  202. package/lib/parser/parse-mo-catalog.spec.js +0 -115
  203. package/lib/parser/parse-mo-catalog.spec.js.map +0 -1
  204. package/lib/transport/fs.js +0 -18
  205. package/lib/transport/fs.js.map +0 -1
  206. package/lib/transport/http.d.ts +0 -4
  207. package/lib/transport/http.js +0 -27
  208. package/lib/transport/http.js.map +0 -1
  209. package/lib/transport/http.spec.d.ts +0 -1
  210. package/lib/transport/http.spec.js +0 -119
  211. package/lib/transport/http.spec.js.map +0 -1
  212. package/lib/transport/index.js +0 -20
  213. package/lib/transport/index.js.map +0 -1
  214. package/lib/transport/transport.interface.js +0 -3
  215. package/lib/transport/transport.interface.js.map +0 -1
  216. package/lib-esm/core/browser-environment.js +0 -8
  217. package/lib-esm/core/browser-environment.js.map +0 -1
  218. package/lib-esm/core/catalog-cache.d.ts +0 -10
  219. package/lib-esm/core/catalog-cache.js +0 -36
  220. package/lib-esm/core/catalog-cache.js.map +0 -1
  221. package/lib-esm/core/catalog-cache.spec.d.ts +0 -1
  222. package/lib-esm/core/catalog-cache.spec.js +0 -22
  223. package/lib-esm/core/catalog-cache.spec.js.map +0 -1
  224. package/lib-esm/core/catalog-format.spec.d.ts +0 -1
  225. package/lib-esm/core/catalog-format.spec.js +0 -33
  226. package/lib-esm/core/catalog-format.spec.js.map +0 -1
  227. package/lib-esm/core/catalog.d.ts +0 -9
  228. package/lib-esm/core/catalog.js +0 -2
  229. package/lib-esm/core/catalog.js.map +0 -1
  230. package/lib-esm/core/data-viewlet.d.ts +0 -11
  231. package/lib-esm/core/data-viewlet.js +0 -54
  232. package/lib-esm/core/data-viewlet.js.map +0 -1
  233. package/lib-esm/core/data-viewlet.spec.d.ts +0 -1
  234. package/lib-esm/core/data-viewlet.spec.js +0 -60
  235. package/lib-esm/core/data-viewlet.spec.js.map +0 -1
  236. package/lib-esm/core/explode-locale.js +0 -33
  237. package/lib-esm/core/explode-locale.js.map +0 -1
  238. package/lib-esm/core/explode-locale.spec.d.ts +0 -1
  239. package/lib-esm/core/explode-locale.spec.js +0 -39
  240. package/lib-esm/core/explode-locale.spec.js.map +0 -1
  241. package/lib-esm/core/germanic-plural.js +0 -4
  242. package/lib-esm/core/germanic-plural.js.map +0 -1
  243. package/lib-esm/core/gettext-impl.d.ts +0 -10
  244. package/lib-esm/core/gettext-impl.js +0 -34
  245. package/lib-esm/core/gettext-impl.js.map +0 -1
  246. package/lib-esm/core/gettext.spec.d.ts +0 -1
  247. package/lib-esm/core/gettext.spec.js +0 -389
  248. package/lib-esm/core/gettext.spec.js.map +0 -1
  249. package/lib-esm/core/index.js +0 -5
  250. package/lib-esm/core/index.js.map +0 -1
  251. package/lib-esm/core/locale-container.d.ts +0 -8
  252. package/lib-esm/core/locale-container.js +0 -2
  253. package/lib-esm/core/locale-container.js.map +0 -1
  254. package/lib-esm/core/path-separator.d.ts +0 -1
  255. package/lib-esm/core/path-separator.js +0 -8
  256. package/lib-esm/core/path-separator.js.map +0 -1
  257. package/lib-esm/core/resolve-impl.d.ts +0 -3
  258. package/lib-esm/core/resolve-impl.js +0 -249
  259. package/lib-esm/core/resolve-impl.js.map +0 -1
  260. package/lib-esm/core/resolve.spec.d.ts +0 -1
  261. package/lib-esm/core/resolve.spec.js +0 -340
  262. package/lib-esm/core/resolve.spec.js.map +0 -1
  263. package/lib-esm/core/select-locale.js +0 -39
  264. package/lib-esm/core/select-locale.js.map +0 -1
  265. package/lib-esm/core/select-locale.spec.d.ts +0 -1
  266. package/lib-esm/core/select-locale.spec.js +0 -25
  267. package/lib-esm/core/select-locale.spec.js.map +0 -1
  268. package/lib-esm/core/set-locale-browser.spec.d.ts +0 -1
  269. package/lib-esm/core/set-locale-browser.spec.js +0 -15
  270. package/lib-esm/core/set-locale-browser.spec.js.map +0 -1
  271. package/lib-esm/core/set-locale-node.spec.d.ts +0 -1
  272. package/lib-esm/core/set-locale-node.spec.js +0 -24
  273. package/lib-esm/core/set-locale-node.spec.js.map +0 -1
  274. package/lib-esm/core/split-locale.js +0 -35
  275. package/lib-esm/core/split-locale.js.map +0 -1
  276. package/lib-esm/core/split-locale.spec.d.ts +0 -1
  277. package/lib-esm/core/split-locale.spec.js +0 -57
  278. package/lib-esm/core/split-locale.spec.js.map +0 -1
  279. package/lib-esm/core/textdomain.d.ts +0 -55
  280. package/lib-esm/core/textdomain.js +0 -274
  281. package/lib-esm/core/textdomain.js.map +0 -1
  282. package/lib-esm/core/textdomain.spec.d.ts +0 -1
  283. package/lib-esm/core/textdomain.spec.js +0 -31
  284. package/lib-esm/core/textdomain.spec.js.map +0 -1
  285. package/lib-esm/core/user-locales.js +0 -8
  286. package/lib-esm/core/user-locales.js.map +0 -1
  287. package/lib-esm/index-browser.d.ts +0 -2
  288. package/lib-esm/index-browser.js +0 -26
  289. package/lib-esm/index-browser.js.map +0 -1
  290. package/lib-esm/index.d.ts +0 -2
  291. package/lib-esm/index.js +0 -19
  292. package/lib-esm/index.js.map +0 -1
  293. package/lib-esm/parser/index.d.ts +0 -2
  294. package/lib-esm/parser/index.js +0 -3
  295. package/lib-esm/parser/index.js.map +0 -1
  296. package/lib-esm/parser/parse-json-catalog.js +0 -32
  297. package/lib-esm/parser/parse-json-catalog.js.map +0 -1
  298. package/lib-esm/parser/parse-json-catalog.spec.d.ts +0 -1
  299. package/lib-esm/parser/parse-json-catalog.spec.js +0 -39
  300. package/lib-esm/parser/parse-json-catalog.spec.js.map +0 -1
  301. package/lib-esm/parser/parse-mo-catalog.js +0 -82
  302. package/lib-esm/parser/parse-mo-catalog.js.map +0 -1
  303. package/lib-esm/parser/parse-mo-catalog.spec.d.ts +0 -1
  304. package/lib-esm/parser/parse-mo-catalog.spec.js +0 -113
  305. package/lib-esm/parser/parse-mo-catalog.spec.js.map +0 -1
  306. package/lib-esm/transport/fs.js +0 -15
  307. package/lib-esm/transport/fs.js.map +0 -1
  308. package/lib-esm/transport/http.js +0 -24
  309. package/lib-esm/transport/http.js.map +0 -1
  310. package/lib-esm/transport/http.spec.d.ts +0 -1
  311. package/lib-esm/transport/http.spec.js +0 -114
  312. package/lib-esm/transport/http.spec.js.map +0 -1
  313. package/lib-esm/transport/index.d.ts +0 -3
  314. package/lib-esm/transport/index.js +0 -4
  315. package/lib-esm/transport/index.js.map +0 -1
  316. package/lib-esm/transport/transport.interface.d.ts +0 -3
  317. package/lib-esm/transport/transport.interface.js +0 -2
  318. package/lib-esm/transport/transport.interface.js.map +0 -1
  319. package/webpack.common.js +0 -38
  320. package/webpack.dev.js +0 -9
  321. package/webpack.prod.js +0 -8
@@ -0,0 +1,1411 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs');
4
+
5
+ let userLocalesSelected = ['C'];
6
+ /*
7
+ * Force an execution environment. By default, the environment (NodeJS or
8
+ * browser) is auto-detected. You can force the library to assume a certain
9
+ * environment with this function.
10
+ *
11
+ * @param browser - whether to assume a browser or not
12
+ * @returns the new setting.
13
+ */
14
+ function userLocales(locales) {
15
+ if (typeof locales !== 'undefined') {
16
+ userLocalesSelected = locales;
17
+ }
18
+ return userLocalesSelected;
19
+ }
20
+
21
+ /******************************************************************************
22
+ Copyright (c) Microsoft Corporation.
23
+
24
+ Permission to use, copy, modify, and/or distribute this software for any
25
+ purpose with or without fee is hereby granted.
26
+
27
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
28
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
29
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
30
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
31
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
32
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
33
+ PERFORMANCE OF THIS SOFTWARE.
34
+ ***************************************************************************** */
35
+ /* global Reflect, Promise, SuppressedError, Symbol */
36
+
37
+
38
+ function __awaiter(thisArg, _arguments, P, generator) {
39
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
40
+ return new (P || (P = Promise))(function (resolve, reject) {
41
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
42
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
43
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
44
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
45
+ });
46
+ }
47
+
48
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
49
+ var e = new Error(message);
50
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
51
+ };
52
+
53
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
54
+ class TransportHttp {
55
+ loadFile(url) {
56
+ return new Promise((resolve, reject) => {
57
+ const xhr = new XMLHttpRequest();
58
+ xhr.responseType = 'arraybuffer';
59
+ xhr.open('GET', url, true);
60
+ xhr.onload = () => {
61
+ if (xhr.readyState === 4 && xhr.status === 200) {
62
+ resolve(xhr.response);
63
+ }
64
+ else {
65
+ reject(new Error('get failed with status ' + xhr.status));
66
+ }
67
+ };
68
+ xhr.onerror = err => reject(err);
69
+ xhr.send();
70
+ });
71
+ }
72
+ }
73
+
74
+ class TransportFs {
75
+ loadFile(url) {
76
+ return new Promise((resolve, reject) => {
77
+ fs.readFile(url, (err, data) => {
78
+ return err ? reject(err) : resolve(data);
79
+ });
80
+ });
81
+ }
82
+ }
83
+
84
+ /*
85
+ * Function for germanic plural. Returns singular (0) for 1 item, and
86
+ * 1 for everything else.
87
+ *
88
+ * @param numItems - number of items
89
+ * @returns the index into the plural translations
90
+ */
91
+ function germanicPlural(numItems) {
92
+ return numItems === 1 ? 0 : 1;
93
+ }
94
+
95
+ /*
96
+ * A minimalistic buffer implementation that can only read 32 bit unsigned
97
+ * integers and strings.
98
+ */
99
+ class DataViewlet {
100
+ /*
101
+ * Create a DataViewlet instance. All encodings that are supported by
102
+ * the runtime environments `TextDecoder` interface.
103
+ *
104
+ * @param array - a `Unit8Array` view on the binary buffer
105
+ * @param encoding - encoding of strings, defaults to utf-8
106
+ */
107
+ constructor(array, encoding = 'utf-8') {
108
+ this.array = array;
109
+ this.decoder = new TextDecoder(encoding);
110
+ this._encoding = encoding;
111
+ }
112
+ /**
113
+ * Get the encoding for strings.
114
+ *
115
+ * @returns the encoding in use
116
+ */
117
+ get encoding() {
118
+ return this._encoding;
119
+ }
120
+ /**
121
+ * Switch to a new encoding.
122
+ *
123
+ * @param encoding - new encoding to use
124
+ */
125
+ set encoding(encoding) {
126
+ this.decoder = new TextDecoder(encoding);
127
+ this._encoding = encoding;
128
+ }
129
+ /*
130
+ * Reads an unsigned 32-bit integer from the buffer at
131
+ * the specified offset as big-endian.
132
+ *
133
+ * @param offset - Number of bytes to skip before starting to read.
134
+ * Must satisfy `0 <= offset <= buf.length - 4`.
135
+ * Default: 0.
136
+ * @returns the 32-bit unsigned integer at position `offset`.s
137
+ */
138
+ readUInt32BE(offset = 0) {
139
+ if (offset + 4 > this.array.byteLength + this.array.byteOffset) {
140
+ throw new Error('read past array end');
141
+ }
142
+ return ((((this.array[offset] << 24) >>> 0) |
143
+ (this.array[offset + 1] << 16) |
144
+ (this.array[offset + 2] << 8) |
145
+ this.array[offset + 3]) >>>
146
+ 0);
147
+ }
148
+ /*
149
+ * Reads an unsigned 32-bit integer from the buffer at
150
+ * the specified offset as little-endian.
151
+ *
152
+ * @param offset - Number of bytes to skip before starting to read.
153
+ * Must satisfy `0 <= offset <= buf.length - 4`.
154
+ * Default: 0.
155
+ * @returns the 32-bit unsigned integer at position `offset`.s
156
+ */
157
+ readUInt32LE(offset = 0) {
158
+ if (offset + 4 > this.array.byteLength + this.array.byteOffset) {
159
+ throw new Error('read past array end');
160
+ }
161
+ return ((((this.array[offset + 3] << 24) >>> 0) |
162
+ (this.array[offset + 2] << 16) |
163
+ (this.array[offset + 1] << 8) |
164
+ this.array[offset]) >>>
165
+ 0);
166
+ }
167
+ /*
168
+ * Read a string at a specified offset.
169
+ *
170
+ * @param offset - to beginning of buffer in bytes
171
+ * @param length - of the string to read in bytes or to the end of the
172
+ * buffer if not specified.
173
+ */
174
+ readString(offset = 0, length) {
175
+ if (offset + length >
176
+ this.array.byteLength + this.array.byteOffset) {
177
+ throw new Error('read past array end');
178
+ }
179
+ if (typeof length === 'undefined') {
180
+ length = this.array.byteLength - offset;
181
+ }
182
+ return this.decoder.decode(this.array.slice(offset, offset + length));
183
+ }
184
+ }
185
+
186
+ /*
187
+ * Parse an MO file.
188
+ *
189
+ * An exception is thrown for invalid data.
190
+ *
191
+ * @param raw - The input as either a binary `String`, any `Array`-like byte
192
+ * storage (`Array`, `Uint8Array`, `Arguments`, `jQuery(Array)`, ...)
193
+ * @returns a Catalog
194
+ */
195
+ function parseMoCatalog(raw) {
196
+ const catalog = {
197
+ major: 0,
198
+ minor: 0,
199
+ entries: {},
200
+ pluralFunction: germanicPlural,
201
+ };
202
+ let offset = 0;
203
+ const blob = new DataViewlet(new Uint8Array(raw), 'ascii');
204
+ const magic = blob.readUInt32LE(offset);
205
+ let reader;
206
+ if (magic === 0x950412de) {
207
+ /* eslint-disable-next-line @typescript-eslint/explicit-function-return-type */
208
+ reader = (buf, off) => buf.readUInt32LE(off);
209
+ }
210
+ else if (magic === 0xde120495) {
211
+ /* eslint-disable-next-line @typescript-eslint/explicit-function-return-type */
212
+ reader = (buf, off) => buf.readUInt32BE(off);
213
+ }
214
+ else {
215
+ throw new Error(`invalid MO magic 0x${magic.toString(16)}`);
216
+ }
217
+ offset += 4;
218
+ // The revision is encoded in two shorts, major and minor. We don't care
219
+ // about the minor revision.
220
+ const major = reader(blob, offset) >> 16;
221
+ offset += 4;
222
+ if (major > 0) {
223
+ throw new Error(`unsupported major revision ${major}`);
224
+ }
225
+ const numStrings = reader(blob, offset);
226
+ offset += 4;
227
+ const msgidOffset = reader(blob, offset);
228
+ offset += 4;
229
+ const msgstrOffset = reader(blob, offset);
230
+ offset = msgidOffset;
231
+ const origTab = [];
232
+ for (let i = 0; i < numStrings; ++i) {
233
+ const l = reader(blob, offset);
234
+ offset += 4;
235
+ const stringOffset = reader(blob, offset);
236
+ offset += 4;
237
+ origTab.push([l, stringOffset]);
238
+ }
239
+ offset = msgstrOffset;
240
+ const transTab = [];
241
+ for (let i = 0; i < numStrings; ++i) {
242
+ const l = reader(blob, offset);
243
+ offset += 4;
244
+ const stringOffset = reader(blob, offset);
245
+ offset += 4;
246
+ transTab.push([l, stringOffset]);
247
+ }
248
+ const poHeader = {};
249
+ for (let i = 0; i < numStrings; ++i) {
250
+ const orig = origTab[i];
251
+ let l = orig[0];
252
+ offset = orig[1];
253
+ const msgid = blob.readString(offset, l).split('\u0000')[0];
254
+ const trans = transTab[i];
255
+ l = trans[0];
256
+ offset = trans[1];
257
+ const msgstr = blob.readString(offset, l).split('\u0000');
258
+ let pairs, kv;
259
+ if (i === 0 && msgid === '') {
260
+ pairs = msgstr[0].split('\n');
261
+ for (let j = 0; j < pairs.length; ++j) {
262
+ if (pairs[j] !== '') {
263
+ kv = pairs[j].split(/[ \t]*:[ \t]*/);
264
+ poHeader[kv[0].toLowerCase()] = kv[1];
265
+ }
266
+ }
267
+ if (poHeader['content-type'] !== undefined) {
268
+ const enc = poHeader['content-type'].replace(/.*=/, '');
269
+ if (enc !== poHeader['content-type']) {
270
+ blob.encoding = enc;
271
+ }
272
+ }
273
+ }
274
+ catalog.entries[msgid] = msgstr;
275
+ }
276
+ return catalog;
277
+ }
278
+
279
+ function validateMoJsonCatalog(udata) {
280
+ // We could use ajv but it results in almost 300 k minimized code
281
+ // for the browser bundle. This validator instead is absolutely
282
+ // minimalistic, and only avoids exceptions that can occur, when
283
+ // accessing entries.
284
+ if (udata === null || typeof udata === 'undefined') {
285
+ throw new Error('catalog is either null or undefined');
286
+ }
287
+ const data = udata;
288
+ if (data.constructor !== Object) {
289
+ throw new Error('catalog must be a dictionary');
290
+ }
291
+ // We don't care about major and minor because they are actually not
292
+ // used.
293
+ if (!Object.prototype.hasOwnProperty.call(data, 'entries')) {
294
+ throw new Error('catalog.entries does not exist');
295
+ }
296
+ const entries = data.entries;
297
+ if (entries === null || typeof entries === 'undefined') {
298
+ throw new Error('catalog.entries are not defined or null');
299
+ }
300
+ if (entries.constructor !== Object) {
301
+ throw new Error('catalog.entries must be a dictionary');
302
+ }
303
+ for (const [key, value] of Object.entries(entries)) {
304
+ if (!Array.isArray(value)) {
305
+ throw new Error(`catalog entry for key '${key}' is not an array`);
306
+ }
307
+ }
308
+ return data;
309
+ }
310
+ function parseMoJsonCatalog(json) {
311
+ const text = new TextDecoder().decode(json);
312
+ const data = JSON.parse(text);
313
+ return validateMoJsonCatalog(data);
314
+ }
315
+
316
+ function validateJsonCatalog(udata) {
317
+ // We could use ajv but it results in almost 300 k minimized code
318
+ // for the browser bundle. This validator instead is absolutely
319
+ // minimalistic, and only avoids exceptions that can occur, when
320
+ // accessing entries.
321
+ if (udata === null || typeof udata === 'undefined') {
322
+ throw new Error('catalog is either null or undefined');
323
+ }
324
+ const entries = udata;
325
+ if (entries.constructor !== Object) ;
326
+ // Convert to a regular catalog.
327
+ const catalog = {
328
+ major: 0,
329
+ minor: 1,
330
+ pluralFunction: () => 0,
331
+ entries: {},
332
+ };
333
+ for (const [msgid, msgstr] of Object.entries(entries)) {
334
+ // Just stringify all values but do not complain.
335
+ catalog.entries[msgid] = [msgstr.toString()];
336
+ }
337
+ return catalog;
338
+ }
339
+ function parseJsonCatalog(json) {
340
+ const text = new TextDecoder().decode(json);
341
+ const data = JSON.parse(text);
342
+ return validateJsonCatalog(data);
343
+ }
344
+
345
+ const tagHyphenRegex = new RegExp('^[a-z0-9]+(?:-[a-z0-9]+)*$', 'i');
346
+ const tagUnderscoreRegex = new RegExp('^[a-z0-9]+(?:_[a-z0-9]+)*$', 'i');
347
+ function splitLocale(locale) {
348
+ let charset = '', modifier = '';
349
+ const underscoreSeparator = locale.includes('_');
350
+ locale = locale.replace(/@([a-z]+)$/i, (_, match) => {
351
+ modifier = match;
352
+ return '';
353
+ });
354
+ locale = locale.replace(/\.([-0-9a-z]+)$/i, (_, match) => {
355
+ charset = match;
356
+ return '';
357
+ });
358
+ if (underscoreSeparator) {
359
+ if (!tagUnderscoreRegex.exec(locale)) {
360
+ return null;
361
+ }
362
+ }
363
+ else {
364
+ if (!tagHyphenRegex.exec(locale)) {
365
+ return null;
366
+ }
367
+ }
368
+ const separator = underscoreSeparator ? '_' : '-';
369
+ const tags = locale.split(separator);
370
+ const split = { tags: tags, underscoreSeparator };
371
+ if (charset.length) {
372
+ split.charset = charset;
373
+ }
374
+ if (modifier.length) {
375
+ split.modifier = modifier;
376
+ }
377
+ return split;
378
+ }
379
+
380
+ /*
381
+ * Caches catalog lookups by path, locale, and textdomain.
382
+ *
383
+ * Failed lookups are stored as null values.
384
+ *
385
+ * It is also possible to store a Promise. In that case, if a request is
386
+ * made to bind the textdomain, the promise is settled. Note that this
387
+ * mechanism is never used for message lookup but only for loading the
388
+ * catalog via resolve.
389
+ */
390
+ class CatalogCache {
391
+ constructor() {
392
+ /* Singleton. */
393
+ }
394
+ static getInstance() {
395
+ if (!CatalogCache.instance) {
396
+ CatalogCache.instance = new CatalogCache();
397
+ }
398
+ return CatalogCache.instance;
399
+ }
400
+ static clear() {
401
+ CatalogCache.cache = {};
402
+ }
403
+ /**
404
+ * Lookup a Catalog for a given base path, locale, and textdomain.
405
+ *
406
+ * The locale key is usually the locale identifier (e.g. de-DE or sr\@latin).
407
+ * But it can also be a colon separated list of such locale identifiers.
408
+ *
409
+ *
410
+ * @param localeKey - the locale key
411
+ * @param textdomain - the textdomain
412
+ * @returns the cached Catalog, a Promise or null for failure
413
+ */
414
+ static lookup(localeKey, textdomain) {
415
+ if (CatalogCache.cache[localeKey]) {
416
+ const ptr = CatalogCache.cache[localeKey];
417
+ if (Object.prototype.hasOwnProperty.call(ptr, textdomain)) {
418
+ return ptr[textdomain];
419
+ }
420
+ }
421
+ return null;
422
+ }
423
+ static store(localeKey, textdomain, entry) {
424
+ if (Promise.resolve(entry) !== entry) {
425
+ // Object.
426
+ entry = validateMoJsonCatalog(entry);
427
+ }
428
+ if (!CatalogCache.cache[localeKey]) {
429
+ CatalogCache.cache[localeKey] = {};
430
+ }
431
+ CatalogCache.cache[localeKey][textdomain] = entry;
432
+ }
433
+ }
434
+ CatalogCache.cache = {};
435
+
436
+ function explodeLocale(locale, vary) {
437
+ const retval = [];
438
+ const lsep = locale.underscoreSeparator ? '_' : '-';
439
+ let i = 0 ;
440
+ const hasCharset = typeof locale.charset !== 'undefined';
441
+ const hasModifier = typeof locale.modifier !== 'undefined';
442
+ const charsets = hasCharset ? [locale.charset] : [''];
443
+ if (hasCharset) {
444
+ const charset = locale.charset;
445
+ const ucCharset = charset.toUpperCase();
446
+ if (ucCharset !== charset) {
447
+ charsets.push(ucCharset);
448
+ }
449
+ charsets.push('');
450
+ }
451
+ for (; i < locale.tags.length; ++i) {
452
+ const lingua = locale.tags.slice(0, i + 1).join(lsep);
453
+ const ids = new Array();
454
+ charsets.forEach(charset => {
455
+ let id = charset.length ? lingua + '.' + charset : lingua;
456
+ if (hasModifier) {
457
+ id += '@' + locale.modifier;
458
+ }
459
+ ids.push(id);
460
+ });
461
+ retval.push(ids);
462
+ }
463
+ return retval;
464
+ }
465
+
466
+ function loadCatalog(url, format) {
467
+ return __awaiter(this, void 0, void 0, function* () {
468
+ let transportInstance;
469
+ {
470
+ let transport;
471
+ // Check whether this is a valid URL.
472
+ try {
473
+ const parsedURL = new URL(url);
474
+ if (parsedURL.protocol === 'https:' ||
475
+ parsedURL.protocol === 'http:' ||
476
+ parsedURL.protocol === 'file:') {
477
+ transport = 'http';
478
+ }
479
+ else {
480
+ throw new Error(`unsupported scheme ${parsedURL.protocol}`);
481
+ }
482
+ }
483
+ catch (e) {
484
+ {
485
+ transport = 'fs';
486
+ }
487
+ }
488
+ if (transport === 'http') {
489
+ transportInstance = new TransportHttp();
490
+ }
491
+ else {
492
+ transportInstance = new TransportFs();
493
+ }
494
+ }
495
+ let validator;
496
+ if ('mo.json' === format) {
497
+ validator = parseMoJsonCatalog;
498
+ }
499
+ else if ('.json' === format) {
500
+ validator = parseJsonCatalog;
501
+ }
502
+ else {
503
+ validator = parseMoCatalog;
504
+ }
505
+ try {
506
+ const data = yield transportInstance.loadFile(url);
507
+ return validator(data);
508
+ }
509
+ catch (_a) {
510
+ return null;
511
+ }
512
+ });
513
+ }
514
+ function assemblePath(base, id, domainname, extender) {
515
+ return `${base}/${id}/LC_MESSAGES/${domainname}.${extender}`;
516
+ }
517
+ function loadLanguageFromObject(ids, base, domainname) {
518
+ return __awaiter(this, void 0, void 0, function* () {
519
+ for (let i = 0; i < ids.length; ++i) {
520
+ const id = ids[i];
521
+ // Language exists?
522
+ if (!Object.prototype.hasOwnProperty.call(base, id)) {
523
+ continue;
524
+ }
525
+ // LC_MESSAGES?
526
+ if (!Object.prototype.hasOwnProperty.call(base[id], 'LC_MESSAGES')) {
527
+ continue;
528
+ }
529
+ // Textdomain?
530
+ if (!Object.prototype.hasOwnProperty.call(base[id].LC_MESSAGES, domainname)) {
531
+ continue;
532
+ }
533
+ return base[id].LC_MESSAGES[domainname];
534
+ }
535
+ return null;
536
+ });
537
+ }
538
+ /*
539
+ * First tries to load a catalog with the specified charset, then with the
540
+ * charset converted to uppercase (if it differs from the original charset),
541
+ * and finally without a charset.
542
+ */
543
+ function loadLanguage(ids, base, domainname, format) {
544
+ return __awaiter(this, void 0, void 0, function* () {
545
+ // Check if `base` is an object (LocaleContainer).
546
+ if (typeof base === 'object' && base !== null) {
547
+ return loadLanguageFromObject(ids, base, domainname);
548
+ }
549
+ for (const id of ids) {
550
+ const catalog = yield loadCatalog(assemblePath(base, id, domainname, format), format);
551
+ if (catalog) {
552
+ return catalog;
553
+ }
554
+ }
555
+ return null;
556
+ });
557
+ }
558
+ function loadDomain(exploded, localeKey, base, domainname, format) {
559
+ return __awaiter(this, void 0, void 0, function* () {
560
+ const entries = {};
561
+ const catalog = {
562
+ major: 0,
563
+ minor: 0,
564
+ pluralFunction: germanicPlural,
565
+ entries,
566
+ };
567
+ const cacheHit = yield CatalogCache.lookup(localeKey, domainname);
568
+ if (cacheHit !== null) {
569
+ return cacheHit;
570
+ }
571
+ for (const tries of exploded) {
572
+ const result = yield loadLanguage(tries, base, domainname, format);
573
+ if (result) {
574
+ catalog.major = result.major;
575
+ catalog.minor = result.minor;
576
+ catalog.entries = Object.assign(Object.assign({}, catalog.entries), result.entries);
577
+ }
578
+ }
579
+ return catalog;
580
+ });
581
+ }
582
+ function pluralExpression(str) {
583
+ const tokens = str
584
+ .replace(/[ \t\r\013\014]/g, '')
585
+ .replace(/;$/, '')
586
+ // Do NOT allow square brackets here. JSFuck!
587
+ .split(/[<>!=]=|&&|\|\||[-!*/%+<>=?:;]/);
588
+ for (let i = 0; i < tokens.length; ++i) {
589
+ const token = tokens[i].replace(/^\(+/, '').replace(/\)+$/, '');
590
+ if (token !== 'nplurals' &&
591
+ token !== 'plural' &&
592
+ token !== 'n' &&
593
+ // Does not catch invalid octal numbers but the compiler
594
+ // takes care of that.
595
+ null === /^[0-9]+$/.exec(token)) {
596
+ throw new Error('invalid plural function');
597
+ }
598
+ }
599
+ const code = 'var nplurals = 1, plural = 0;' + str + '; return 0 + plural';
600
+ // This may throw an exception!
601
+ // eslint-disable-next-line @typescript-eslint/no-implied-eval
602
+ return new Function('n', code);
603
+ }
604
+ function setPluralFunction(catalog) {
605
+ if (!Object.prototype.hasOwnProperty.call(catalog.entries, '')) {
606
+ return catalog;
607
+ }
608
+ const headers = catalog.entries[''][0].split('\n');
609
+ headers.forEach(header => {
610
+ const tokens = header.split(':');
611
+ if ('plural-forms' === tokens.shift().toLowerCase()) {
612
+ const code = tokens.join(':');
613
+ try {
614
+ catalog.pluralFunction = pluralExpression(code);
615
+ }
616
+ catch (_a) {
617
+ catalog.pluralFunction = germanicPlural;
618
+ }
619
+ }
620
+ });
621
+ return catalog;
622
+ }
623
+ function resolveImpl(domainname, path, format, localeKey) {
624
+ return __awaiter(this, void 0, void 0, function* () {
625
+ const defaultCatalog = {
626
+ major: 0,
627
+ minor: 0,
628
+ pluralFunction: germanicPlural,
629
+ entries: {},
630
+ };
631
+ if (localeKey === 'C' || localeKey === 'POSIX') {
632
+ return defaultCatalog;
633
+ }
634
+ const exploded = explodeLocale(splitLocale(localeKey));
635
+ const catalog = yield loadDomain(exploded, localeKey, path, domainname, format);
636
+ setPluralFunction(catalog);
637
+ CatalogCache.store(localeKey, domainname, catalog);
638
+ return catalog;
639
+ });
640
+ }
641
+
642
+ function gettextImpl(args) {
643
+ var _a;
644
+ const key = typeof args.msgctxt === 'undefined'
645
+ ? args.msgid
646
+ : args.msgctxt + '\u0004' + args.msgid;
647
+ const translations = args.catalog.entries[key];
648
+ const numItems = (_a = args.numItems) !== null && _a !== void 0 ? _a : 1;
649
+ if (translations && translations.length) {
650
+ if (typeof args.msgidPlural === 'undefined') {
651
+ return translations[0];
652
+ }
653
+ else {
654
+ let pluralForm = args.catalog.pluralFunction(numItems);
655
+ if (pluralForm >= translations.length) {
656
+ if (translations.length === 1) {
657
+ return translations[0];
658
+ }
659
+ else {
660
+ pluralForm = germanicPlural(numItems);
661
+ }
662
+ }
663
+ return translations[pluralForm];
664
+ }
665
+ }
666
+ else if (typeof args.msgidPlural !== 'undefined') {
667
+ const pluralform = args.catalog.pluralFunction(numItems);
668
+ if (pluralform === 1) {
669
+ return args.msgidPlural;
670
+ }
671
+ }
672
+ return args.msgid;
673
+ }
674
+
675
+ const isNode = typeof process !== 'undefined' &&
676
+ process.versions !== null &&
677
+ process.versions.node !== null;
678
+ const pathSeparator = isNode && process.platform === 'win32' ? '\\' : '/';
679
+
680
+ function tagsEqual(left, right) {
681
+ if (left.length !== right.length) {
682
+ return false;
683
+ }
684
+ for (let i = 0; i < left.length; ++i) {
685
+ if (left[i].toLowerCase() !== right[i].toLowerCase()) {
686
+ return false;
687
+ }
688
+ }
689
+ return true;
690
+ }
691
+ function selectLocale(supported, requested) {
692
+ let languageMatch = '';
693
+ for (let i = 0; i < requested.length; ++i) {
694
+ const wanted = splitLocale(requested[i]);
695
+ if (!wanted) {
696
+ continue;
697
+ }
698
+ for (let j = 0; j < supported.length; ++j) {
699
+ const got = splitLocale(supported[j]);
700
+ if (!got) {
701
+ continue;
702
+ }
703
+ if (tagsEqual(wanted.tags, got.tags)) {
704
+ return supported[j];
705
+ }
706
+ if (!languageMatch.length &&
707
+ wanted.tags[0].toLowerCase() === got.tags[0].toLowerCase()) {
708
+ languageMatch = supported[j];
709
+ }
710
+ }
711
+ }
712
+ if (languageMatch.length) {
713
+ return languageMatch;
714
+ }
715
+ return 'C';
716
+ }
717
+
718
+ /**
719
+ * A Textdomain is a container for an esgettext configuration and all loaded
720
+ * LocaleContainer for the textual domain selected.
721
+ *
722
+ * The actual translation methods have quite funny names like `_()` or
723
+ * `_x()`. The purpose of this naming convention is to make the
724
+ * internationalization of your programs as little obtrusive as possible.
725
+ * Most of the times you just have to exchange
726
+ *
727
+ * ```
728
+ * doSomething('Hello, world!');
729
+ * ```
730
+ *
731
+ * with
732
+ *
733
+ * ```
734
+ * doSomething(gtx._('Hello, world!'));
735
+ * ```
736
+ *
737
+ * Besides, depending on the string extractor you are using, it may be useful
738
+ * that the method names do not collide with method names from other packages.
739
+ */
740
+ class Textdomain {
741
+ /**
742
+ * Retrieve a translation for a string.
743
+ *
744
+ * @param msgid - the string to translate
745
+ *
746
+ * @returns the translated string
747
+ */
748
+ _(msgid) {
749
+ return gettextImpl({ msgid: msgid, catalog: this.catalog });
750
+ }
751
+ /**
752
+ * Retrieve a translation for a string containing a possible plural.
753
+ * You will almost always want to call {@link _nx} instead so that
754
+ * you can interpolate the number of items into the strings.
755
+ *
756
+ * @param msgid - the string in the singular
757
+ * @param msgidPlural - the string in the plural
758
+ * @param numItems - the number of items
759
+ *
760
+ * @returns the translated string
761
+ */
762
+ _n(msgid, msgidPlural, numItems) {
763
+ return gettextImpl({
764
+ msgid: msgid,
765
+ msgidPlural: msgidPlural,
766
+ numItems: numItems,
767
+ catalog: this.catalog,
768
+ });
769
+ }
770
+ /**
771
+ * Translate a string with a context.
772
+ *
773
+ * @param msgctxt - the message context
774
+ * @param msgid - the string to translate
775
+ *
776
+ * @returns the translated string
777
+ */
778
+ _p(msgctxt, msgid) {
779
+ return gettextImpl({
780
+ msgctxt: msgctxt,
781
+ msgid: msgid,
782
+ catalog: this.catalog,
783
+ });
784
+ }
785
+ /**
786
+ * The method `_np()` combines `_n()` with `_p()`.
787
+ * You will almost always want to call {@link _npx} instead so that
788
+ * you can interpolate the number of items into the strings.
789
+
790
+ *
791
+ * @param msgctxt - the message context
792
+ * @param msgid - the message id
793
+ * @param placeholders - a dictionary with placehoders
794
+ * @returns the translated string
795
+ */
796
+ _np(msgctxt, msgid, msgidPlural, numItems) {
797
+ return gettextImpl({
798
+ msgctxt: msgctxt,
799
+ msgid: msgid,
800
+ msgidPlural: msgidPlural,
801
+ numItems: numItems,
802
+ catalog: this.catalog,
803
+ });
804
+ }
805
+ /**
806
+ * Translate a string with placeholders. The placeholders should be
807
+ * wrapped into curly braces and must match the regular expression
808
+ * "[_a-zA-Z][_a-zA-Z0-9]*".
809
+ *
810
+ * @param msgid - the msgid to translate
811
+ * @param placeholders - an optional dictionary of placeholders
812
+ *
813
+ * @returns the translated string with placeholders expanded
814
+ */
815
+ _x(msgid, placeholders) {
816
+ return Textdomain.expand(gettextImpl({ msgid: msgid, catalog: this.catalog }), placeholders || {});
817
+ }
818
+ /**
819
+ * Translate a string with a plural expression with placeholders.
820
+ *
821
+ * @param msgid - the string in the singular
822
+ * @param msgidPlural - the string in the plural
823
+ * @param numItems - the number of items
824
+ * @param placeholders - an optional dictionary of placeholders
825
+ *
826
+ * @returns the translated string
827
+ */
828
+ _nx(msgid, msgidPlural, numItems, placeholders) {
829
+ return Textdomain.expand(gettextImpl({
830
+ msgid: msgid,
831
+ msgidPlural: msgidPlural,
832
+ numItems: numItems,
833
+ catalog: this.catalog,
834
+ }), placeholders || {});
835
+ }
836
+ /**
837
+ * The method `_px()` combines `_p()` with `_x()`.
838
+ *
839
+ * @param msgctxt - the message context
840
+ * @param msgid - the message id
841
+ * @param placeholders - an optional dictionary with placehoders
842
+ * @returns the translated string
843
+ */
844
+ _px(msgctxt, msgid, placeholders) {
845
+ return Textdomain.expand(gettextImpl({ msgctxt: msgctxt, msgid: msgid, catalog: this.catalog }), placeholders || {});
846
+ }
847
+ /**
848
+ * The method `_npx()` brings it all together. It combines `_n()` and
849
+ * `_p()` and `_x()`.
850
+ *
851
+ * @param msgctxt - the message context
852
+ * @param msgid - the message id
853
+ * @param msgidPlural - the plural string
854
+ * @param numItems - the number of items
855
+ * @param placeholders - an optional dictionary with placehoders
856
+ * @returns the translated string
857
+ */
858
+ _npx(msgctxt, msgid, msgidPlural, numItems, placeholders) {
859
+ return Textdomain.expand(gettextImpl({
860
+ msgctxt: msgctxt,
861
+ msgid: msgid,
862
+ msgidPlural: msgidPlural,
863
+ numItems: numItems,
864
+ catalog: this.catalog,
865
+ }), placeholders || {});
866
+ }
867
+ static getCatalog(locale, textdomain) {
868
+ const catalog = CatalogCache.lookup(locale, textdomain);
869
+ if (!catalog || Promise.resolve(catalog) === catalog) {
870
+ return {
871
+ major: 0,
872
+ minor: 0,
873
+ pluralFunction: germanicPlural,
874
+ entries: {},
875
+ };
876
+ }
877
+ return catalog;
878
+ }
879
+ /**
880
+ * Retrieve a translation for a string with a fixed locale.
881
+ *
882
+ * @param locale - the locale identifier
883
+ * @param msgid - the string to translate
884
+ *
885
+ * @returns the translated string
886
+ */
887
+ _l(locale, msgid) {
888
+ const catalog = Textdomain.getCatalog(locale, this.textdomain());
889
+ return gettextImpl({ msgid: msgid, catalog: catalog });
890
+ }
891
+ /**
892
+ * Retrieve a translation for a string containing a possible plural with
893
+ * a fixed locale.
894
+ * You will almost always want to call {@link _nx} instead so that
895
+ * you can interpolate the number of items into the strings.
896
+ *
897
+ * @param locale - the locale identifier
898
+ * @param msgid - the string in the singular
899
+ * @param msgidPlural - the string in the plural
900
+ * @param numItems - the number of items
901
+ *
902
+ * @returns the translated string
903
+ */
904
+ _ln(locale, msgid, msgidPlural, numItems) {
905
+ const catalog = Textdomain.getCatalog(locale, this.textdomain());
906
+ return gettextImpl({
907
+ msgid: msgid,
908
+ msgidPlural: msgidPlural,
909
+ numItems: numItems,
910
+ catalog: catalog,
911
+ });
912
+ }
913
+ /**
914
+ * Translate a string with a context with a fixed locale.
915
+ *
916
+ * @param locale - the locale identifier
917
+ * @param msgctxt - the message context
918
+ * @param msgid - the string to translate
919
+ *
920
+ * @returns the translated string
921
+ */
922
+ _lp(locale, msgctxt, msgid) {
923
+ const catalog = Textdomain.getCatalog(locale, this.textdomain());
924
+ return gettextImpl({ msgctxt: msgctxt, msgid: msgid, catalog: catalog });
925
+ }
926
+ /**
927
+ * The method `_lnp()` combines `_ln()` with `_lp()`.
928
+ * You will almost always want to call {@link _npx} instead so that
929
+ * you can interpolate the number of items into the strings.
930
+
931
+ *
932
+ * @param locale - the locale identifier
933
+ * @param msgctxt - the message context
934
+ * @param msgid - the message id
935
+ * @param placeholders - a dictionary with placehoders
936
+ * @returns the translated string
937
+ */
938
+ _lnp(locale, msgctxt, msgid, msgidPlural, numItems) {
939
+ const catalog = Textdomain.getCatalog(locale, this.textdomain());
940
+ return gettextImpl({
941
+ msgctxt: msgctxt,
942
+ msgid: msgid,
943
+ msgidPlural: msgidPlural,
944
+ numItems: numItems,
945
+ catalog: catalog,
946
+ });
947
+ }
948
+ /**
949
+ * Translate a string with placeholders for a fixed locale.
950
+ * The placeholders should be
951
+ * wrapped into curly braces and must match the regular expression
952
+ * "[_a-zA-Z][_a-zA-Z0-9]*".
953
+ *
954
+ * @param locale - the locale identifier
955
+ * @param msgid - the msgid to translate
956
+ * @param placeholders - an optional dictionary of placeholders
957
+ *
958
+ * @returns the translated string with placeholders expanded
959
+ */
960
+ _lx(locale, msgid, placeholders) {
961
+ const catalog = Textdomain.getCatalog(locale, this.textdomain());
962
+ return Textdomain.expand(gettextImpl({ msgid: msgid, catalog: catalog }), placeholders || {});
963
+ }
964
+ /**
965
+ * Translate a string with a plural expression with placeholders into a
966
+ * fixed locale.
967
+ *
968
+ * @param locale - the locale identifier
969
+ * @param msgid - the string in the singular
970
+ * @param msgidPlural - the string in the plural
971
+ * @param numItems - the number of items
972
+ * @param placeholders - an optional dictionary of placeholders
973
+ *
974
+ * @returns the translated string
975
+ */
976
+ _lnx(locale, msgid, msgidPlural, numItems, placeholders) {
977
+ const catalog = Textdomain.getCatalog(locale, this.textdomain());
978
+ return Textdomain.expand(gettextImpl({
979
+ msgid: msgid,
980
+ msgidPlural: msgidPlural,
981
+ numItems: numItems,
982
+ catalog: catalog,
983
+ }), placeholders || {});
984
+ }
985
+ /**
986
+ * The method `_lpx()` combines `_lp()` with `_lx()`.
987
+ *
988
+ * @param locale - the locale identifier
989
+ * @param msgctxt - the message context
990
+ * @param msgid - the message id
991
+ * @param placeholders - an optional dictionary with placehoders
992
+ * @returns the translated string
993
+ */
994
+ _lpx(locale, msgctxt, msgid, placeholders) {
995
+ const catalog = Textdomain.getCatalog(locale, this.textdomain());
996
+ return Textdomain.expand(gettextImpl({ msgctxt: msgctxt, msgid: msgid, catalog: catalog }), placeholders || {});
997
+ }
998
+ /**
999
+ * The method `_lnpx()` brings it all together. It combines `_ln()` and
1000
+ * `_lp()` and `_lx()`.
1001
+ *
1002
+ * @param locale - the locale identifier
1003
+ * @param msgctxt - the message context
1004
+ * @param msgid - the message id
1005
+ * @param msgidPlural - the plural string
1006
+ * @param numItems - the number of items
1007
+ * @param placeholders - an optional dictionary with placehoders
1008
+ * @returns the translated string
1009
+ */
1010
+ _lnpx(locale, msgctxt, msgid, msgidPlural, numItems, placeholders) {
1011
+ const catalog = Textdomain.getCatalog(locale, this.textdomain());
1012
+ return Textdomain.expand(gettextImpl({
1013
+ msgctxt: msgctxt,
1014
+ msgid: msgid,
1015
+ msgidPlural: msgidPlural,
1016
+ numItems: numItems,
1017
+ catalog: catalog,
1018
+ }), placeholders || {});
1019
+ }
1020
+ static expand(msg, placeholders) {
1021
+ return msg.replace(/\{([a-zA-Z][0-9a-zA-Z]*)\}/g, (_, match) => {
1022
+ if (Object.prototype.hasOwnProperty.call(placeholders, match)) {
1023
+ return placeholders[match];
1024
+ }
1025
+ else {
1026
+ return `{${match}}`;
1027
+ }
1028
+ });
1029
+ }
1030
+ /**
1031
+ * Instantiate a Textdomain object. Textdomain objects are singletons
1032
+ * for each textdomain identifier.
1033
+ *
1034
+ * @param textdomain - the textdomain of your application or library.
1035
+ *
1036
+ * @returns a [[`Textdomain`]]
1037
+ */
1038
+ static getInstance(textdomain) {
1039
+ if (typeof textdomain === 'undefined' ||
1040
+ textdomain === null ||
1041
+ textdomain === '') {
1042
+ throw new Error('Cannot instantiate TextDomain without a textdomain');
1043
+ }
1044
+ if (Object.prototype.hasOwnProperty.call(Textdomain.domains, textdomain)) {
1045
+ return Textdomain.domains[textdomain];
1046
+ }
1047
+ else {
1048
+ const domain = new Textdomain(textdomain);
1049
+ Textdomain.domains[textdomain] = domain;
1050
+ domain.catalog = {
1051
+ major: 0,
1052
+ minor: 0,
1053
+ pluralFunction: germanicPlural,
1054
+ entries: {},
1055
+ };
1056
+ return domain;
1057
+ }
1058
+ }
1059
+ /**
1060
+ * Delete all existing singletons. This method should usually be called
1061
+ * only, when you want to free memory.
1062
+ */
1063
+ static clearInstances() {
1064
+ Textdomain.boundDomains = {};
1065
+ }
1066
+ /**
1067
+ * This method is used for testing. Do not use it yourself!
1068
+ */
1069
+ static forgetInstances() {
1070
+ Textdomain.clearInstances();
1071
+ Textdomain.domains = {};
1072
+ }
1073
+ /**
1074
+ * Query the locale in use.
1075
+ */
1076
+ static get locale() {
1077
+ return Textdomain._locale;
1078
+ }
1079
+ /**
1080
+ * Change the locale.
1081
+ *
1082
+ * For the web you can use all valid language identifier tags that
1083
+ * [BCP47](https://tools.ietf.org/html/bcp47) allows
1084
+ * (and actually a lot more). The tag is always used unmodified.
1085
+ *
1086
+ * For server environments, the locale identifier has to match the following
1087
+ * scheme:
1088
+ *
1089
+ * `ll_CC.charset\@modifier`
1090
+ *
1091
+ * * `ll` is the two- or three-letter language code.
1092
+ * * `CC` is the optional two-letter country code.
1093
+ * * `charset` is an optional character set (letters, digits, and the hyphen).
1094
+ * * `modifier` is an optional variant (letters and digits).
1095
+ *
1096
+ * The language code is always converted to lowercase, the country code is
1097
+ * converted to uppercase, variant and charset are used as is.
1098
+ *
1099
+ * @param locale - the locale identifier
1100
+ * @returns the locale in use
1101
+ */
1102
+ static set locale(locale) {
1103
+ const ucLocale = locale.toUpperCase();
1104
+ if (ucLocale === 'POSIX' || ucLocale === 'C') {
1105
+ this._locale = 'POSIX';
1106
+ return;
1107
+ }
1108
+ const split = splitLocale(locale);
1109
+ if (!split) {
1110
+ throw new Error('invalid locale identifier');
1111
+ }
1112
+ // Node.
1113
+ split.tags[0] = split.tags[0].toLowerCase();
1114
+ if (split.tags.length > 1) {
1115
+ split.tags[1] = split.tags[1].toUpperCase();
1116
+ }
1117
+ const separator = split.underscoreSeparator ? '_' : '-';
1118
+ this._locale = split.tags.join(separator);
1119
+ if (typeof split.charset !== 'undefined') {
1120
+ this._locale += '.' + split.charset;
1121
+ }
1122
+ if (typeof split.modifier !== 'undefined') {
1123
+ this._locale += '@' + split.modifier;
1124
+ }
1125
+ }
1126
+ constructor(domain) {
1127
+ this._catalogFormat = 'mo.json';
1128
+ this.catalog = undefined;
1129
+ this.domain = domain;
1130
+ const msg = "The property 'locale' is not an instance property but static. Use 'Textdomain.locale' instead!";
1131
+ Object.defineProperty(this, 'locale', {
1132
+ get: () => {
1133
+ throw new Error(msg);
1134
+ },
1135
+ set: () => {
1136
+ throw new Error(msg);
1137
+ },
1138
+ enumerable: true,
1139
+ configurable: true,
1140
+ });
1141
+ }
1142
+ /**
1143
+ * A textdomain is an identifier for your application or library. It is
1144
+ * the basename of your translation files which are either
1145
+ * TEXTDOMAIN.mo.json or TEXTDOMAIN.mo, depending on the format you have
1146
+ * chosen.
1147
+ *
1148
+ * FIXME! This should be a getter!
1149
+ *
1150
+ * @returns the textdomain
1151
+ */
1152
+ textdomain() {
1153
+ return this.domain;
1154
+ }
1155
+ /**
1156
+ * Bind a textdomain to a certain path or queries the path that a
1157
+ * textdomain is bound to. The catalog file will be searched
1158
+ * in `${path}/LC_MESSAGES/${domainname}.EXT` where `EXT` is the
1159
+ * selected catalog format (one of `mo.json`, `mo`, or `json`).
1160
+ *
1161
+ * Alternatively, you can pass a [[`LocaleContainer`]] that holds the
1162
+ * catalogs in memory.
1163
+ *
1164
+ * The returned string or `LocaleContainer` is valid until the next
1165
+ * `bindtextdomain` call with an argument.
1166
+ *
1167
+ * @param path - the base path or [[`LocaleContainer`]] for this textdomain
1168
+ *
1169
+ * @returns the current base directory or [[`LocaleContainer`]] for this domain, after possibly changing it.
1170
+ */
1171
+ bindtextdomain(path) {
1172
+ if (typeof path !== 'undefined') {
1173
+ Textdomain.boundDomains[this.domain] = path;
1174
+ }
1175
+ return Textdomain.boundDomains[this.domain];
1176
+ }
1177
+ /**
1178
+ * Resolve a textdomain, i.e. load the LocaleContainer for this domain and all
1179
+ * of its dependencies for the currently selected locale or the locale
1180
+ * specified.
1181
+ *
1182
+ * The promise will always resolve. If no catalog was found, an empty
1183
+ * catalog will be returned that is still usable.
1184
+ *
1185
+ * @param locale - an optional locale identifier, defaults to Textdomain.locale
1186
+ *
1187
+ * @returns a promise for a Catalog that will always resolve.
1188
+ */
1189
+ resolve(locale) {
1190
+ return __awaiter(this, void 0, void 0, function* () {
1191
+ const promises = [this.resolve1(locale)];
1192
+ for (const td in Textdomain.domains) {
1193
+ if (Object.prototype.hasOwnProperty.call(Textdomain.domains, td) &&
1194
+ Textdomain.domains[td] !== this) {
1195
+ promises.push(Textdomain.domains[td].resolve1(locale));
1196
+ }
1197
+ }
1198
+ return Promise.all(promises).then(values => {
1199
+ return new Promise(resolve => resolve(values[0]));
1200
+ });
1201
+ });
1202
+ }
1203
+ resolve1(locale) {
1204
+ return __awaiter(this, void 0, void 0, function* () {
1205
+ let path = this.bindtextdomain();
1206
+ if (typeof path === 'undefined' || path === null) {
1207
+ const parts = ['.', 'locale'];
1208
+ path = parts.join(pathSeparator);
1209
+ }
1210
+ const resolvedLocale = locale ? locale : Textdomain.locale;
1211
+ return resolveImpl(this.domain, path, this.catalogFormat, resolvedLocale).then(catalog => {
1212
+ if (!locale) {
1213
+ this.catalog = catalog;
1214
+ }
1215
+ return new Promise(resolve => resolve(catalog));
1216
+ });
1217
+ });
1218
+ }
1219
+ /**
1220
+ * Get the catalog format in use.
1221
+ *
1222
+ * @returns one of 'mo.json' or 'mo' (default is 'mo.json')
1223
+ */
1224
+ get catalogFormat() {
1225
+ return this._catalogFormat;
1226
+ }
1227
+ /**
1228
+ * Set the catalog format to use.
1229
+ *
1230
+ * @param format - one of 'mo.json' or 'mo'
1231
+ */
1232
+ set catalogFormat(format) {
1233
+ format = format.toLowerCase();
1234
+ if (format === 'mo.json') {
1235
+ this._catalogFormat = 'mo.json';
1236
+ }
1237
+ else if (format === 'mo') {
1238
+ this._catalogFormat = 'mo';
1239
+ }
1240
+ else {
1241
+ throw new Error(`unsupported format ${format}`);
1242
+ }
1243
+ }
1244
+ /**
1245
+ * Queries the user's preferred locales. On the server it queries the
1246
+ * environment variables `LANGUAGE`, `LC_ALL`, `LANG`, and `LC_MESSAGES`
1247
+ * (in that order). In the browser, it parses it checks the user preferences
1248
+ * in the variables `navigator.languages`, `navigator.language`,
1249
+ * `navigator.userLanguage`, `navigator.browserLanguage`, and
1250
+ * `navigator.systemLanguage`.
1251
+ *
1252
+ * @returns the set of locales in order of preference
1253
+ *
1254
+ * Added in \@runtime 0.1.0.
1255
+ */
1256
+ static userLocales() {
1257
+ return userLocales();
1258
+ }
1259
+ /**
1260
+ * Select one of the supported locales from a list of locales accepted by
1261
+ * the user.
1262
+ *
1263
+ * @param supported - the list of locales supported by the application
1264
+ * @param requested - the list of locales accepted by the user
1265
+ *
1266
+ * If called with just one argument, then the list of requested locales
1267
+ * is determined by calling [[Textdomain.userLocales]].
1268
+ *
1269
+ * @returns the negotiated locale or 'C' if not possible.
1270
+ */
1271
+ static selectLocale(supported, requested) {
1272
+ return selectLocale(supported, requested !== null && requested !== void 0 ? requested : Textdomain.userLocales());
1273
+ }
1274
+ /**
1275
+ * A no-op method for string marking.
1276
+ *
1277
+ * Sometimes you want to mark strings for translation but do not actually
1278
+ * want to translate them, at least not at the time of their definition.
1279
+ * This is often the case, when you have to preserve the original string.
1280
+ *
1281
+ * Take this example:
1282
+ *
1283
+ * ```
1284
+ * orangeColors = [gtx.N_('coral'), gtx.N_('tomato'), gtx.N_('orangered'),
1285
+ * gtx.N_('gold'), gtx.N_('orange'), gtx.N_('darkorange')]
1286
+ * ```
1287
+ *
1288
+ * These are standard CSS colors, and you cannot translate them inside
1289
+ * CSS styles. But for presentation you may want to translate them later:
1290
+ *
1291
+ * ```
1292
+ * console.log(gtx._x("The css color '{color}' is {translated}.",
1293
+ * {
1294
+ * color: orangeColors[2],
1295
+ * translated: gtx._(orangeColors[2]),
1296
+ * }
1297
+ * )
1298
+ * );
1299
+ * ```
1300
+ *
1301
+ * In other words: The method just marks strings for translation, so that
1302
+ * the extractor `esgettext-xgettext` finds them but it does not actually
1303
+ * translate anything.
1304
+ *
1305
+ * Similar methods are available for other cases (with placeholder
1306
+ * expansion, context, or both). They are *not* available for plural
1307
+ * methods because that would not make sense.
1308
+ *
1309
+ * Note that all of these methods are also available as instance methods.
1310
+ *
1311
+ * @param msgid - the message id
1312
+ * @returns the original string
1313
+ */
1314
+ static N_(msgid) {
1315
+ return msgid;
1316
+ }
1317
+ /**
1318
+ * Does the same as the static method `N_()`.
1319
+ *
1320
+ * @param msgid - the message id
1321
+ * @returns the original string
1322
+ */
1323
+ N_(msgid) {
1324
+ return msgid;
1325
+ }
1326
+ /**
1327
+ * Same as `N_()` but with placeholder expansion.
1328
+ *
1329
+ * @param msgid - the message id
1330
+ * @param placeholders - a dictionary of placeholders
1331
+ * @returns the original string with placeholders expanded
1332
+ */
1333
+ N_x(msgid, placeholders) {
1334
+ return Textdomain.expand(msgid, placeholders !== null && placeholders !== void 0 ? placeholders : {});
1335
+ }
1336
+ /**
1337
+ * Does the same as the static method `N_x()`.
1338
+ *
1339
+ * @param msgid - the message id
1340
+ * @param placeholders - a dictionary of placeholders
1341
+ * @returns the original string with placeholders expanded
1342
+ */
1343
+ static N_x(msgid, placeholders) {
1344
+ return Textdomain.expand(msgid, placeholders !== null && placeholders !== void 0 ? placeholders : {});
1345
+ }
1346
+ /**
1347
+ * Same as `N_()` but with context.
1348
+ *
1349
+ * @param _msgctxt - the message context (not used)
1350
+ * @param msgid - the message id
1351
+ * @returns the original string
1352
+ */
1353
+ N_p(_msgctxt, msgid) {
1354
+ return msgid;
1355
+ }
1356
+ /**
1357
+ * Does the same as the static method `N_p()`.
1358
+ *
1359
+ * @param _msgctxt - the message context (not used)
1360
+ * @param msgid - the message id
1361
+ * @returns the original string with placeholders expanded
1362
+ */
1363
+ static N_p(_msgctxt, msgid) {
1364
+ return msgid;
1365
+ }
1366
+ /**
1367
+ * Same as `N_()` but with context and placeholder expansion.
1368
+ *
1369
+ * @param _msgctxt - the message context (not used)
1370
+ * @param msgid - the message id
1371
+ * @param placeholders - a dictionary of placeholders
1372
+ * @returns the original string with placeholders expanded
1373
+ */
1374
+ N_px(_msgctxt, msgid, placeholders) {
1375
+ return Textdomain.expand(msgid, placeholders !== null && placeholders !== void 0 ? placeholders : {});
1376
+ }
1377
+ /**
1378
+ * Does the same as the static method `N_px()`.
1379
+ *
1380
+ * @param _msgctxt - the message context (not used)
1381
+ * @param msgid - the message id
1382
+ * @param placeholders - a dictionary of placeholders
1383
+ * @returns the original string with placeholders expanded
1384
+ */
1385
+ static N_px(_msgctxt, msgid, placeholders) {
1386
+ return Textdomain.expand(msgid, placeholders !== null && placeholders !== void 0 ? placeholders : {});
1387
+ }
1388
+ }
1389
+ Textdomain.domains = {};
1390
+ Textdomain.boundDomains = {};
1391
+ Textdomain._locale = 'C';
1392
+
1393
+ // FIXME! Windows!
1394
+ if (typeof process.env.LANGUAGE !== 'undefined') {
1395
+ userLocales(process.env.LANGUAGE.split(':'));
1396
+ }
1397
+ else if (typeof process.env.LC_ALL !== 'undefined') {
1398
+ userLocales([process.env.LC_ALL]);
1399
+ }
1400
+ else if (typeof process.env.LANG !== 'undefined') {
1401
+ userLocales([process.env.LANG]);
1402
+ }
1403
+ else if (typeof process.env.LC_MESSAGES !== 'undefined') {
1404
+ userLocales([process.env.LC_MESSAGES]);
1405
+ }
1406
+
1407
+ exports.CatalogCache = CatalogCache;
1408
+ exports.Textdomain = Textdomain;
1409
+ exports.parseMoCatalog = parseMoCatalog;
1410
+ exports.parseMoJsonCatalog = parseMoJsonCatalog;
1411
+ //# sourceMappingURL=esgettext.cjs.js.map