@x18n/builtins 0.0.12 → 0.0.14

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 (170) hide show
  1. package/dist/angular-templates-DqIOGfzT.mjs +8 -0
  2. package/dist/checks.mjs +3 -2
  3. package/dist/extractors.d.mts +2 -2
  4. package/dist/extractors.mjs +18 -6
  5. package/dist/finders.d.mts +4 -1
  6. package/dist/finders.mjs +1 -1
  7. package/dist/formats/ecmascript.d.mts +5 -0
  8. package/dist/formats/ecmascript.mjs +211 -0
  9. package/dist/formats/ftl.d.mts +5 -0
  10. package/dist/formats/ftl.mjs +234 -0
  11. package/dist/formats/ini.d.mts +5 -0
  12. package/dist/formats/ini.mjs +158 -0
  13. package/dist/formats/json.d.mts +6 -0
  14. package/dist/formats/json.mjs +10 -0
  15. package/dist/formats/json5.d.mts +5 -0
  16. package/dist/formats/json5.mjs +30 -0
  17. package/dist/formats/jsonc.d.mts +6 -0
  18. package/dist/formats/jsonc.mjs +10 -0
  19. package/dist/formats/php.d.mts +5 -0
  20. package/dist/formats/php.mjs +200 -0
  21. package/dist/formats/po.d.mts +5 -0
  22. package/dist/formats/po.mjs +177 -0
  23. package/dist/formats/properties.d.mts +5 -0
  24. package/dist/formats/properties.mjs +123 -0
  25. package/dist/formats/resx.d.mts +6 -0
  26. package/dist/formats/resx.mjs +202 -0
  27. package/dist/formats/yaml.d.mts +5 -0
  28. package/dist/formats/yaml.mjs +113 -0
  29. package/dist/formats.d.mts +10 -34
  30. package/dist/formats.mjs +61 -1
  31. package/dist/index.d.mts +2 -2
  32. package/dist/index.mjs +28 -22
  33. package/dist/{vue-5GFR5hft.mjs → js-CV-ECNJG.mjs} +133 -273
  34. package/dist/json-CyjI8bjp.d.mts +8 -0
  35. package/dist/json-Db-8qSbE.mjs +73 -0
  36. package/dist/jsx-templates-B1J0no3i.mjs +17 -0
  37. package/dist/locale-root-C_rch3IQ.mjs +15 -0
  38. package/dist/manifests.d.mts +8 -0
  39. package/dist/manifests.mjs +66 -2
  40. package/dist/placeholders.d.mts +11 -0
  41. package/dist/placeholders.mjs +28 -1
  42. package/dist/plugin-Cb1b0axD.mjs +83 -0
  43. package/dist/plural-forms-B7_QX4nG.mjs +12 -0
  44. package/dist/presets/cargo-i18n.d.mts +6 -0
  45. package/dist/presets/cargo-i18n.mjs +28 -0
  46. package/dist/presets/chrome-extension.d.mts +6 -0
  47. package/dist/presets/chrome-extension.mjs +52 -0
  48. package/dist/presets/dotnet-resx.d.mts +6 -0
  49. package/dist/presets/dotnet-resx.mjs +64 -0
  50. package/dist/presets/easy-localization.d.mts +6 -0
  51. package/dist/presets/easy-localization.mjs +36 -0
  52. package/dist/presets/ember-intl.d.mts +5 -0
  53. package/dist/presets/ember-intl.mjs +31 -0
  54. package/dist/presets/fluent-react.d.mts +5 -0
  55. package/dist/presets/fluent-react.mjs +46 -0
  56. package/dist/presets/fluent-vue.d.mts +5 -0
  57. package/dist/presets/fluent-vue.mjs +51 -0
  58. package/dist/presets/flutter-translate.d.mts +6 -0
  59. package/dist/presets/flutter-translate.mjs +30 -0
  60. package/dist/presets/flutter.d.mts +6 -0
  61. package/dist/presets/flutter.mjs +21 -0
  62. package/dist/presets/general.d.mts +6 -0
  63. package/dist/presets/general.mjs +17 -0
  64. package/dist/presets/globalize.d.mts +5 -0
  65. package/dist/presets/globalize.mjs +25 -0
  66. package/dist/presets/gravity-ui-i18n.d.mts +6 -0
  67. package/dist/presets/gravity-ui-i18n.mjs +41 -0
  68. package/dist/presets/i18n-js.d.mts +5 -0
  69. package/dist/presets/i18n-js.mjs +19 -0
  70. package/dist/presets/i18n-tag.d.mts +5 -0
  71. package/dist/presets/i18n-tag.mjs +21 -0
  72. package/dist/presets/i18next-shopify.d.mts +6 -0
  73. package/dist/presets/i18next-shopify.mjs +23 -0
  74. package/dist/presets/i18next.d.mts +5 -0
  75. package/dist/presets/i18next.mjs +10 -0
  76. package/dist/presets/i18nice.d.mts +6 -0
  77. package/dist/presets/i18nice.mjs +29 -0
  78. package/dist/presets/jekyll.d.mts +5 -0
  79. package/dist/presets/jekyll.mjs +23 -0
  80. package/dist/presets/laravel-vue-i18n.d.mts +6 -0
  81. package/dist/presets/laravel-vue-i18n.mjs +54 -0
  82. package/dist/presets/laravel.d.mts +6 -0
  83. package/dist/presets/laravel.mjs +23 -0
  84. package/dist/presets/lingui.d.mts +5 -0
  85. package/dist/presets/lingui.mjs +61 -0
  86. package/dist/presets/next-international.d.mts +5 -0
  87. package/dist/presets/next-international.mjs +27 -0
  88. package/dist/presets/next-intl.d.mts +5 -0
  89. package/dist/presets/next-intl.mjs +55 -0
  90. package/dist/presets/next-translate.d.mts +5 -0
  91. package/dist/presets/next-translate.mjs +53 -0
  92. package/dist/presets/ngx-translate.d.mts +5 -0
  93. package/dist/presets/ngx-translate.mjs +41 -0
  94. package/dist/presets/nuxt-i18n-micro.d.mts +5 -0
  95. package/dist/presets/nuxt-i18n-micro.mjs +81 -0
  96. package/dist/presets/nuxt-i18n.d.mts +5 -0
  97. package/dist/presets/nuxt-i18n.mjs +23 -0
  98. package/dist/presets/paraglide.d.mts +5 -0
  99. package/dist/presets/paraglide.mjs +38 -0
  100. package/dist/presets/php-gettext.d.mts +6 -0
  101. package/dist/presets/php-gettext.mjs +27 -0
  102. package/dist/presets/php-joomla.d.mts +6 -0
  103. package/dist/presets/php-joomla.mjs +22 -0
  104. package/dist/presets/polyglot.d.mts +5 -0
  105. package/dist/presets/polyglot.mjs +23 -0
  106. package/dist/presets/python-gettext.d.mts +6 -0
  107. package/dist/presets/python-gettext.mjs +44 -0
  108. package/dist/presets/react-i18next.d.mts +5 -0
  109. package/dist/presets/react-i18next.mjs +67 -0
  110. package/dist/presets/react-intl.d.mts +5 -0
  111. package/dist/presets/react-intl.mjs +47 -0
  112. package/dist/presets/ruby-rails.d.mts +7 -0
  113. package/dist/presets/ruby-rails.mjs +44 -0
  114. package/dist/presets/solid-primitives-i18n.d.mts +5 -0
  115. package/dist/presets/solid-primitives-i18n.mjs +29 -0
  116. package/dist/presets/svelte-i18n.d.mts +5 -0
  117. package/dist/presets/svelte-i18n.mjs +33 -0
  118. package/dist/presets/svelte-i18next.d.mts +5 -0
  119. package/dist/presets/svelte-i18next.mjs +27 -0
  120. package/dist/presets/transloco.d.mts +5 -0
  121. package/dist/presets/transloco.mjs +44 -0
  122. package/dist/presets/typesafe-i18n.d.mts +6 -0
  123. package/dist/presets/typesafe-i18n.mjs +61 -0
  124. package/dist/presets/ui5.d.mts +5 -0
  125. package/dist/presets/ui5.mjs +35 -0
  126. package/dist/presets/vscode-extension.d.mts +5 -0
  127. package/dist/presets/vscode-extension.mjs +53 -0
  128. package/dist/presets/vue-i18n.d.mts +5 -0
  129. package/dist/presets/vue-i18n.mjs +59 -0
  130. package/dist/presets.d.mts +7 -54
  131. package/dist/presets.mjs +346 -1
  132. package/dist/reporters/github.d.mts +6 -0
  133. package/dist/reporters/github.mjs +27 -0
  134. package/dist/reporters/json.d.mts +6 -0
  135. package/dist/reporters/json.mjs +24 -0
  136. package/dist/reporters/markdown.d.mts +6 -0
  137. package/dist/reporters/markdown.mjs +37 -0
  138. package/dist/reporters/pretty.d.mts +6 -0
  139. package/dist/reporters/pretty.mjs +64 -0
  140. package/dist/reporters/sarif.d.mts +6 -0
  141. package/dist/reporters/sarif.mjs +48 -0
  142. package/dist/reporters.d.mts +5 -12
  143. package/dist/reporters.mjs +8 -218
  144. package/dist/scanners/astro.d.mts +6 -0
  145. package/dist/scanners/astro.mjs +256 -0
  146. package/dist/scanners/js.d.mts +6 -0
  147. package/dist/scanners/js.mjs +33 -0
  148. package/dist/scanners/regex-scopes.d.mts +14 -0
  149. package/dist/scanners/regex-scopes.mjs +41 -0
  150. package/dist/scanners/regex.d.mts +9 -0
  151. package/dist/{regex-B9TBGgXC.mjs → scanners/regex.mjs} +2 -33
  152. package/dist/scanners/svelte.d.mts +6 -0
  153. package/dist/{scanners-B27IEH4_.mjs → scanners/svelte.mjs} +8 -23
  154. package/dist/scanners/vue.d.mts +6 -0
  155. package/dist/scanners/vue.mjs +172 -0
  156. package/dist/scanners.d.mts +9 -47
  157. package/dist/scanners.mjs +36 -4
  158. package/dist/sfc-blocks-DaGKDZsb.mjs +213 -0
  159. package/dist/shared-BWaXUmwA.mjs +70 -0
  160. package/dist/shared-D-tbsYmc.mjs +30 -0
  161. package/dist/shared-D4NJBKEP.mjs +17 -0
  162. package/dist/shared-Tq06G0gp.mjs +6 -0
  163. package/dist/shared-meYeVckh.mjs +11 -0
  164. package/dist/vue-compiler-0sfLIiiL.mjs +8 -0
  165. package/package.json +67 -3
  166. package/dist/formats-CFkM5co0.mjs +0 -1370
  167. package/dist/presets-DJrGl3HR.mjs +0 -1184
  168. package/dist/sfc-blocks-BIPqKcvd.mjs +0 -161
  169. package/dist/yaml-plugin.d.mts +0 -8
  170. package/dist/yaml-plugin.mjs +0 -68
@@ -0,0 +1,53 @@
1
+ import { doubleBraces } from "../placeholders.mjs";
2
+ import { n as scriptExtensions } from "../shared-D4NJBKEP.mjs";
3
+ import { t as jsxTemplates } from "../jsx-templates-B1J0no3i.mjs";
4
+ import { createLibraryPlugin } from "@x18n/core";
5
+ //#region src/presets/next-translate/index.ts
6
+ function nextTranslate() {
7
+ return {
8
+ name: "next-translate",
9
+ plugins: [createLibraryPlugin({
10
+ name: "x18n:next-translate",
11
+ namespace: {
12
+ separator: ":",
13
+ default: "common"
14
+ },
15
+ calls: [
16
+ {
17
+ callee: "useTranslation",
18
+ factory: true,
19
+ returns: ["t"],
20
+ namespace: { arg: 0 }
21
+ },
22
+ {
23
+ callee: "getT",
24
+ factory: true,
25
+ returns: ["t"],
26
+ namespace: { arg: 1 }
27
+ },
28
+ {
29
+ callee: "Trans",
30
+ key: {
31
+ arg: 0,
32
+ property: "i18nKey"
33
+ },
34
+ namespace: {
35
+ arg: 0,
36
+ property: "ns"
37
+ }
38
+ },
39
+ { callee: "t" }
40
+ ],
41
+ regex: [{
42
+ extensions: scriptExtensions,
43
+ patterns: ["[^\\w\\d]t`({key})`"]
44
+ }],
45
+ resources: [{ pattern: "locales/{locale}/{namespace}.json" }],
46
+ keyStyle: "nested",
47
+ templates: jsxTemplates,
48
+ placeholders: [doubleBraces]
49
+ })]
50
+ };
51
+ }
52
+ //#endregion
53
+ export { nextTranslate as default, nextTranslate };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/ngx-translate/index.d.ts
3
+ export declare function ngxTranslate(): Preset;
4
+ //#endregion
5
+ export { ngxTranslate as default };
@@ -0,0 +1,41 @@
1
+ import { doubleBraces } from "../placeholders.mjs";
2
+ import { t as angularTemplates } from "../angular-templates-DqIOGfzT.mjs";
3
+ import { createLibraryPlugin } from "@x18n/core";
4
+ //#region src/presets/ngx-translate/index.ts
5
+ function ngxTranslate() {
6
+ return {
7
+ name: "ngx-translate",
8
+ plugins: [createLibraryPlugin({
9
+ name: "x18n:ngx-translate",
10
+ calls: [{ callee: [
11
+ "translate.instant",
12
+ "translate.get",
13
+ "translate.stream",
14
+ "translateService.instant",
15
+ "translateService.get",
16
+ "translateService.stream",
17
+ "_"
18
+ ] }],
19
+ regex: [{
20
+ extensions: angularTemplates,
21
+ patterns: [
22
+ "[`'\"]({key})[`'\"][\\s\\n]*\\|[\\s\\n]*translate\\b",
23
+ "[\\s\\n]translate>[\\s\\n]*({key})[\\s\\n]*</",
24
+ "\\[translate\\]=[\"']'({key})'[\"']",
25
+ "\\stranslate=[\"']({key})[\"']"
26
+ ]
27
+ }],
28
+ resources: [{ pattern: "src/assets/i18n/{locale}.json" }, { pattern: "src/assets/i18n/{locale}/{namespaces}.json" }],
29
+ templates: [{
30
+ template: "{{ '{key}' | translate }}",
31
+ kinds: ["html-text"]
32
+ }, {
33
+ template: "this.translate.instant('{key}'{args})",
34
+ kinds: ["js-string", "js-template"]
35
+ }],
36
+ placeholders: [doubleBraces]
37
+ })]
38
+ };
39
+ }
40
+ //#endregion
41
+ export { ngxTranslate as default, ngxTranslate };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/nuxt-i18n-micro/index.d.ts
3
+ export declare function nuxtI18nMicro(): Preset;
4
+ //#endregion
5
+ export { nuxtI18nMicro as default };
@@ -0,0 +1,81 @@
1
+ import { braces } from "../placeholders.mjs";
2
+ import { t as readNuxtConfig } from "../shared-Tq06G0gp.mjs";
3
+ import { createLibraryPlugin } from "@x18n/core";
4
+ //#region src/presets/nuxt-i18n-micro/index.ts
5
+ /** Nuxt's route name of a page component, which names its translation folder: `pages/products/[id].vue` is `products-id`. Route groups like `(admin)` are not part of it. */
6
+ function routeName(path) {
7
+ const segments = /^(?:app\/)?pages\/(.+)\.vue$/.exec(path)?.[1]?.split("/").filter((segment) => !/^\(.+\)$/.test(segment));
8
+ if (!segments?.length) return void 0;
9
+ if (segments.length > 1 && segments.at(-1) === "index") segments.pop();
10
+ return segments.join("-").replace(/[[\].]/g, "");
11
+ }
12
+ function nuxtI18nMicro() {
13
+ const returns = [
14
+ "$t",
15
+ "$ts",
16
+ "$tc",
17
+ "$has"
18
+ ];
19
+ return {
20
+ name: "nuxt-i18n-micro",
21
+ plugins: [createLibraryPlugin({
22
+ name: "x18n:nuxt-i18n-micro",
23
+ calls: [{ callee: returns }, {
24
+ callee: ["useI18n", "useNuxtApp"],
25
+ factory: true,
26
+ returns
27
+ }],
28
+ templates: [
29
+ {
30
+ template: "{{ $t('{key}'{args}) }}",
31
+ kinds: ["vue-template-text"]
32
+ },
33
+ {
34
+ template: ":{attr}=\"$t('{key}'{args})\"",
35
+ kinds: ["vue-attribute"]
36
+ },
37
+ {
38
+ template: "$t('{key}'{args})",
39
+ kinds: ["js-string", "js-template"],
40
+ files: ["**/*.vue"],
41
+ imports: ["import { useI18n } from '#imports'", "const { $t } = useI18n()"]
42
+ }
43
+ ],
44
+ extra: async (draft, ctx) => {
45
+ const nuxtConfig = await readNuxtConfig(ctx.host);
46
+ const dir = nuxtConfig && /translationDir:\s*['"]([^'"]+)['"]/.exec(nuxtConfig)?.[1]?.replace(/^\.\/|\/$/g, "") || "locales";
47
+ draft.resources = [
48
+ ...draft.resources,
49
+ { pattern: `${dir}/{locale}.json` },
50
+ { pattern: `${dir}/{namespaces}/{locale}.json` }
51
+ ];
52
+ },
53
+ placeholders: [{
54
+ ...braces,
55
+ implicit: ["count"]
56
+ }]
57
+ }), {
58
+ name: "x18n:nuxt-i18n-micro-pages",
59
+ scanners: [{
60
+ id: "nuxt-i18n-micro-pages",
61
+ extensions: ["vue"],
62
+ scan(file) {
63
+ const route = routeName(file.path);
64
+ return {
65
+ usages: [],
66
+ scopes: route ? [{
67
+ range: {
68
+ start: 0,
69
+ end: file.text.length
70
+ },
71
+ keyPrefix: `pages.${route}`,
72
+ optionalPrefix: true
73
+ }] : []
74
+ };
75
+ }
76
+ }]
77
+ }]
78
+ };
79
+ }
80
+ //#endregion
81
+ export { nuxtI18nMicro as default, nuxtI18nMicro };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/nuxt-i18n/index.d.ts
3
+ export declare function nuxtI18n(): Preset;
4
+ //#endregion
5
+ export { nuxtI18n as default };
@@ -0,0 +1,23 @@
1
+ import vueI18n from "./vue-i18n.mjs";
2
+ import { t as readNuxtConfig } from "../shared-Tq06G0gp.mjs";
3
+ //#region src/presets/nuxt-i18n/index.ts
4
+ function nuxtI18n() {
5
+ return {
6
+ name: "nuxt-i18n",
7
+ plugins: [...vueI18n().plugins, {
8
+ name: "x18n:nuxt-i18n",
9
+ async config(draft, ctx) {
10
+ const nuxtConfig = await readNuxtConfig(ctx.host);
11
+ const langDir = nuxtConfig ? /langDir:\s*['"]([^'"]+)['"]/.exec(nuxtConfig)?.[1]?.replace(/^\.\/|\/$/g, "") : void 0;
12
+ const dirs = langDir ? [`i18n/${langDir}`, langDir] : [
13
+ "i18n/locales",
14
+ "locales",
15
+ "lang"
16
+ ];
17
+ draft.resources = [...draft.resources, ...dirs.map((dir) => ({ pattern: `${dir}/{locale}.{ext}` }))];
18
+ }
19
+ }]
20
+ };
21
+ }
22
+ //#endregion
23
+ export { nuxtI18n as default, nuxtI18n };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/paraglide/index.d.ts
3
+ export declare function paraglide(): Preset;
4
+ //#endregion
5
+ export { paraglide as default };
@@ -0,0 +1,38 @@
1
+ import { braces } from "../placeholders.mjs";
2
+ import { n as scriptExtensions } from "../shared-D4NJBKEP.mjs";
3
+ import { createLibraryPlugin } from "@x18n/core";
4
+ //#region src/presets/paraglide/index.ts
5
+ function paraglide() {
6
+ return {
7
+ name: "paraglide",
8
+ plugins: [createLibraryPlugin({
9
+ name: "x18n:paraglide",
10
+ regex: [{
11
+ extensions: [
12
+ ...scriptExtensions,
13
+ "vue",
14
+ "svelte",
15
+ "astro"
16
+ ],
17
+ patterns: ["\\bm\\.({key})\\(", "\\bm\\[\\s*['\"`]({key})['\"`]\\s*\\]\\("]
18
+ }],
19
+ resources: [{ pattern: "messages/{locale}.json" }],
20
+ templates: [{
21
+ template: "{m.{key}({args})}",
22
+ kinds: [
23
+ "jsx-text",
24
+ "svelte-text",
25
+ "astro-text"
26
+ ],
27
+ imports: ["import { m } from '$lib/paraglide/messages'"]
28
+ }, {
29
+ template: "m.{key}({args})",
30
+ kinds: ["js-string", "js-template"],
31
+ imports: ["import { m } from '$lib/paraglide/messages'"]
32
+ }],
33
+ placeholders: [braces]
34
+ })]
35
+ };
36
+ }
37
+ //#endregion
38
+ export { paraglide as default, paraglide };
@@ -0,0 +1,6 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/php-gettext/index.d.ts
3
+ /** PHP gettext with `.po` files. Exclusive and never detected, as in i18n-ally: list it in `presets`. */
4
+ export declare function phpGettext(): Preset;
5
+ //#endregion
6
+ export { phpGettext as default };
@@ -0,0 +1,27 @@
1
+ import { printf } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/php-gettext/index.ts
4
+ /** PHP gettext with `.po` files. Exclusive and never detected, as in i18n-ally: list it in `presets`. */
5
+ function phpGettext() {
6
+ return {
7
+ name: "php-gettext",
8
+ plugins: [createLibraryPlugin({
9
+ name: "x18n:php-gettext",
10
+ regex: [{
11
+ extensions: ["php"],
12
+ patterns: ["[^\\w\\d](?:gettext|_|__)\\(\\s*['\"`]({key})['\"`]"]
13
+ }],
14
+ resources: [{ pattern: "locale/{locale}/LC_MESSAGES/*.po" }, { pattern: "locales/{locale}.po" }],
15
+ extra: (draft) => {
16
+ draft.extract = {
17
+ keygen: "source",
18
+ ...draft.extract
19
+ };
20
+ },
21
+ templates: [{ template: "gettext('{key}')" }],
22
+ placeholders: [printf]
23
+ })]
24
+ };
25
+ }
26
+ //#endregion
27
+ export { phpGettext as default, phpGettext };
@@ -0,0 +1,6 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/php-joomla/index.d.ts
3
+ /** Joomla: INI language files, `Text::_('KEY')`. */
4
+ export declare function phpJoomla(): Preset;
5
+ //#endregion
6
+ export { phpJoomla as default };
@@ -0,0 +1,22 @@
1
+ import { printf } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/php-joomla/index.ts
4
+ /** Joomla: INI language files, `Text::_('KEY')`. */
5
+ function phpJoomla() {
6
+ return {
7
+ name: "php-joomla",
8
+ plugins: [createLibraryPlugin({
9
+ name: "x18n:php-joomla",
10
+ regex: [{
11
+ extensions: ["php"],
12
+ patterns: ["J?Text::(?:_|[\\w]+)\\(\\s*['\"]({key})['\"]"]
13
+ }],
14
+ resources: [{ pattern: "language/{locale}/*.ini" }, { pattern: "administrator/language/{locale}/*.ini" }],
15
+ keyStyle: "flat",
16
+ templates: [{ template: "Text::_('{key}')" }],
17
+ placeholders: [printf]
18
+ })]
19
+ };
20
+ }
21
+ //#endregion
22
+ export { phpJoomla as default, phpJoomla };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/polyglot/index.d.ts
3
+ export declare function polyglot(): Preset;
4
+ //#endregion
5
+ export { polyglot as default };
@@ -0,0 +1,23 @@
1
+ import { percentBraces } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/polyglot/index.ts
4
+ function polyglot() {
5
+ return {
6
+ name: "polyglot",
7
+ plugins: [createLibraryPlugin({
8
+ name: "x18n:polyglot",
9
+ calls: [{ callee: ["polyglot.t", "I18n.t"] }],
10
+ regex: [{
11
+ extensions: ["rb"],
12
+ patterns: ["(?:polyglot|I18n)\\.t\\(\\s*['\"`]({key})['\"`]"]
13
+ }],
14
+ templates: [{
15
+ template: "polyglot.t('{key}'{args})",
16
+ kinds: ["js-string", "js-template"]
17
+ }],
18
+ placeholders: [percentBraces]
19
+ })]
20
+ };
21
+ }
22
+ //#endregion
23
+ export { polyglot as default, polyglot };
@@ -0,0 +1,6 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/python-gettext/index.d.ts
3
+ /** gettext in Python (Django, Flask-Babel, Babel): `.po` catalogs, `_()`, `gettext()`, `ngettext()` and Django `{% translate %}`. */
4
+ export declare function pythonGettext(): Preset;
5
+ //#endregion
6
+ export { pythonGettext as default };
@@ -0,0 +1,44 @@
1
+ import { pythonPercent } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/python-gettext/index.ts
4
+ const quoted = [String.raw`"([^"\\\n]+)"`, String.raw`'([^'\\\n]+)'`];
5
+ const gettextCall = String.raw`(?<!\w)(?:u?gettext(?:_lazy|_noop)?|lazy_gettext|u?ngettext(?:_lazy)?|lazy_ngettext|_l|_lazy|_)\(\s*`;
6
+ const gettextCalls = quoted.map((string) => String.raw`${gettextCall}${string}(?=\s*[,)])`);
7
+ const djangoTags = quoted.map((string) => String.raw`\{%\s*trans(?:late)?\s+${string}(?=\s*(?:noop\s*)?(?:as\s+\w+\s*)?%\})`);
8
+ /** gettext in Python (Django, Flask-Babel, Babel): `.po` catalogs, `_()`, `gettext()`, `ngettext()` and Django `{% translate %}`. */
9
+ function pythonGettext() {
10
+ return {
11
+ name: "python-gettext",
12
+ plugins: [createLibraryPlugin({
13
+ name: "x18n:python-gettext",
14
+ regex: [{
15
+ extensions: ["py"],
16
+ patterns: gettextCalls
17
+ }, {
18
+ extensions: [
19
+ "html",
20
+ "jinja",
21
+ "jinja2",
22
+ "j2"
23
+ ],
24
+ patterns: [...gettextCalls, ...djangoTags]
25
+ }],
26
+ resources: [
27
+ { pattern: "locale/{locale}/LC_MESSAGES/*.po" },
28
+ { pattern: "*/locale/{locale}/LC_MESSAGES/*.po" },
29
+ { pattern: "translations/{locale}/LC_MESSAGES/*.po" },
30
+ { pattern: "*/translations/{locale}/LC_MESSAGES/*.po" }
31
+ ],
32
+ extra: (draft) => {
33
+ draft.extract = {
34
+ keygen: "source",
35
+ ...draft.extract
36
+ };
37
+ },
38
+ templates: [{ template: "_(\"{key}\")" }],
39
+ placeholders: [pythonPercent]
40
+ })]
41
+ };
42
+ }
43
+ //#endregion
44
+ export { pythonGettext as default, pythonGettext };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/react-i18next/index.d.ts
3
+ export declare function reactI18next(): Preset;
4
+ //#endregion
5
+ export { reactI18next as default };
@@ -0,0 +1,67 @@
1
+ import { n as scriptExtensions } from "../shared-D4NJBKEP.mjs";
2
+ import regexScopes from "../scanners/regex-scopes.mjs";
3
+ import { t as i18nextPlugin } from "../plugin-Cb1b0axD.mjs";
4
+ import { createLibraryPlugin } from "@x18n/core";
5
+ //#region src/presets/react-i18next/index.ts
6
+ function reactI18next() {
7
+ return {
8
+ name: "react-i18next",
9
+ plugins: [
10
+ i18nextPlugin,
11
+ createLibraryPlugin({
12
+ name: "x18n:react-i18next",
13
+ calls: [
14
+ {
15
+ callee: "useTranslation",
16
+ factory: true,
17
+ returns: ["t"],
18
+ namespace: { arg: 0 },
19
+ keyPrefix: {
20
+ arg: 1,
21
+ property: "keyPrefix"
22
+ }
23
+ },
24
+ {
25
+ callee: "Trans",
26
+ key: {
27
+ arg: 0,
28
+ property: "i18nKey"
29
+ },
30
+ namespace: {
31
+ arg: 0,
32
+ property: "ns"
33
+ }
34
+ },
35
+ {
36
+ callee: "Translation",
37
+ factory: true,
38
+ returns: ["t"],
39
+ namespace: {
40
+ arg: 0,
41
+ property: "ns"
42
+ },
43
+ keyPrefix: {
44
+ arg: 0,
45
+ property: "keyPrefix"
46
+ }
47
+ }
48
+ ],
49
+ templates: [{
50
+ template: "<Trans i18nKey=\"{key}\" />",
51
+ kinds: ["jsx-text"],
52
+ imports: ["import { Trans } from 'react-i18next'"]
53
+ }, {
54
+ template: "{attr}={i18next.t('{key}'{args})}",
55
+ kinds: ["jsx-attribute"],
56
+ imports: ["import i18next from 'i18next'"]
57
+ }]
58
+ }),
59
+ regexScopes("\\bwithTranslation\\(\\s*(?:\\[?\\s*['\"`](?<namespace>[^'\"`]+)['\"`])?(?:[^)]*?\\bkeyPrefix\\s*:\\s*['\"`](?<keyPrefix>[^'\"`]+)['\"`])?", "react-i18next-hoc", {
60
+ wholeFile: true,
61
+ extensions: scriptExtensions
62
+ })
63
+ ]
64
+ };
65
+ }
66
+ //#endregion
67
+ export { reactI18next as default, reactI18next };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/react-intl/index.d.ts
3
+ export declare function reactIntl(): Preset;
4
+ //#endregion
5
+ export { reactIntl as default };
@@ -0,0 +1,47 @@
1
+ import { icu } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/react-intl/index.ts
4
+ function reactIntl() {
5
+ return {
6
+ name: "react-intl",
7
+ plugins: [createLibraryPlugin({
8
+ name: "x18n:react-intl",
9
+ calls: [{
10
+ callee: [
11
+ "intl.formatMessage",
12
+ "formatMessage",
13
+ "defineMessage",
14
+ "FormattedMessage"
15
+ ],
16
+ key: {
17
+ arg: 0,
18
+ property: "id"
19
+ }
20
+ }, {
21
+ callee: "defineMessages",
22
+ key: {
23
+ arg: 0,
24
+ property: "*.id"
25
+ }
26
+ }],
27
+ templates: [
28
+ {
29
+ template: "<FormattedMessage id=\"{key}\" />",
30
+ kinds: ["jsx-text"],
31
+ imports: ["import { FormattedMessage } from 'react-intl'"]
32
+ },
33
+ {
34
+ template: "{attr}={intl.formatMessage({ id: '{key}' }{args})}",
35
+ kinds: ["jsx-attribute"]
36
+ },
37
+ {
38
+ template: "intl.formatMessage({ id: '{key}' }{args})",
39
+ kinds: ["js-string", "js-template"]
40
+ }
41
+ ],
42
+ placeholders: [icu]
43
+ })]
44
+ };
45
+ }
46
+ //#endregion
47
+ export { reactIntl as default, reactIntl };
@@ -0,0 +1,7 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/ruby-rails/index.d.ts
3
+ export declare function rubyRails(): Preset;
4
+ /** `t('.title')` in `app/views/users/index.html.erb` means `users.index.title`. */
5
+ export declare function railsLazyKey(raw: string, path: string): string | undefined;
6
+ //#endregion
7
+ export { rubyRails as default };
@@ -0,0 +1,44 @@
1
+ import { percentBraces } from "../placeholders.mjs";
2
+ import { t as localeRoot } from "../locale-root-C_rch3IQ.mjs";
3
+ import { createLibraryPlugin } from "@x18n/core";
4
+ //#region src/presets/ruby-rails/index.ts
5
+ function rubyRails() {
6
+ return {
7
+ name: "ruby-rails",
8
+ plugins: [createLibraryPlugin({
9
+ name: "x18n:ruby-rails",
10
+ regex: [{
11
+ extensions: [
12
+ "rb",
13
+ "erb",
14
+ "haml",
15
+ "slim"
16
+ ],
17
+ patterns: [
18
+ "[^\\w\\d]t(?:\\(| )\\s*['\"`]({key})['\"`]",
19
+ "[^\\w\\d]t\\(:({key})\\)",
20
+ "I18n\\.t\\(\\s*['\"`]({key})['\"`]"
21
+ ]
22
+ }],
23
+ resources: [
24
+ { pattern: "config/locales/{locale}.yml" },
25
+ { pattern: "config/locales/**/*.{locale}.yml" },
26
+ { pattern: "config/locales/{locale}/**/*.yml" }
27
+ ],
28
+ normalizeKey: (raw, ctx) => railsLazyKey(raw, ctx.path),
29
+ transformResource: localeRoot((ctx) => /\.ya?ml$/.test(ctx.path)),
30
+ templates: [{ template: "t('{key}')" }],
31
+ placeholders: [percentBraces]
32
+ })]
33
+ };
34
+ }
35
+ const viewSuffix = /(?:\.html)?\.(?:erb|haml|slim)$/;
36
+ /** `t('.title')` in `app/views/users/index.html.erb` means `users.index.title`. */
37
+ function railsLazyKey(raw, path) {
38
+ if (!raw.startsWith(".")) return void 0;
39
+ const match = /(?:^|\/)app\/views\/(.+)$/.exec(path);
40
+ if (!match) return void 0;
41
+ return `${match[1].replace(viewSuffix, "").split("/").map((segment) => segment.replace(/^_/, "")).join(".")}${raw}`;
42
+ }
43
+ //#endregion
44
+ export { rubyRails as default, rubyRails, railsLazyKey };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/solid-primitives-i18n/index.d.ts
3
+ export declare function solidPrimitivesI18n(): Preset;
4
+ //#endregion
5
+ export { solidPrimitivesI18n as default };
@@ -0,0 +1,29 @@
1
+ import { doubleBraces } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/solid-primitives-i18n/index.ts
4
+ function solidPrimitivesI18n() {
5
+ return {
6
+ name: "solid-primitives-i18n",
7
+ plugins: [createLibraryPlugin({
8
+ name: "x18n:solid-primitives-i18n",
9
+ calls: [{ callee: ["t", "i18n.t"] }],
10
+ templates: [
11
+ {
12
+ template: "{t('{key}'{args})}",
13
+ kinds: ["jsx-text"]
14
+ },
15
+ {
16
+ template: "{attr}={t('{key}'{args})}",
17
+ kinds: ["jsx-attribute"]
18
+ },
19
+ {
20
+ template: "t('{key}'{args})",
21
+ kinds: ["js-string", "js-template"]
22
+ }
23
+ ],
24
+ placeholders: [doubleBraces]
25
+ })]
26
+ };
27
+ }
28
+ //#endregion
29
+ export { solidPrimitivesI18n as default, solidPrimitivesI18n };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/svelte-i18n/index.d.ts
3
+ export declare function svelteI18n(): Preset;
4
+ //#endregion
5
+ export { svelteI18n as default };