@x18n/builtins 0.0.13 → 0.0.15

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 (173) hide show
  1. package/dist/angular-templates-DqIOGfzT.mjs +8 -0
  2. package/dist/checks.d.mts +1 -0
  3. package/dist/checks.mjs +26 -1
  4. package/dist/extractors.mjs +7 -3
  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 +232 -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 +143 -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 +198 -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 +140 -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 +30 -22
  33. package/dist/{vue-CF4pe-Yr.mjs → js-CV-ECNJG.mjs} +67 -222
  34. package/dist/json-CGNSGS97.mjs +109 -0
  35. package/dist/json-CyjI8bjp.d.mts +8 -0
  36. package/dist/jsx-templates-B1J0no3i.mjs +17 -0
  37. package/dist/literal-gIdB1VGy.mjs +125 -0
  38. package/dist/locale-root-C_rch3IQ.mjs +15 -0
  39. package/dist/manifests.d.mts +8 -0
  40. package/dist/manifests.mjs +66 -2
  41. package/dist/placeholders.d.mts +11 -0
  42. package/dist/placeholders.mjs +28 -1
  43. package/dist/plugin-Cb1b0axD.mjs +83 -0
  44. package/dist/plural-forms-B7_QX4nG.mjs +12 -0
  45. package/dist/presets/cargo-i18n.d.mts +6 -0
  46. package/dist/presets/cargo-i18n.mjs +28 -0
  47. package/dist/presets/chrome-extension.d.mts +6 -0
  48. package/dist/presets/chrome-extension.mjs +52 -0
  49. package/dist/presets/dotnet-resx.d.mts +6 -0
  50. package/dist/presets/dotnet-resx.mjs +64 -0
  51. package/dist/presets/easy-localization.d.mts +6 -0
  52. package/dist/presets/easy-localization.mjs +36 -0
  53. package/dist/presets/ember-intl.d.mts +5 -0
  54. package/dist/presets/ember-intl.mjs +31 -0
  55. package/dist/presets/fluent-react.d.mts +5 -0
  56. package/dist/presets/fluent-react.mjs +46 -0
  57. package/dist/presets/fluent-vue.d.mts +5 -0
  58. package/dist/presets/fluent-vue.mjs +51 -0
  59. package/dist/presets/flutter-translate.d.mts +6 -0
  60. package/dist/presets/flutter-translate.mjs +30 -0
  61. package/dist/presets/flutter.d.mts +6 -0
  62. package/dist/presets/flutter.mjs +21 -0
  63. package/dist/presets/general.d.mts +6 -0
  64. package/dist/presets/general.mjs +17 -0
  65. package/dist/presets/globalize.d.mts +5 -0
  66. package/dist/presets/globalize.mjs +25 -0
  67. package/dist/presets/gravity-ui-i18n.d.mts +6 -0
  68. package/dist/presets/gravity-ui-i18n.mjs +41 -0
  69. package/dist/presets/i18n-tag.d.mts +5 -0
  70. package/dist/presets/i18n-tag.mjs +21 -0
  71. package/dist/presets/i18next-shopify.d.mts +6 -0
  72. package/dist/presets/i18next-shopify.mjs +23 -0
  73. package/dist/presets/i18next.d.mts +5 -0
  74. package/dist/presets/i18next.mjs +10 -0
  75. package/dist/presets/i18nice.d.mts +6 -0
  76. package/dist/presets/i18nice.mjs +29 -0
  77. package/dist/presets/jekyll.d.mts +5 -0
  78. package/dist/presets/jekyll.mjs +23 -0
  79. package/dist/presets/laravel-vue-i18n.d.mts +6 -0
  80. package/dist/presets/laravel-vue-i18n.mjs +54 -0
  81. package/dist/presets/laravel.d.mts +6 -0
  82. package/dist/presets/laravel.mjs +23 -0
  83. package/dist/presets/lingui.d.mts +5 -0
  84. package/dist/presets/lingui.mjs +61 -0
  85. package/dist/presets/next-international.d.mts +5 -0
  86. package/dist/presets/next-international.mjs +27 -0
  87. package/dist/presets/next-intl.d.mts +5 -0
  88. package/dist/presets/next-intl.mjs +55 -0
  89. package/dist/presets/next-translate.d.mts +5 -0
  90. package/dist/presets/next-translate.mjs +53 -0
  91. package/dist/presets/ngx-translate.d.mts +5 -0
  92. package/dist/presets/ngx-translate.mjs +41 -0
  93. package/dist/presets/nuxt-i18n-micro.d.mts +5 -0
  94. package/dist/presets/nuxt-i18n-micro.mjs +81 -0
  95. package/dist/presets/nuxt-i18n.d.mts +5 -0
  96. package/dist/presets/nuxt-i18n.mjs +23 -0
  97. package/dist/presets/paraglide.d.mts +5 -0
  98. package/dist/presets/paraglide.mjs +38 -0
  99. package/dist/presets/php-gettext.d.mts +6 -0
  100. package/dist/presets/php-gettext.mjs +27 -0
  101. package/dist/presets/php-joomla.d.mts +6 -0
  102. package/dist/presets/php-joomla.mjs +22 -0
  103. package/dist/presets/polyglot.d.mts +5 -0
  104. package/dist/presets/polyglot.mjs +23 -0
  105. package/dist/presets/python-gettext.d.mts +6 -0
  106. package/dist/presets/python-gettext.mjs +44 -0
  107. package/dist/presets/react-i18next.d.mts +5 -0
  108. package/dist/presets/react-i18next.mjs +67 -0
  109. package/dist/presets/react-intl.d.mts +5 -0
  110. package/dist/presets/react-intl.mjs +47 -0
  111. package/dist/presets/ruby-i18n-js.d.mts +5 -0
  112. package/dist/presets/ruby-i18n-js.mjs +19 -0
  113. package/dist/presets/ruby-rails.d.mts +7 -0
  114. package/dist/presets/ruby-rails.mjs +44 -0
  115. package/dist/presets/solid-primitives-i18n.d.mts +5 -0
  116. package/dist/presets/solid-primitives-i18n.mjs +29 -0
  117. package/dist/presets/svelte-i18n.d.mts +5 -0
  118. package/dist/presets/svelte-i18n.mjs +33 -0
  119. package/dist/presets/svelte-i18next.d.mts +5 -0
  120. package/dist/presets/svelte-i18next.mjs +27 -0
  121. package/dist/presets/transloco.d.mts +5 -0
  122. package/dist/presets/transloco.mjs +44 -0
  123. package/dist/presets/typesafe-i18n.d.mts +6 -0
  124. package/dist/presets/typesafe-i18n.mjs +61 -0
  125. package/dist/presets/ui5.d.mts +5 -0
  126. package/dist/presets/ui5.mjs +35 -0
  127. package/dist/presets/vscode-extension.d.mts +5 -0
  128. package/dist/presets/vscode-extension.mjs +53 -0
  129. package/dist/presets/vue-i18n.d.mts +5 -0
  130. package/dist/presets/vue-i18n.mjs +59 -0
  131. package/dist/presets.d.mts +7 -54
  132. package/dist/presets.mjs +346 -1
  133. package/dist/reporters/github.d.mts +6 -0
  134. package/dist/reporters/github.mjs +27 -0
  135. package/dist/reporters/json.d.mts +6 -0
  136. package/dist/reporters/json.mjs +24 -0
  137. package/dist/reporters/markdown.d.mts +6 -0
  138. package/dist/reporters/markdown.mjs +37 -0
  139. package/dist/reporters/pretty.d.mts +6 -0
  140. package/dist/reporters/pretty.mjs +64 -0
  141. package/dist/reporters/sarif.d.mts +6 -0
  142. package/dist/reporters/sarif.mjs +48 -0
  143. package/dist/reporters.d.mts +5 -12
  144. package/dist/reporters.mjs +8 -218
  145. package/dist/reviews.d.mts +6 -0
  146. package/dist/reviews.mjs +35 -0
  147. package/dist/scanners/astro.d.mts +6 -0
  148. package/dist/scanners/astro.mjs +256 -0
  149. package/dist/scanners/js.d.mts +6 -0
  150. package/dist/scanners/js.mjs +33 -0
  151. package/dist/scanners/regex-scopes.d.mts +14 -0
  152. package/dist/scanners/regex-scopes.mjs +41 -0
  153. package/dist/scanners/regex.d.mts +9 -0
  154. package/dist/{regex-AYVhuSb6.mjs → scanners/regex.mjs} +2 -40
  155. package/dist/scanners/svelte.d.mts +6 -0
  156. package/dist/{scanners-DhnnVp7s.mjs → scanners/svelte.mjs} +3 -3
  157. package/dist/scanners/vue.d.mts +6 -0
  158. package/dist/scanners/vue.mjs +172 -0
  159. package/dist/scanners.d.mts +9 -50
  160. package/dist/scanners.mjs +36 -4
  161. package/dist/sfc-blocks-DaGKDZsb.mjs +213 -0
  162. package/dist/shared-C7ceptwi.mjs +55 -0
  163. package/dist/shared-D-tbsYmc.mjs +30 -0
  164. package/dist/shared-D4NJBKEP.mjs +17 -0
  165. package/dist/shared-Tq06G0gp.mjs +6 -0
  166. package/dist/shared-meYeVckh.mjs +11 -0
  167. package/dist/vue-compiler-0sfLIiiL.mjs +8 -0
  168. package/package.json +68 -3
  169. package/dist/formats-CFkM5co0.mjs +0 -1370
  170. package/dist/presets-Co5SlnKr.mjs +0 -1187
  171. package/dist/sfc-blocks-BqQ8m9rX.mjs +0 -161
  172. package/dist/yaml-plugin.d.mts +0 -8
  173. package/dist/yaml-plugin.mjs +0 -68
@@ -0,0 +1,27 @@
1
+ import { braces } from "../placeholders.mjs";
2
+ import { t as jsxTemplates } from "../jsx-templates-B1J0no3i.mjs";
3
+ import { createLibraryPlugin } from "@x18n/core";
4
+ //#region src/presets/next-international/index.ts
5
+ function nextInternational() {
6
+ return {
7
+ name: "next-international",
8
+ plugins: [createLibraryPlugin({
9
+ name: "x18n:next-international",
10
+ calls: [{
11
+ callee: ["useI18n", "getI18n"],
12
+ factory: true,
13
+ returns: ["t"]
14
+ }, {
15
+ callee: ["useScopedI18n", "getScopedI18n"],
16
+ factory: true,
17
+ returns: ["t"],
18
+ keyPrefix: { arg: 0 }
19
+ }],
20
+ resources: [{ pattern: "locales/{locale}.{ext}" }, { pattern: "src/locales/{locale}.{ext}" }],
21
+ templates: jsxTemplates,
22
+ placeholders: [braces]
23
+ })]
24
+ };
25
+ }
26
+ //#endregion
27
+ export { nextInternational as default, nextInternational };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/next-intl/index.d.ts
3
+ export declare function nextIntl(): Preset;
4
+ //#endregion
5
+ export { nextIntl as default };
@@ -0,0 +1,55 @@
1
+ import { icu } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/next-intl/index.ts
4
+ function nextIntl() {
5
+ return {
6
+ name: "next-intl",
7
+ plugins: [createLibraryPlugin({
8
+ name: "x18n:next-intl",
9
+ calls: [{
10
+ callee: ["useTranslations", "getTranslations"],
11
+ factory: true,
12
+ returns: [
13
+ "t",
14
+ "t.rich",
15
+ "t.markup",
16
+ "t.raw",
17
+ "t.has"
18
+ ],
19
+ keyPrefix: { arg: 0 }
20
+ }, {
21
+ callee: "getTranslations",
22
+ factory: true,
23
+ returns: [
24
+ "t",
25
+ "t.rich",
26
+ "t.markup",
27
+ "t.raw",
28
+ "t.has"
29
+ ],
30
+ keyPrefix: {
31
+ arg: 0,
32
+ property: "namespace"
33
+ }
34
+ }],
35
+ resources: [{ pattern: "messages/{locale}.json" }, { pattern: "src/messages/{locale}.json" }],
36
+ templates: [
37
+ {
38
+ template: "{t('{key}'{args})}",
39
+ kinds: ["jsx-text"]
40
+ },
41
+ {
42
+ template: "{attr}={t('{key}'{args})}",
43
+ kinds: ["jsx-attribute"]
44
+ },
45
+ {
46
+ template: "t('{key}'{args})",
47
+ kinds: ["js-string", "js-template"]
48
+ }
49
+ ],
50
+ placeholders: [icu]
51
+ })]
52
+ };
53
+ }
54
+ //#endregion
55
+ export { nextIntl as default, nextIntl };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/next-translate/index.d.ts
3
+ export declare function nextTranslate(): Preset;
4
+ //#endregion
5
+ export { nextTranslate as default };
@@ -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,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/ruby-i18n-js/index.d.ts
3
+ export declare function rubyI18nJs(): Preset;
4
+ //#endregion
5
+ export { rubyI18nJs as default };
@@ -0,0 +1,19 @@
1
+ import { percentBraces } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/ruby-i18n-js/index.ts
4
+ function rubyI18nJs() {
5
+ return {
6
+ name: "ruby-i18n-js",
7
+ plugins: [createLibraryPlugin({
8
+ name: "x18n:ruby-i18n-js",
9
+ calls: [{ callee: ["I18n.t", "i18n.t"] }],
10
+ templates: [{
11
+ template: "i18n.t('{key}'{args})",
12
+ kinds: ["js-string", "js-template"]
13
+ }],
14
+ placeholders: [percentBraces]
15
+ })]
16
+ };
17
+ }
18
+ //#endregion
19
+ export { rubyI18nJs as default, rubyI18nJs };