@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
@@ -1,1187 +0,0 @@
1
- import { defaultTemplates } from "./extractors.mjs";
2
- import { n as sfcFluentBlocks, t as sfcBlocks } from "./sfc-blocks-BqQ8m9rX.mjs";
3
- import { braces, colon, dollars, doubleBraces, fluent, icu, linked, nesting, percentBraces, placeholders, printf } from "./placeholders.mjs";
4
- import { r as regexScopes } from "./regex-AYVhuSb6.mjs";
5
- import { isMessageLeaf } from "@x18n/core";
6
- //#region src/presets/shared.ts
7
- /** One plugin holding a library's call specs, regexes, namespace rules, defaults and extraction templates. */
8
- function library(options) {
9
- return {
10
- name: `x18n:${options.name}`,
11
- async config(draft, ctx) {
12
- if (options.namespace) draft.namespace = {
13
- separator: options.namespace.separator ?? draft.namespace.separator,
14
- default: draft.namespace.default ?? options.namespace.default,
15
- fromPath: options.namespace.fromPath ?? draft.namespace.fromPath
16
- };
17
- if (options.resources) draft.resources = [...draft.resources, ...options.resources.filter((spec) => !draft.resources.some((r) => r.pattern === spec.pattern))];
18
- if (options.keyStyle && draft.keyStyle === "auto" && !ctx.user.keyStyle) draft.keyStyle = options.keyStyle;
19
- draft.usage = {
20
- ...draft.usage,
21
- calls: [...draft.usage.calls, ...options.calls ?? []],
22
- regex: [...draft.usage.regex, ...options.regex ?? []],
23
- derivedKeys: [...draft.usage.derivedKeys, ...options.derivedKeys ?? []]
24
- };
25
- await options.extra?.(draft, ctx);
26
- },
27
- localeFinders: options.finders,
28
- normalizeKey: options.normalizeKey,
29
- transformResource: options.transformResource,
30
- translatePrompt: options.translatePrompt,
31
- extractors: options.templates ? [{
32
- id: options.name,
33
- templates: options.templates
34
- }] : void 0
35
- };
36
- }
37
- function dependsOn(names, prefixes = []) {
38
- return (ctx) => ctx.hasAnyDependency(names) || [...ctx.dependencies].some((dep) => prefixes.some((prefix) => dep.startsWith(prefix)));
39
- }
40
- /** Extensions of JS and TS sources. */
41
- const scriptExtensions = [
42
- "js",
43
- "jsx",
44
- "mjs",
45
- "cjs",
46
- "ts",
47
- "tsx",
48
- "mts",
49
- "cts"
50
- ];
51
- //#endregion
52
- //#region src/presets/angular.ts
53
- const templates = [
54
- "html",
55
- "ts",
56
- "js"
57
- ];
58
- function ngxTranslate() {
59
- return {
60
- name: "ngx-translate",
61
- detect: dependsOn(["@ngx-translate/core"]),
62
- plugins: [library({
63
- name: "ngx-translate",
64
- calls: [{ callee: [
65
- "translate.instant",
66
- "translate.get",
67
- "translate.stream",
68
- "translateService.instant",
69
- "translateService.get",
70
- "translateService.stream",
71
- "_"
72
- ] }],
73
- regex: [{
74
- extensions: templates,
75
- patterns: [
76
- "[`'\"]({key})[`'\"][\\s\\n]*\\|[\\s\\n]*translate\\b",
77
- "[\\s\\n]translate>[\\s\\n]*({key})[\\s\\n]*</",
78
- "\\[translate\\]=[\"']'({key})'[\"']",
79
- "\\stranslate=[\"']({key})[\"']"
80
- ]
81
- }],
82
- resources: [{ pattern: "src/assets/i18n/{locale}.json" }, { pattern: "src/assets/i18n/{locale}/{namespaces}.json" }],
83
- templates: [{
84
- template: "{{ '{key}' | translate }}",
85
- kinds: ["html-text"]
86
- }, {
87
- template: "this.translate.instant('{key}'{args})",
88
- kinds: ["js-string", "js-template"]
89
- }]
90
- }), placeholders(doubleBraces)]
91
- };
92
- }
93
- function transloco() {
94
- return {
95
- name: "transloco",
96
- detect: dependsOn(["@jsverse/transloco", "@ngneat/transloco"]),
97
- plugins: [
98
- library({
99
- name: "transloco",
100
- namespace: { fromPath: "camel" },
101
- calls: [{ callee: [
102
- "translate",
103
- "translocoService.translate",
104
- "transloco.translate",
105
- "translocoService.selectTranslate",
106
- "transloco.selectTranslate"
107
- ] }],
108
- regex: [{
109
- extensions: templates,
110
- patterns: [
111
- "[`'\"]({key})[`'\"][\\s\\n]*\\|[\\s\\n]*transloco\\b",
112
- "[^\\w\\d]t\\([\\s\\n]*['\"`]({key})['\"`]",
113
- "[^*\\w\\d]transloco=['\"`]({key})['\"`]"
114
- ]
115
- }],
116
- resources: [{ pattern: "src/assets/i18n/{locale}.json" }, { pattern: "src/assets/i18n/{namespaces}/{locale}.json" }],
117
- templates: [{
118
- template: "{{ '{key}' | transloco }}",
119
- kinds: ["html-text"]
120
- }, {
121
- template: "translate('{key}'{args})",
122
- kinds: ["js-string", "js-template"],
123
- imports: ["import { translate } from '@jsverse/transloco'"]
124
- }]
125
- }),
126
- regexScopes("\\*transloco=\"[^\"]*read:\\s*'([^']+)'", "transloco-read", {
127
- as: "keyPrefix",
128
- extensions: ["html"]
129
- }),
130
- placeholders(doubleBraces)
131
- ]
132
- };
133
- }
134
- //#endregion
135
- //#region src/presets/nls.ts
136
- const nlsFile = /^(?:(.*)\/)?package\.nls(?:\.([\w-]+))?\.json$/;
137
- const bundleFile = /^(?:(.*)\/)?bundle\.l10n(?:\.([\w-]+))?\.json$/;
138
- /** VS Code extension strings: `package.nls[.locale].json` and `l10n/bundle.l10n[.locale].json`. */
139
- const nlsFinder = {
140
- id: "nls",
141
- async find(ctx) {
142
- const paths = await ctx.host.glob(["**/package.nls*.json", "**/bundle.l10n*.json"], {
143
- ignore: ["**/node_modules/**"],
144
- gitignore: true
145
- });
146
- const out = [];
147
- for (const path of paths) {
148
- const nls = nlsFile.exec(path);
149
- const bundle = nls ? void 0 : bundleFile.exec(path);
150
- const match = nls ?? bundle;
151
- if (!match) continue;
152
- out.push({
153
- path,
154
- locale: match[2] ?? ctx.config.sourceLocale,
155
- namespace: void 0,
156
- format: "json"
157
- });
158
- }
159
- return out;
160
- }
161
- };
162
- //#endregion
163
- //#region src/presets/js.ts
164
- const vueI18nCalls = [{ callee: [
165
- "$t",
166
- "t",
167
- "tc",
168
- "$tc",
169
- "te",
170
- "$te",
171
- "tm",
172
- "$tm",
173
- "i18n.t",
174
- "i18n.global.t",
175
- "$i18n.t",
176
- "i18n.tc",
177
- "i18n.te"
178
- ] }, {
179
- callee: "useI18n",
180
- factory: true,
181
- returns: [
182
- "t",
183
- "tc",
184
- "te",
185
- "tm"
186
- ]
187
- }];
188
- function vueI18n() {
189
- return {
190
- name: "vue-i18n",
191
- detect: dependsOn([
192
- "vue-i18n",
193
- "vuex-i18n",
194
- "petite-vue-i18n",
195
- "vue-i18n-bridge"
196
- ], ["@intlify/"]),
197
- plugins: [
198
- library({
199
- name: "vue-i18n",
200
- calls: vueI18nCalls,
201
- templates: [
202
- {
203
- template: "{{ $t('{key}'{args}) }}",
204
- kinds: ["vue-template-text"]
205
- },
206
- {
207
- template: ":{attr}=\"$t('{key}'{args})\"",
208
- kinds: ["vue-attribute"]
209
- },
210
- {
211
- template: "t('{key}'{args})",
212
- kinds: ["js-string", "js-template"],
213
- files: ["**/*.vue"],
214
- imports: ["import { useI18n } from 'vue-i18n'", "const { t } = useI18n()"]
215
- }
216
- ]
217
- }),
218
- placeholders({
219
- ...braces,
220
- implicit: ["n", "count"]
221
- }, linked),
222
- sfcBlocks()
223
- ]
224
- };
225
- }
226
- function nuxtI18n() {
227
- return {
228
- name: "nuxt-i18n",
229
- detect: dependsOn(["@nuxtjs/i18n", "nuxt-i18n"]),
230
- plugins: [...vueI18n().plugins, {
231
- name: "x18n:nuxt-i18n",
232
- async config(draft, ctx) {
233
- const nuxtConfig = await ctx.host.readFile("nuxt.config.ts") ?? await ctx.host.readFile("nuxt.config.js");
234
- const langDir = nuxtConfig ? /langDir:\s*['"]([^'"]+)['"]/.exec(nuxtConfig)?.[1]?.replace(/^\.\/|\/$/g, "") : void 0;
235
- const dirs = langDir ? [`i18n/${langDir}`, langDir] : [
236
- "i18n/locales",
237
- "locales",
238
- "lang"
239
- ];
240
- draft.resources = [...draft.resources, ...dirs.map((dir) => ({ pattern: `${dir}/{locale}.{ext}` }))];
241
- }
242
- }]
243
- };
244
- }
245
- /** `defaultNS` from the i18next init code (`i18n.ts`, `next-i18next.config.js`), as keys without a namespace use it. */
246
- async function findDefaultNamespace(host) {
247
- const files = await host.glob(["**/*i18n*.{js,mjs,cjs,ts,mts,cts}", "**/i18n/index.{js,ts}"], {
248
- ignore: ["**/node_modules/**", "**/dist/**"],
249
- gitignore: true
250
- });
251
- for (const file of files.slice(0, 20)) {
252
- const found = /\bdefaultNS\s*:\s*['"`]([^'"`]+)['"`]/.exec(await host.readFile(file) ?? "");
253
- if (found) return found[1];
254
- }
255
- }
256
- const i18nextPlugin = library({
257
- name: "i18next",
258
- namespace: {
259
- separator: ":",
260
- default: "translation",
261
- fromPath: "slash"
262
- },
263
- extra: async (draft, ctx) => {
264
- const found = ctx.user.namespace?.default ? void 0 : await findDefaultNamespace(ctx.host);
265
- if (found) draft.namespace = {
266
- ...draft.namespace,
267
- default: found
268
- };
269
- },
270
- calls: [
271
- {
272
- callee: [
273
- "t",
274
- "i18next.t",
275
- "i18n.t"
276
- ],
277
- namespace: {
278
- arg: 1,
279
- property: "ns"
280
- }
281
- },
282
- {
283
- callee: [
284
- "getFixedT",
285
- "i18next.getFixedT",
286
- "i18n.getFixedT"
287
- ],
288
- factory: true,
289
- returns: ["t"],
290
- namespace: { arg: 1 },
291
- keyPrefix: { arg: 2 }
292
- },
293
- {
294
- callee: "tr",
295
- types: ["TFunction"]
296
- }
297
- ],
298
- derivedKeys: [
299
- "{key}_ordinal_{ordinal}",
300
- "{key}_{plural}",
301
- "{key}_*"
302
- ],
303
- translatePrompt: (draft, ctx) => {
304
- draft.notes.push(`i18next plural keys end in _${ctx.localeInfo.pluralCategories.join(", _")} for ${ctx.targetLocale}; write one key per category.`);
305
- },
306
- templates: [{
307
- template: "i18next.t('{key}'{args})",
308
- kinds: ["js-string", "js-template"],
309
- imports: ["import i18next from 'i18next'"]
310
- }]
311
- });
312
- function i18next() {
313
- return {
314
- name: "i18next",
315
- detect: dependsOn(["i18next"]),
316
- plugins: [i18nextPlugin, placeholders(doubleBraces, nesting)]
317
- };
318
- }
319
- function reactI18next() {
320
- return {
321
- name: "react-i18next",
322
- detect: dependsOn(["react-i18next", "next-i18next"]),
323
- plugins: [
324
- i18nextPlugin,
325
- placeholders(doubleBraces, nesting),
326
- library({
327
- name: "react-i18next",
328
- calls: [
329
- {
330
- callee: "useTranslation",
331
- factory: true,
332
- returns: ["t"],
333
- namespace: { arg: 0 },
334
- keyPrefix: {
335
- arg: 1,
336
- property: "keyPrefix"
337
- }
338
- },
339
- {
340
- callee: "Trans",
341
- key: {
342
- arg: 0,
343
- property: "i18nKey"
344
- },
345
- namespace: {
346
- arg: 0,
347
- property: "ns"
348
- }
349
- },
350
- {
351
- callee: "Translation",
352
- factory: true,
353
- returns: ["t"],
354
- namespace: {
355
- arg: 0,
356
- property: "ns"
357
- },
358
- keyPrefix: {
359
- arg: 0,
360
- property: "keyPrefix"
361
- }
362
- }
363
- ],
364
- templates: [{
365
- template: "<Trans i18nKey=\"{key}\" />",
366
- kinds: ["jsx-text"],
367
- imports: ["import { Trans } from 'react-i18next'"]
368
- }, {
369
- template: "{attr}={i18next.t('{key}'{args})}",
370
- kinds: ["jsx-attribute"],
371
- imports: ["import i18next from 'i18next'"]
372
- }]
373
- }),
374
- regexScopes("\\bwithTranslation\\(\\s*(?:\\[?\\s*['\"`](?<namespace>[^'\"`]+)['\"`])?(?:[^)]*?\\bkeyPrefix\\s*:\\s*['\"`](?<keyPrefix>[^'\"`]+)['\"`])?", "react-i18next-hoc", {
375
- wholeFile: true,
376
- extensions: scriptExtensions
377
- })
378
- ]
379
- };
380
- }
381
- function nextIntl() {
382
- return {
383
- name: "next-intl",
384
- detect: dependsOn(["next-intl", "use-intl"]),
385
- plugins: [library({
386
- name: "next-intl",
387
- calls: [{
388
- callee: ["useTranslations", "getTranslations"],
389
- factory: true,
390
- returns: [
391
- "t",
392
- "t.rich",
393
- "t.markup",
394
- "t.raw",
395
- "t.has"
396
- ],
397
- keyPrefix: { arg: 0 }
398
- }, {
399
- callee: "getTranslations",
400
- factory: true,
401
- returns: [
402
- "t",
403
- "t.rich",
404
- "t.markup",
405
- "t.raw",
406
- "t.has"
407
- ],
408
- keyPrefix: {
409
- arg: 0,
410
- property: "namespace"
411
- }
412
- }],
413
- resources: [{ pattern: "messages/{locale}.json" }, { pattern: "src/messages/{locale}.json" }],
414
- templates: [
415
- {
416
- template: "{t('{key}'{args})}",
417
- kinds: ["jsx-text"]
418
- },
419
- {
420
- template: "{attr}={t('{key}'{args})}",
421
- kinds: ["jsx-attribute"]
422
- },
423
- {
424
- template: "t('{key}'{args})",
425
- kinds: ["js-string", "js-template"]
426
- }
427
- ]
428
- }), placeholders(icu)]
429
- };
430
- }
431
- function reactIntl() {
432
- return {
433
- name: "react-intl",
434
- detect: dependsOn(["react-intl"], ["@formatjs/"]),
435
- plugins: [library({
436
- name: "react-intl",
437
- calls: [{
438
- callee: [
439
- "intl.formatMessage",
440
- "formatMessage",
441
- "defineMessage",
442
- "FormattedMessage"
443
- ],
444
- key: {
445
- arg: 0,
446
- property: "id"
447
- }
448
- }, {
449
- callee: "defineMessages",
450
- key: {
451
- arg: 0,
452
- property: "*.id"
453
- }
454
- }],
455
- templates: [
456
- {
457
- template: "<FormattedMessage id=\"{key}\" />",
458
- kinds: ["jsx-text"],
459
- imports: ["import { FormattedMessage } from 'react-intl'"]
460
- },
461
- {
462
- template: "{attr}={intl.formatMessage({ id: '{key}' }{args})}",
463
- kinds: ["jsx-attribute"]
464
- },
465
- {
466
- template: "intl.formatMessage({ id: '{key}' }{args})",
467
- kinds: ["js-string", "js-template"]
468
- }
469
- ]
470
- }), placeholders(icu)]
471
- };
472
- }
473
- function svelteI18n() {
474
- return {
475
- name: "svelte-i18n",
476
- detect: dependsOn([
477
- "svelte-i18n",
478
- "sveltekit-i18n",
479
- "@sveltekit-i18n/base"
480
- ]),
481
- plugins: [library({
482
- name: "svelte-i18n",
483
- calls: [{ callee: [
484
- "$_",
485
- "$t",
486
- "$format",
487
- "_",
488
- "t",
489
- "format",
490
- "$json",
491
- "json"
492
- ] }],
493
- templates: [{
494
- template: "{$_('{key}'{args})}",
495
- kinds: ["svelte-text"],
496
- imports: ["import { _ } from 'svelte-i18n'"]
497
- }, {
498
- template: "{attr}={$_('{key}'{args})}",
499
- kinds: ["svelte-attribute"],
500
- imports: ["import { _ } from 'svelte-i18n'"]
501
- }]
502
- }), placeholders(icu)]
503
- };
504
- }
505
- function vscodeExtension() {
506
- return {
507
- name: "vscode-extension",
508
- detect: (ctx) => ctx.hasAnyDependency(["vscode", "@types/vscode"]),
509
- plugins: [library({
510
- name: "vscode-extension",
511
- calls: [{ callee: ["l10n.t", "vscode.l10n.t"] }],
512
- finders: [nlsFinder],
513
- extra: (draft) => {
514
- draft.usage = {
515
- ...draft.usage,
516
- regex: [...draft.usage.regex, {
517
- extensions: ["json"],
518
- patterns: ["\"%({key})%\""]
519
- }]
520
- };
521
- }
522
- }), placeholders(braces)]
523
- };
524
- }
525
- /** Always last: hard-string extraction templates for plain JS, TS and HTML. */
526
- function general() {
527
- return {
528
- name: "general",
529
- detect: () => true,
530
- plugins: [{
531
- name: "x18n:general",
532
- extractors: [{
533
- id: "general",
534
- templates: defaultTemplates
535
- }]
536
- }]
537
- };
538
- }
539
- //#endregion
540
- //#region src/presets/mobile.ts
541
- /** Flutter with `flutter_i18n`: JSON or YAML assets, `FlutterI18n.translate(context, 'key')`. */
542
- function flutter() {
543
- return {
544
- name: "flutter",
545
- detect: dependsOn(["flutter_i18n"]),
546
- plugins: [library({
547
- name: "flutter",
548
- regex: [{
549
- extensions: ["dart"],
550
- patterns: ["[^\\w\\d]FlutterI18n\\.(?:plural|translate)\\(\\s*[\\w\\d.]+,\\s*['\"`]({key})['\"`]", "[^\\w\\d]I18n(?:Plural|Text)\\(\\s*['\"`]({key})['\"`]"]
551
- }],
552
- resources: [{ pattern: "assets/flutter_i18n/{locale}.{ext}" }, { pattern: "assets/i18n/{locale}.{ext}" }],
553
- templates: [{ template: "FlutterI18n.translate(context, '{key}')" }]
554
- }), placeholders(braces)]
555
- };
556
- }
557
- //#endregion
558
- //#region src/presets/server.ts
559
- /** Laravel: `lang/{locale}/{file}.php` arrays and `lang/{locale}.json`; keys are `file.key`. Exclusive like i18n-ally. */
560
- function laravel() {
561
- return {
562
- name: "laravel",
563
- detect: dependsOn(["laravel/framework"]),
564
- exclusive: true,
565
- plugins: [library({
566
- name: "laravel",
567
- regex: [{
568
- extensions: ["php"],
569
- patterns: ["[^\\w\\d](?:__|trans|@lang|trans_choice|Lang::get|Lang::choice)\\(\\s*'([^']+)'", "[^\\w\\d](?:__|trans|@lang|trans_choice|Lang::get|Lang::choice)\\(\\s*\"([^\"]+)\""]
570
- }],
571
- resources: [
572
- { pattern: "lang/{locale}/{namespaces}.php" },
573
- { pattern: "resources/lang/{locale}/{namespaces}.php" },
574
- { pattern: "lang/{locale}.json" },
575
- { pattern: "resources/lang/{locale}.json" }
576
- ],
577
- normalizeKey: (raw) => raw.includes("/") ? raw.replace(/\//g, ".") : void 0,
578
- templates: [{ template: "__('{key}')" }]
579
- }), placeholders(colon)]
580
- };
581
- }
582
- /** Joomla: INI language files, `Text::_('KEY')`. */
583
- function phpJoomla() {
584
- return {
585
- name: "php-joomla",
586
- detect: dependsOn(["joomla/application", "joomla/cms"]),
587
- plugins: [library({
588
- name: "php-joomla",
589
- regex: [{
590
- extensions: ["php"],
591
- patterns: ["J?Text::(?:_|[\\w]+)\\(\\s*['\"]({key})['\"]"]
592
- }],
593
- resources: [{ pattern: "language/{locale}/*.ini" }, { pattern: "administrator/language/{locale}/*.ini" }],
594
- keyStyle: "flat",
595
- templates: [{ template: "Text::_('{key}')" }]
596
- }), placeholders(printf)]
597
- };
598
- }
599
- /** PHP gettext with `.po` files. Exclusive and never detected, as in i18n-ally: list it in `presets`. */
600
- function phpGettext() {
601
- return {
602
- name: "php-gettext",
603
- exclusive: true,
604
- plugins: [library({
605
- name: "php-gettext",
606
- regex: [{
607
- extensions: ["php"],
608
- patterns: ["[^\\w\\d](?:gettext|_|__)\\(\\s*['\"`]({key})['\"`]"]
609
- }],
610
- resources: [{ pattern: "locale/{locale}/LC_MESSAGES/*.po" }, { pattern: "locales/{locale}.po" }],
611
- extra: (draft) => {
612
- draft.extract = {
613
- keygen: "source",
614
- ...draft.extract
615
- };
616
- },
617
- templates: [{ template: "gettext('{key}')" }]
618
- }), placeholders(printf)]
619
- };
620
- }
621
- const viewSuffix = /(?:\.html)?\.(?:erb|haml|slim)$/;
622
- /** `t('.title')` in `app/views/users/index.html.erb` means `users.index.title`. */
623
- function railsLazyKey(raw, path) {
624
- if (!raw.startsWith(".")) return void 0;
625
- const match = /(?:^|\/)app\/views\/(.+)$/.exec(path);
626
- if (!match) return void 0;
627
- return `${match[1].replace(viewSuffix, "").split("/").map((segment) => segment.replace(/^_/, "")).join(".")}${raw}`;
628
- }
629
- function rubyRails() {
630
- return {
631
- name: "ruby-rails",
632
- detect: dependsOn([
633
- "rails",
634
- "rails-i18n",
635
- "railties"
636
- ]),
637
- plugins: [library({
638
- name: "ruby-rails",
639
- regex: [{
640
- extensions: [
641
- "rb",
642
- "erb",
643
- "haml",
644
- "slim"
645
- ],
646
- patterns: [
647
- "[^\\w\\d]t(?:\\(| )\\s*['\"`]({key})['\"`]",
648
- "[^\\w\\d]t\\(:({key})\\)",
649
- "I18n\\.t\\(\\s*['\"`]({key})['\"`]"
650
- ]
651
- }],
652
- resources: [
653
- { pattern: "config/locales/{locale}.yml" },
654
- { pattern: "config/locales/**/*.{locale}.yml" },
655
- { pattern: "config/locales/{locale}/**/*.yml" }
656
- ],
657
- normalizeKey: (raw, ctx) => railsLazyKey(raw, ctx.path),
658
- transformResource: {
659
- applies: (ctx) => /\.ya?ml$/.test(ctx.path),
660
- read(tree, ctx) {
661
- const root = tree[ctx.locale];
662
- return root !== void 0 && !isMessageLeaf(root) ? root : {};
663
- },
664
- toStored: (path, ctx) => [ctx.locale, ...path]
665
- },
666
- templates: [{ template: "t('{key}')" }]
667
- }), placeholders(percentBraces)]
668
- };
669
- }
670
- function jekyll() {
671
- return {
672
- name: "jekyll",
673
- detect: dependsOn(["jekyll-multiple-languages-plugin"]),
674
- plugins: [library({
675
- name: "jekyll",
676
- regex: [{
677
- extensions: [
678
- "html",
679
- "md",
680
- "liquid"
681
- ],
682
- patterns: ["\\{%\\s+t\\s+({key})\\s+%\\}"]
683
- }],
684
- resources: [{ pattern: "_i18n/{locale}.yml" }],
685
- keyStyle: "nested",
686
- templates: [{ template: "{% t {key} %}" }]
687
- })]
688
- };
689
- }
690
- //#endregion
691
- //#region src/presets/web.ts
692
- const jsxTemplates = [
693
- {
694
- template: "{t('{key}'{args})}",
695
- kinds: ["jsx-text"]
696
- },
697
- {
698
- template: "{attr}={t('{key}'{args})}",
699
- kinds: ["jsx-attribute"]
700
- },
701
- {
702
- template: "t('{key}'{args})",
703
- kinds: ["js-string", "js-template"]
704
- }
705
- ];
706
- function nextInternational() {
707
- return {
708
- name: "next-international",
709
- detect: dependsOn(["next-international"]),
710
- plugins: [library({
711
- name: "next-international",
712
- calls: [{
713
- callee: ["useI18n", "getI18n"],
714
- factory: true,
715
- returns: ["t"]
716
- }, {
717
- callee: ["useScopedI18n", "getScopedI18n"],
718
- factory: true,
719
- returns: ["t"],
720
- keyPrefix: { arg: 0 }
721
- }],
722
- resources: [{ pattern: "locales/{locale}.{ext}" }, { pattern: "src/locales/{locale}.{ext}" }],
723
- templates: jsxTemplates
724
- }), placeholders(braces)]
725
- };
726
- }
727
- function nextTranslate() {
728
- return {
729
- name: "next-translate",
730
- detect: dependsOn(["next-translate"]),
731
- plugins: [library({
732
- name: "next-translate",
733
- namespace: {
734
- separator: ":",
735
- default: "common"
736
- },
737
- calls: [
738
- {
739
- callee: "useTranslation",
740
- factory: true,
741
- returns: ["t"],
742
- namespace: { arg: 0 }
743
- },
744
- {
745
- callee: "getT",
746
- factory: true,
747
- returns: ["t"],
748
- namespace: { arg: 1 }
749
- },
750
- {
751
- callee: "Trans",
752
- key: {
753
- arg: 0,
754
- property: "i18nKey"
755
- },
756
- namespace: {
757
- arg: 0,
758
- property: "ns"
759
- }
760
- },
761
- { callee: "t" }
762
- ],
763
- regex: [{
764
- extensions: scriptExtensions,
765
- patterns: ["[^\\w\\d]t`({key})`"]
766
- }],
767
- resources: [{ pattern: "locales/{locale}/{namespace}.json" }],
768
- keyStyle: "nested",
769
- templates: jsxTemplates
770
- }), placeholders(doubleBraces)]
771
- };
772
- }
773
- /** Shopify's i18next format: plural and ordinal forms as nested keys (`{key}.one`). */
774
- function i18nextShopify() {
775
- const derivedKeys = [
776
- "{key}.ordinal.{ordinal}",
777
- "{key}.{plural}",
778
- ...["plural", ...Array.from({ length: 10 }, (_, i) => String(i))].map((form) => `{key}.${form}`)
779
- ];
780
- return {
781
- name: "i18next-shopify",
782
- detect: dependsOn(["@shopify/i18next-shopify"]),
783
- plugins: [
784
- ...reactI18next().plugins,
785
- library({
786
- name: "i18next-shopify",
787
- derivedKeys,
788
- keyStyle: "nested"
789
- }),
790
- placeholders(braces)
791
- ]
792
- };
793
- }
794
- function i18nTag() {
795
- return {
796
- name: "i18n-tag",
797
- detect: dependsOn(["es2015-i18n-tag"]),
798
- plugins: [library({
799
- name: "i18n-tag",
800
- regex: [{
801
- extensions: [...scriptExtensions, "vue"],
802
- patterns: ["i18n`({key})`"]
803
- }],
804
- templates: [{
805
- template: "i18n`{key}`",
806
- kinds: ["js-string", "js-template"]
807
- }]
808
- })]
809
- };
810
- }
811
- function fluentVue() {
812
- return {
813
- name: "fluent-vue",
814
- detect: dependsOn([
815
- "fluent-vue",
816
- "fluent-vue-loader",
817
- "rollup-plugin-fluent-vue",
818
- "unplugin-fluent-vue"
819
- ]),
820
- plugins: [
821
- library({
822
- name: "fluent-vue",
823
- calls: [{ callee: [
824
- "$t",
825
- "$ta",
826
- "fluent.format",
827
- "fluent.formatAttrs",
828
- "this.$t",
829
- "this.$ta"
830
- ] }, {
831
- callee: "useFluent",
832
- factory: true,
833
- returns: [
834
- "$t",
835
- "$ta",
836
- "format",
837
- "formatAttrs"
838
- ]
839
- }],
840
- regex: [{
841
- extensions: ["vue"],
842
- patterns: ["v-t:({key})[\\s\\n=>]", "<i18n[\\s\\n]+path=['\"`]({key})['\"`]"]
843
- }],
844
- resources: [{ pattern: "locales/{locale}.ftl" }, { pattern: "src/locales/{locale}.ftl" }],
845
- templates: [
846
- {
847
- template: "{{ $t('{key}'{args}) }}",
848
- kinds: ["vue-template-text"]
849
- },
850
- {
851
- template: ":{attr}=\"$t('{key}'{args})\"",
852
- kinds: ["vue-attribute"]
853
- },
854
- {
855
- template: "$t('{key}'{args})",
856
- kinds: ["js-string", "js-template"]
857
- }
858
- ]
859
- }),
860
- sfcFluentBlocks(),
861
- placeholders(fluent)
862
- ]
863
- };
864
- }
865
- function polyglot() {
866
- return {
867
- name: "polyglot",
868
- detect: dependsOn(["node-polyglot"]),
869
- plugins: [library({
870
- name: "polyglot",
871
- calls: [{ callee: ["polyglot.t", "I18n.t"] }],
872
- regex: [{
873
- extensions: ["rb"],
874
- patterns: ["(?:polyglot|I18n)\\.t\\(\\s*['\"`]({key})['\"`]"]
875
- }],
876
- templates: [{
877
- template: "polyglot.t('{key}'{args})",
878
- kinds: ["js-string", "js-template"]
879
- }]
880
- }), placeholders(percentBraces)]
881
- };
882
- }
883
- function globalize() {
884
- return {
885
- name: "globalize",
886
- detect: dependsOn(["globalize"]),
887
- plugins: [library({
888
- name: "globalize",
889
- calls: [{ callee: [
890
- "Globalize.messageFormatter",
891
- "Globalize.formatMessage",
892
- "globalize.messageFormatter",
893
- "globalize.formatMessage"
894
- ] }],
895
- normalizeKey: (raw) => raw.includes("/") ? raw.replace(/\//g, ".") : void 0,
896
- templates: [{
897
- template: "Globalize.formatMessage('{key}'{args})",
898
- kinds: ["js-string", "js-template"]
899
- }]
900
- }), placeholders(icu)]
901
- };
902
- }
903
- function ui5() {
904
- return {
905
- name: "ui5",
906
- detect: dependsOn(["@ui5/cli"]),
907
- plugins: [library({
908
- name: "ui5",
909
- regex: [{
910
- extensions: [
911
- "xml",
912
- "json",
913
- ...scriptExtensions
914
- ],
915
- patterns: ["\\{i18n>({key})\\}"]
916
- }, {
917
- extensions: scriptExtensions,
918
- patterns: ["getResourceBundle\\(\\)\\.getText\\(\\s*['\"`]({key})['\"`]"]
919
- }],
920
- resources: [{ pattern: "webapp/i18n/i18n_{locale}.properties" }, { pattern: "webapp/i18n/i18n.properties" }],
921
- keyStyle: "flat",
922
- templates: [{
923
- template: "{i18n>{key}}",
924
- files: ["**/*.xml"]
925
- }, {
926
- template: "this.getResourceBundle().getText('{key}')",
927
- kinds: ["js-string", "js-template"]
928
- }]
929
- }), placeholders(braces)]
930
- };
931
- }
932
- function lingui() {
933
- return {
934
- name: "lingui",
935
- detect: dependsOn([
936
- "@lingui/core",
937
- "@lingui/react",
938
- "@lingui/macro"
939
- ]),
940
- plugins: [library({
941
- name: "lingui",
942
- calls: [
943
- { callee: [
944
- "i18n._",
945
- "i18n.t",
946
- "t",
947
- "_"
948
- ] },
949
- {
950
- callee: [
951
- "t",
952
- "msg",
953
- "defineMessage",
954
- "i18n._",
955
- "Trans"
956
- ],
957
- key: {
958
- arg: 0,
959
- property: "id"
960
- }
961
- },
962
- {
963
- callee: "useLingui",
964
- factory: true,
965
- returns: ["t", "_"]
966
- }
967
- ],
968
- regex: [{
969
- extensions: scriptExtensions,
970
- patterns: ["\\bt`({key})`", "<Trans>[\\s]*({key})[\\s]*<\\/Trans>"]
971
- }],
972
- resources: [{ pattern: "src/locales/{locale}/messages.po" }, { pattern: "locales/{locale}/messages.po" }],
973
- extra: (draft) => {
974
- draft.extract = {
975
- keygen: "source",
976
- ...draft.extract
977
- };
978
- },
979
- templates: [{
980
- template: "<Trans>{key}</Trans>",
981
- kinds: ["jsx-text"],
982
- imports: ["import { Trans } from '@lingui/react/macro'"]
983
- }, {
984
- template: "t`{key}`",
985
- kinds: ["js-string", "js-template"],
986
- imports: ["import { t } from '@lingui/core/macro'"]
987
- }]
988
- }), placeholders(icu)]
989
- };
990
- }
991
- function emberIntl() {
992
- return {
993
- name: "ember-intl",
994
- detect: dependsOn(["ember-intl"]),
995
- plugins: [library({
996
- name: "ember-intl",
997
- calls: [{ callee: ["intl.t"] }],
998
- regex: [{
999
- extensions: [
1000
- "hbs",
1001
- "gjs",
1002
- "gts"
1003
- ],
1004
- patterns: ["\\{\\{\\s*t\\s+['\"`]({key})['\"`]", "\\(\\s*t\\s+['\"`]({key})['\"`]"]
1005
- }],
1006
- resources: [{ pattern: "translations/{locale}.{ext}" }, { pattern: "translations/{namespaces}/{locale}.{ext}" }],
1007
- templates: [{
1008
- template: "{{t '{key}'}}",
1009
- files: ["**/*.hbs"]
1010
- }, {
1011
- template: "this.intl.t('{key}'{args})",
1012
- kinds: ["js-string", "js-template"]
1013
- }]
1014
- }), placeholders(icu)]
1015
- };
1016
- }
1017
- function i18nJs() {
1018
- return {
1019
- name: "i18n-js",
1020
- detect: dependsOn(["i18n-js"]),
1021
- plugins: [library({
1022
- name: "i18n-js",
1023
- calls: [{ callee: ["I18n.t", "i18n.t"] }],
1024
- templates: [{
1025
- template: "i18n.t('{key}'{args})",
1026
- kinds: ["js-string", "js-template"]
1027
- }]
1028
- }), placeholders(percentBraces)]
1029
- };
1030
- }
1031
- /** Chrome and WebExtension `_locales/{locale}/messages.json`: `{ "name": { "message": "..." } }` reads as `name`. */
1032
- function chromeExtension() {
1033
- return {
1034
- name: "chrome-extension",
1035
- async detect(ctx) {
1036
- for (const path of [
1037
- "manifest.json",
1038
- "src/manifest.json",
1039
- "public/manifest.json"
1040
- ]) if ((await ctx.host.readFile(path))?.includes("\"default_locale\"")) return true;
1041
- return false;
1042
- },
1043
- plugins: [
1044
- library({
1045
- name: "chrome-extension",
1046
- calls: [{ callee: [
1047
- "chrome.i18n.getMessage",
1048
- "browser.i18n.getMessage",
1049
- "i18n.getMessage"
1050
- ] }],
1051
- regex: [{
1052
- extensions: [
1053
- "json",
1054
- "html",
1055
- "css"
1056
- ],
1057
- patterns: ["__MSG_({key})__"]
1058
- }],
1059
- resources: [{ pattern: "_locales/{locale}/messages.json" }, { pattern: "{src,public,extension}/_locales/{locale}/messages.json" }],
1060
- transformResource: {
1061
- applies: (ctx) => /(?:^|\/)_locales\/[^/]+\/messages\.json$/.test(ctx.path),
1062
- read(tree) {
1063
- const out = {};
1064
- for (const [name, entry] of Object.entries(tree)) {
1065
- const message = isMessageLeaf(entry) ? void 0 : entry.message;
1066
- if (message !== void 0 && isMessageLeaf(message)) out[name] = message;
1067
- }
1068
- return out;
1069
- },
1070
- toStored: (path) => [path.join("."), "message"]
1071
- },
1072
- templates: [{
1073
- template: "chrome.i18n.getMessage('{key}')",
1074
- kinds: ["js-string", "js-template"]
1075
- }]
1076
- }),
1077
- {
1078
- name: "x18n:chrome-extension-source-locale",
1079
- async config(draft, ctx) {
1080
- const manifest = await ctx.host.readFile("manifest.json") ?? await ctx.host.readFile("src/manifest.json") ?? await ctx.host.readFile("public/manifest.json");
1081
- const locale = manifest ? /"default_locale"\s*:\s*"([^"]+)"/.exec(manifest)?.[1] : void 0;
1082
- if (locale) draft.sourceLocale = locale;
1083
- }
1084
- },
1085
- placeholders(dollars)
1086
- ]
1087
- };
1088
- }
1089
- function solidPrimitivesI18n() {
1090
- return {
1091
- name: "solid-primitives-i18n",
1092
- detect: dependsOn(["@solid-primitives/i18n"]),
1093
- plugins: [library({
1094
- name: "solid-primitives-i18n",
1095
- calls: [{ callee: ["t", "i18n.t"] }],
1096
- templates: [
1097
- {
1098
- template: "{t('{key}'{args})}",
1099
- kinds: ["jsx-text"]
1100
- },
1101
- {
1102
- template: "{attr}={t('{key}'{args})}",
1103
- kinds: ["jsx-attribute"]
1104
- },
1105
- {
1106
- template: "t('{key}'{args})",
1107
- kinds: ["js-string", "js-template"]
1108
- }
1109
- ]
1110
- }), placeholders(doubleBraces)]
1111
- };
1112
- }
1113
- function paraglide() {
1114
- return {
1115
- name: "paraglide",
1116
- detect: dependsOn([
1117
- "@inlang/paraglide-js",
1118
- "@inlang/paraglide-sveltekit",
1119
- "@inlang/paraglide-next",
1120
- "@inlang/paraglide-astro",
1121
- "@inlang/paraglide-vite"
1122
- ]),
1123
- plugins: [library({
1124
- name: "paraglide",
1125
- regex: [{
1126
- extensions: [
1127
- ...scriptExtensions,
1128
- "vue",
1129
- "svelte",
1130
- "astro"
1131
- ],
1132
- patterns: ["\\bm\\.({key})\\(", "\\bm\\[\\s*['\"`]({key})['\"`]\\s*\\]\\("]
1133
- }],
1134
- resources: [{ pattern: "messages/{locale}.json" }],
1135
- templates: [{
1136
- template: "{m.{key}({args})}",
1137
- kinds: ["jsx-text", "svelte-text"],
1138
- imports: ["import { m } from '$lib/paraglide/messages'"]
1139
- }, {
1140
- template: "m.{key}({args})",
1141
- kinds: ["js-string", "js-template"],
1142
- imports: ["import { m } from '$lib/paraglide/messages'"]
1143
- }]
1144
- }), placeholders(braces)]
1145
- };
1146
- }
1147
- //#endregion
1148
- //#region src/presets/index.ts
1149
- /**
1150
- * Presets by name, in detection order: every i18n-ally framework has one.
1151
- * Presets that share plugins (react-i18next and i18next) apply them once.
1152
- */
1153
- const presets = {
1154
- "nuxt-i18n": () => nuxtI18n(),
1155
- "vue-i18n": () => vueI18n(),
1156
- "fluent-vue": () => fluentVue(),
1157
- "i18next-shopify": () => i18nextShopify(),
1158
- "react-i18next": () => reactI18next(),
1159
- "next-translate": () => nextTranslate(),
1160
- "next-international": () => nextInternational(),
1161
- "i18next": () => i18next(),
1162
- "next-intl": () => nextIntl(),
1163
- "react-intl": () => reactIntl(),
1164
- "svelte-i18n": () => svelteI18n(),
1165
- "solid-primitives-i18n": () => solidPrimitivesI18n(),
1166
- "paraglide": () => paraglide(),
1167
- "ngx-translate": () => ngxTranslate(),
1168
- "transloco": () => transloco(),
1169
- "lingui": () => lingui(),
1170
- "ember-intl": () => emberIntl(),
1171
- "polyglot": () => polyglot(),
1172
- "globalize": () => globalize(),
1173
- "i18n-tag": () => i18nTag(),
1174
- "i18n-js": () => i18nJs(),
1175
- "ui5": () => ui5(),
1176
- "chrome-extension": () => chromeExtension(),
1177
- "vscode-extension": () => vscodeExtension(),
1178
- "laravel": () => laravel(),
1179
- "php-joomla": () => phpJoomla(),
1180
- "php-gettext": () => phpGettext(),
1181
- "ruby-rails": () => rubyRails(),
1182
- "jekyll": () => jekyll(),
1183
- "flutter": () => flutter(),
1184
- "general": () => general()
1185
- };
1186
- //#endregion
1187
- export { vscodeExtension as A, general as C, reactI18next as D, nuxtI18n as E, ngxTranslate as M, transloco as N, reactIntl as O, flutter as S, nextIntl as T, laravel as _, globalize as a, railsLazyKey as b, i18nextShopify as c, nextTranslate as d, paraglide as f, jekyll as g, ui5 as h, fluentVue as i, vueI18n as j, svelteI18n as k, lingui as l, solidPrimitivesI18n as m, chromeExtension as n, i18nJs as o, polyglot as p, emberIntl as r, i18nTag as s, presets as t, nextInternational as u, phpGettext as v, i18next as w, rubyRails as x, phpJoomla as y };