@x18n/builtins 0.0.12 → 0.0.14

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