@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,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 };
@@ -0,0 +1,33 @@
1
+ import { icu } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/svelte-i18n/index.ts
4
+ function svelteI18n() {
5
+ return {
6
+ name: "svelte-i18n",
7
+ plugins: [createLibraryPlugin({
8
+ name: "x18n:svelte-i18n",
9
+ calls: [{ callee: [
10
+ "$_",
11
+ "$t",
12
+ "$format",
13
+ "_",
14
+ "t",
15
+ "format",
16
+ "$json",
17
+ "json"
18
+ ] }],
19
+ templates: [{
20
+ template: "{$_('{key}'{args})}",
21
+ kinds: ["svelte-text"],
22
+ imports: ["import { _ } from 'svelte-i18n'"]
23
+ }, {
24
+ template: "{attr}={$_('{key}'{args})}",
25
+ kinds: ["svelte-attribute"],
26
+ imports: ["import { _ } from 'svelte-i18n'"]
27
+ }],
28
+ placeholders: [icu]
29
+ })]
30
+ };
31
+ }
32
+ //#endregion
33
+ export { svelteI18n as default, svelteI18n };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/svelte-i18next/index.d.ts
3
+ export declare function svelteI18next(): Preset;
4
+ //#endregion
5
+ export { svelteI18next as default };
@@ -0,0 +1,27 @@
1
+ import { t as i18nextPlugin } from "../plugin-Cb1b0axD.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/svelte-i18next/index.ts
4
+ function svelteI18next() {
5
+ return {
6
+ name: "svelte-i18next",
7
+ plugins: [i18nextPlugin, createLibraryPlugin({
8
+ name: "x18n:svelte-i18next",
9
+ calls: [{
10
+ callee: "$i18n.t",
11
+ namespace: {
12
+ arg: 1,
13
+ property: "ns"
14
+ }
15
+ }],
16
+ templates: [{
17
+ template: "{$i18n.t('{key}'{args})}",
18
+ kinds: ["svelte-text"]
19
+ }, {
20
+ template: "{attr}={$i18n.t('{key}'{args})}",
21
+ kinds: ["svelte-attribute"]
22
+ }]
23
+ })]
24
+ };
25
+ }
26
+ //#endregion
27
+ export { svelteI18next as default, svelteI18next };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/transloco/index.d.ts
3
+ export declare function transloco(): Preset;
4
+ //#endregion
5
+ export { transloco as default };
@@ -0,0 +1,44 @@
1
+ import { doubleBraces } from "../placeholders.mjs";
2
+ import regexScopes from "../scanners/regex-scopes.mjs";
3
+ import { t as angularTemplates } from "../angular-templates-DqIOGfzT.mjs";
4
+ import { createLibraryPlugin } from "@x18n/core";
5
+ //#region src/presets/transloco/index.ts
6
+ function transloco() {
7
+ return {
8
+ name: "transloco",
9
+ plugins: [createLibraryPlugin({
10
+ name: "x18n:transloco",
11
+ namespace: { fromPath: "camel" },
12
+ calls: [{ callee: [
13
+ "translate",
14
+ "translocoService.translate",
15
+ "transloco.translate",
16
+ "translocoService.selectTranslate",
17
+ "transloco.selectTranslate"
18
+ ] }],
19
+ regex: [{
20
+ extensions: angularTemplates,
21
+ patterns: [
22
+ "[`'\"]({key})[`'\"][\\s\\n]*\\|[\\s\\n]*transloco\\b",
23
+ "[^\\w\\d]t\\([\\s\\n]*['\"`]({key})['\"`]",
24
+ "[^*\\w\\d]transloco=['\"`]({key})['\"`]"
25
+ ]
26
+ }],
27
+ resources: [{ pattern: "src/assets/i18n/{locale}.json" }, { pattern: "src/assets/i18n/{namespaces}/{locale}.json" }],
28
+ templates: [{
29
+ template: "{{ '{key}' | transloco }}",
30
+ kinds: ["html-text"]
31
+ }, {
32
+ template: "translate('{key}'{args})",
33
+ kinds: ["js-string", "js-template"],
34
+ imports: ["import { translate } from '@jsverse/transloco'"]
35
+ }],
36
+ placeholders: [doubleBraces]
37
+ }), regexScopes("\\*transloco=\"[^\"]*read:\\s*'([^']+)'", "transloco-read", {
38
+ as: "keyPrefix",
39
+ extensions: ["html"]
40
+ })]
41
+ };
42
+ }
43
+ //#endregion
44
+ export { transloco as default, transloco };
@@ -0,0 +1,6 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/typesafe-i18n/index.d.ts
3
+ /** Usage regex and resource layout after lokalise/i18n-ally#681. */
4
+ export declare function typesafeI18n(): Preset;
5
+ //#endregion
6
+ export { typesafeI18n as default };
@@ -0,0 +1,61 @@
1
+ import { typedBraces } from "../placeholders.mjs";
2
+ import { n as scriptExtensions } from "../shared-D4NJBKEP.mjs";
3
+ import { createLibraryPlugin } from "@x18n/core";
4
+ //#region src/presets/typesafe-i18n/index.ts
5
+ /** Usage regex and resource layout after lokalise/i18n-ally#681. */
6
+ function typesafeI18n() {
7
+ return {
8
+ name: "typesafe-i18n",
9
+ plugins: [createLibraryPlugin({
10
+ name: "x18n:typesafe-i18n",
11
+ regex: [{
12
+ extensions: [
13
+ ...scriptExtensions,
14
+ "vue",
15
+ "svelte"
16
+ ],
17
+ patterns: ["\\bLL\\.({key})\\("]
18
+ }],
19
+ resources: [{ pattern: "src/i18n/{locale}/index.{ext}" }, { pattern: "src/i18n/{locale}/{namespace}/index.{ext}" }],
20
+ keyStyle: "nested",
21
+ templates: [
22
+ {
23
+ template: "{$LL.{key}({args})}",
24
+ kinds: ["svelte-text"]
25
+ },
26
+ {
27
+ template: "{attr}={$LL.{key}({args})}",
28
+ kinds: ["svelte-attribute"]
29
+ },
30
+ {
31
+ template: "$LL.{key}({args})",
32
+ kinds: ["js-string", "js-template"],
33
+ files: ["**/*.svelte"]
34
+ },
35
+ {
36
+ template: "{{ LL.{key}({args}) }}",
37
+ kinds: ["vue-template-text"]
38
+ },
39
+ {
40
+ template: ":{attr}=\"LL.{key}({args})\"",
41
+ kinds: ["vue-attribute"]
42
+ },
43
+ {
44
+ template: "{LL.{key}({args})}",
45
+ kinds: ["jsx-text"]
46
+ },
47
+ {
48
+ template: "{attr}={LL.{key}({args})}",
49
+ kinds: ["jsx-attribute"]
50
+ },
51
+ {
52
+ template: "LL.{key}({args})",
53
+ kinds: ["js-string", "js-template"]
54
+ }
55
+ ],
56
+ placeholders: [typedBraces]
57
+ })]
58
+ };
59
+ }
60
+ //#endregion
61
+ export { typesafeI18n as default, typesafeI18n };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/ui5/index.d.ts
3
+ export declare function ui5(): Preset;
4
+ //#endregion
5
+ export { ui5 as default };
@@ -0,0 +1,35 @@
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/ui5/index.ts
5
+ function ui5() {
6
+ return {
7
+ name: "ui5",
8
+ plugins: [createLibraryPlugin({
9
+ name: "x18n:ui5",
10
+ regex: [{
11
+ extensions: [
12
+ "xml",
13
+ "json",
14
+ ...scriptExtensions
15
+ ],
16
+ patterns: ["\\{i18n>({key})\\}"]
17
+ }, {
18
+ extensions: scriptExtensions,
19
+ patterns: ["getResourceBundle\\(\\)\\.getText\\(\\s*['\"`]({key})['\"`]"]
20
+ }],
21
+ resources: [{ pattern: "webapp/i18n/i18n_{locale}.properties" }, { pattern: "webapp/i18n/i18n.properties" }],
22
+ keyStyle: "flat",
23
+ templates: [{
24
+ template: "{i18n>{key}}",
25
+ files: ["**/*.xml"]
26
+ }, {
27
+ template: "this.getResourceBundle().getText('{key}')",
28
+ kinds: ["js-string", "js-template"]
29
+ }],
30
+ placeholders: [braces]
31
+ })]
32
+ };
33
+ }
34
+ //#endregion
35
+ export { ui5 as default, ui5 };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/vscode-extension/index.d.ts
3
+ export declare function vscodeExtension(): Preset;
4
+ //#endregion
5
+ export { vscodeExtension as default };
@@ -0,0 +1,53 @@
1
+ import { braces } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/vscode-extension/nls.ts
4
+ const nlsFile = /^(?:(.*)\/)?package\.nls(?:\.([\w-]+))?\.json$/;
5
+ const bundleFile = /^(?:(.*)\/)?bundle\.l10n(?:\.([\w-]+))?\.json$/;
6
+ /** VS Code extension strings: `package.nls[.locale].json` and `l10n/bundle.l10n[.locale].json`. */
7
+ const nlsFinder = {
8
+ id: "nls",
9
+ async find(ctx) {
10
+ const paths = await ctx.host.glob(["**/package.nls*.json", "**/bundle.l10n*.json"], {
11
+ ignore: ["**/node_modules/**"],
12
+ gitignore: true
13
+ });
14
+ const out = [];
15
+ for (const path of paths) {
16
+ const nls = nlsFile.exec(path);
17
+ const bundle = nls ? void 0 : bundleFile.exec(path);
18
+ const match = nls ?? bundle;
19
+ if (!match) continue;
20
+ out.push({
21
+ path,
22
+ locale: match[2] ?? ctx.config.sourceLocale,
23
+ namespace: void 0,
24
+ format: "json"
25
+ });
26
+ }
27
+ return out;
28
+ }
29
+ };
30
+ //#endregion
31
+ //#region src/presets/vscode-extension/index.ts
32
+ function vscodeExtension() {
33
+ return {
34
+ name: "vscode-extension",
35
+ plugins: [createLibraryPlugin({
36
+ name: "x18n:vscode-extension",
37
+ calls: [{ callee: ["l10n.t", "vscode.l10n.t"] }],
38
+ finders: [nlsFinder],
39
+ extra: (draft) => {
40
+ draft.usage = {
41
+ ...draft.usage,
42
+ regex: [...draft.usage.regex, {
43
+ extensions: ["json"],
44
+ patterns: ["\"%({key})%\""]
45
+ }]
46
+ };
47
+ },
48
+ placeholders: [braces]
49
+ })]
50
+ };
51
+ }
52
+ //#endregion
53
+ export { vscodeExtension as default, vscodeExtension };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/vue-i18n/index.d.ts
3
+ export declare function vueI18n(): Preset;
4
+ //#endregion
5
+ export { vueI18n as default };
@@ -0,0 +1,59 @@
1
+ import { t as sfcBlocks } from "../sfc-blocks-DaGKDZsb.mjs";
2
+ import { braces, linked } from "../placeholders.mjs";
3
+ import { createLibraryPlugin } from "@x18n/core";
4
+ //#region src/presets/vue-i18n/index.ts
5
+ const vueI18nCalls = [{ callee: [
6
+ "$t",
7
+ "t",
8
+ "tc",
9
+ "$tc",
10
+ "te",
11
+ "$te",
12
+ "tm",
13
+ "$tm",
14
+ "i18n.t",
15
+ "i18n.global.t",
16
+ "$i18n.t",
17
+ "i18n.tc",
18
+ "i18n.te"
19
+ ] }, {
20
+ callee: "useI18n",
21
+ factory: true,
22
+ returns: [
23
+ "t",
24
+ "tc",
25
+ "te",
26
+ "tm"
27
+ ]
28
+ }];
29
+ function vueI18n() {
30
+ return {
31
+ name: "vue-i18n",
32
+ plugins: [createLibraryPlugin({
33
+ name: "x18n:vue-i18n",
34
+ calls: vueI18nCalls,
35
+ templates: [
36
+ {
37
+ template: "{{ $t('{key}'{args}) }}",
38
+ kinds: ["vue-template-text"]
39
+ },
40
+ {
41
+ template: ":{attr}=\"$t('{key}'{args})\"",
42
+ kinds: ["vue-attribute"]
43
+ },
44
+ {
45
+ template: "t('{key}'{args})",
46
+ kinds: ["js-string", "js-template"],
47
+ files: ["**/*.vue"],
48
+ imports: ["import { useI18n } from 'vue-i18n'", "const { t } = useI18n()"]
49
+ }
50
+ ],
51
+ placeholders: [{
52
+ ...braces,
53
+ implicit: ["n", "count"]
54
+ }, linked]
55
+ }), sfcBlocks()]
56
+ };
57
+ }
58
+ //#endregion
59
+ export { vueI18n as default, vueI18n };
@@ -1,60 +1,13 @@
1
- import { Preset, PresetFactory } from "@x18n/core";
2
- //#region src/presets/angular.d.ts
3
- export declare function ngxTranslate(): Preset;
4
- export declare function transloco(): Preset;
5
- //#endregion
6
- //#region src/presets/js.d.ts
7
- export declare function vueI18n(): Preset;
8
- export declare function nuxtI18n(): Preset;
9
- export declare function i18next(): Preset;
10
- export declare function reactI18next(): Preset;
11
- export declare function nextIntl(): Preset;
12
- export declare function reactIntl(): Preset;
13
- export declare function svelteI18n(): Preset;
14
- export declare function vscodeExtension(): Preset;
15
- /** Always last: hard-string extraction templates for plain JS, TS and HTML. */
16
- export declare function general(): Preset;
17
- //#endregion
18
- //#region src/presets/mobile.d.ts
19
- /** Flutter with `flutter_i18n`: JSON or YAML assets, `FlutterI18n.translate(context, 'key')`. */
20
- export declare function flutter(): Preset;
21
- //#endregion
22
- //#region src/presets/server.d.ts
23
- /** Laravel: `lang/{locale}/{file}.php` arrays and `lang/{locale}.json`; keys are `file.key`. Exclusive like i18n-ally. */
24
- export declare function laravel(): Preset;
25
- /** Joomla: INI language files, `Text::_('KEY')`. */
26
- export declare function phpJoomla(): Preset;
27
- /** PHP gettext with `.po` files. Exclusive and never detected, as in i18n-ally: list it in `presets`. */
28
- export declare function phpGettext(): Preset;
29
- /** `t('.title')` in `app/views/users/index.html.erb` means `users.index.title`. */
30
- export declare function railsLazyKey(raw: string, path: string): string | undefined;
31
- export declare function rubyRails(): Preset;
32
- export declare function jekyll(): Preset;
33
- //#endregion
34
- //#region src/presets/web.d.ts
35
- export declare function nextInternational(): Preset;
36
- export declare function nextTranslate(): Preset;
37
- /** Shopify's i18next format: plural and ordinal forms as nested keys (`{key}.one`). */
38
- export declare function i18nextShopify(): Preset;
39
- export declare function i18nTag(): Preset;
40
- export declare function fluentVue(): Preset;
41
- export declare function polyglot(): Preset;
42
- export declare function globalize(): Preset;
43
- export declare function ui5(): Preset;
44
- export declare function lingui(): Preset;
45
- export declare function emberIntl(): Preset;
46
- export declare function i18nJs(): Preset;
47
- /** Chrome and WebExtension `_locales/{locale}/messages.json`: `{ "name": { "message": "..." } }` reads as `name`. */
48
- export declare function chromeExtension(): Preset;
49
- export declare function solidPrimitivesI18n(): Preset;
50
- export declare function paraglide(): Preset;
51
- //#endregion
1
+ import { PresetEntry } from "@x18n/core";
52
2
  //#region src/presets/index.d.ts
53
3
  /**
54
- * Presets by name, in detection order: every i18n-ally framework has one.
55
- * Presets that share plugins (react-i18next and i18next) apply them once.
4
+ * Built-in presets by name, in detection order: every i18n-ally framework has one.
5
+ * A preset is a folder. `<name>/entry.ts` holds its detection and a `load` for `<name>/index.ts`,
6
+ * the preset itself; it is cheap and always loaded, while the preset is imported only when detection passes
7
+ * or the config lists it.
8
+ * Presets that share plugins (react-i18next, svelte-i18next and i18next) apply them once.
56
9
  */
57
10
  export declare const presets: {
58
- readonly [name: string]: PresetFactory;
11
+ readonly [name: string]: PresetEntry;
59
12
  };
60
13
  //#endregion