@x18n/builtins 0.0.13 → 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 (168) hide show
  1. package/dist/angular-templates-DqIOGfzT.mjs +8 -0
  2. package/dist/extractors.mjs +7 -3
  3. package/dist/finders.d.mts +4 -1
  4. package/dist/finders.mjs +1 -1
  5. package/dist/formats/ecmascript.d.mts +5 -0
  6. package/dist/formats/ecmascript.mjs +211 -0
  7. package/dist/formats/ftl.d.mts +5 -0
  8. package/dist/formats/ftl.mjs +234 -0
  9. package/dist/formats/ini.d.mts +5 -0
  10. package/dist/formats/ini.mjs +158 -0
  11. package/dist/formats/json.d.mts +6 -0
  12. package/dist/formats/json.mjs +10 -0
  13. package/dist/formats/json5.d.mts +5 -0
  14. package/dist/formats/json5.mjs +30 -0
  15. package/dist/formats/jsonc.d.mts +6 -0
  16. package/dist/formats/jsonc.mjs +10 -0
  17. package/dist/formats/php.d.mts +5 -0
  18. package/dist/formats/php.mjs +200 -0
  19. package/dist/formats/po.d.mts +5 -0
  20. package/dist/formats/po.mjs +177 -0
  21. package/dist/formats/properties.d.mts +5 -0
  22. package/dist/formats/properties.mjs +123 -0
  23. package/dist/formats/resx.d.mts +6 -0
  24. package/dist/formats/resx.mjs +202 -0
  25. package/dist/formats/yaml.d.mts +5 -0
  26. package/dist/formats/yaml.mjs +113 -0
  27. package/dist/formats.d.mts +10 -34
  28. package/dist/formats.mjs +61 -1
  29. package/dist/index.d.mts +2 -2
  30. package/dist/index.mjs +28 -22
  31. package/dist/{vue-CF4pe-Yr.mjs → js-CV-ECNJG.mjs} +67 -222
  32. package/dist/json-CyjI8bjp.d.mts +8 -0
  33. package/dist/json-Db-8qSbE.mjs +73 -0
  34. package/dist/jsx-templates-B1J0no3i.mjs +17 -0
  35. package/dist/locale-root-C_rch3IQ.mjs +15 -0
  36. package/dist/manifests.d.mts +8 -0
  37. package/dist/manifests.mjs +66 -2
  38. package/dist/placeholders.d.mts +11 -0
  39. package/dist/placeholders.mjs +28 -1
  40. package/dist/plugin-Cb1b0axD.mjs +83 -0
  41. package/dist/plural-forms-B7_QX4nG.mjs +12 -0
  42. package/dist/presets/cargo-i18n.d.mts +6 -0
  43. package/dist/presets/cargo-i18n.mjs +28 -0
  44. package/dist/presets/chrome-extension.d.mts +6 -0
  45. package/dist/presets/chrome-extension.mjs +52 -0
  46. package/dist/presets/dotnet-resx.d.mts +6 -0
  47. package/dist/presets/dotnet-resx.mjs +64 -0
  48. package/dist/presets/easy-localization.d.mts +6 -0
  49. package/dist/presets/easy-localization.mjs +36 -0
  50. package/dist/presets/ember-intl.d.mts +5 -0
  51. package/dist/presets/ember-intl.mjs +31 -0
  52. package/dist/presets/fluent-react.d.mts +5 -0
  53. package/dist/presets/fluent-react.mjs +46 -0
  54. package/dist/presets/fluent-vue.d.mts +5 -0
  55. package/dist/presets/fluent-vue.mjs +51 -0
  56. package/dist/presets/flutter-translate.d.mts +6 -0
  57. package/dist/presets/flutter-translate.mjs +30 -0
  58. package/dist/presets/flutter.d.mts +6 -0
  59. package/dist/presets/flutter.mjs +21 -0
  60. package/dist/presets/general.d.mts +6 -0
  61. package/dist/presets/general.mjs +17 -0
  62. package/dist/presets/globalize.d.mts +5 -0
  63. package/dist/presets/globalize.mjs +25 -0
  64. package/dist/presets/gravity-ui-i18n.d.mts +6 -0
  65. package/dist/presets/gravity-ui-i18n.mjs +41 -0
  66. package/dist/presets/i18n-js.d.mts +5 -0
  67. package/dist/presets/i18n-js.mjs +19 -0
  68. package/dist/presets/i18n-tag.d.mts +5 -0
  69. package/dist/presets/i18n-tag.mjs +21 -0
  70. package/dist/presets/i18next-shopify.d.mts +6 -0
  71. package/dist/presets/i18next-shopify.mjs +23 -0
  72. package/dist/presets/i18next.d.mts +5 -0
  73. package/dist/presets/i18next.mjs +10 -0
  74. package/dist/presets/i18nice.d.mts +6 -0
  75. package/dist/presets/i18nice.mjs +29 -0
  76. package/dist/presets/jekyll.d.mts +5 -0
  77. package/dist/presets/jekyll.mjs +23 -0
  78. package/dist/presets/laravel-vue-i18n.d.mts +6 -0
  79. package/dist/presets/laravel-vue-i18n.mjs +54 -0
  80. package/dist/presets/laravel.d.mts +6 -0
  81. package/dist/presets/laravel.mjs +23 -0
  82. package/dist/presets/lingui.d.mts +5 -0
  83. package/dist/presets/lingui.mjs +61 -0
  84. package/dist/presets/next-international.d.mts +5 -0
  85. package/dist/presets/next-international.mjs +27 -0
  86. package/dist/presets/next-intl.d.mts +5 -0
  87. package/dist/presets/next-intl.mjs +55 -0
  88. package/dist/presets/next-translate.d.mts +5 -0
  89. package/dist/presets/next-translate.mjs +53 -0
  90. package/dist/presets/ngx-translate.d.mts +5 -0
  91. package/dist/presets/ngx-translate.mjs +41 -0
  92. package/dist/presets/nuxt-i18n-micro.d.mts +5 -0
  93. package/dist/presets/nuxt-i18n-micro.mjs +81 -0
  94. package/dist/presets/nuxt-i18n.d.mts +5 -0
  95. package/dist/presets/nuxt-i18n.mjs +23 -0
  96. package/dist/presets/paraglide.d.mts +5 -0
  97. package/dist/presets/paraglide.mjs +38 -0
  98. package/dist/presets/php-gettext.d.mts +6 -0
  99. package/dist/presets/php-gettext.mjs +27 -0
  100. package/dist/presets/php-joomla.d.mts +6 -0
  101. package/dist/presets/php-joomla.mjs +22 -0
  102. package/dist/presets/polyglot.d.mts +5 -0
  103. package/dist/presets/polyglot.mjs +23 -0
  104. package/dist/presets/python-gettext.d.mts +6 -0
  105. package/dist/presets/python-gettext.mjs +44 -0
  106. package/dist/presets/react-i18next.d.mts +5 -0
  107. package/dist/presets/react-i18next.mjs +67 -0
  108. package/dist/presets/react-intl.d.mts +5 -0
  109. package/dist/presets/react-intl.mjs +47 -0
  110. package/dist/presets/ruby-rails.d.mts +7 -0
  111. package/dist/presets/ruby-rails.mjs +44 -0
  112. package/dist/presets/solid-primitives-i18n.d.mts +5 -0
  113. package/dist/presets/solid-primitives-i18n.mjs +29 -0
  114. package/dist/presets/svelte-i18n.d.mts +5 -0
  115. package/dist/presets/svelte-i18n.mjs +33 -0
  116. package/dist/presets/svelte-i18next.d.mts +5 -0
  117. package/dist/presets/svelte-i18next.mjs +27 -0
  118. package/dist/presets/transloco.d.mts +5 -0
  119. package/dist/presets/transloco.mjs +44 -0
  120. package/dist/presets/typesafe-i18n.d.mts +6 -0
  121. package/dist/presets/typesafe-i18n.mjs +61 -0
  122. package/dist/presets/ui5.d.mts +5 -0
  123. package/dist/presets/ui5.mjs +35 -0
  124. package/dist/presets/vscode-extension.d.mts +5 -0
  125. package/dist/presets/vscode-extension.mjs +53 -0
  126. package/dist/presets/vue-i18n.d.mts +5 -0
  127. package/dist/presets/vue-i18n.mjs +59 -0
  128. package/dist/presets.d.mts +7 -54
  129. package/dist/presets.mjs +346 -1
  130. package/dist/reporters/github.d.mts +6 -0
  131. package/dist/reporters/github.mjs +27 -0
  132. package/dist/reporters/json.d.mts +6 -0
  133. package/dist/reporters/json.mjs +24 -0
  134. package/dist/reporters/markdown.d.mts +6 -0
  135. package/dist/reporters/markdown.mjs +37 -0
  136. package/dist/reporters/pretty.d.mts +6 -0
  137. package/dist/reporters/pretty.mjs +64 -0
  138. package/dist/reporters/sarif.d.mts +6 -0
  139. package/dist/reporters/sarif.mjs +48 -0
  140. package/dist/reporters.d.mts +5 -12
  141. package/dist/reporters.mjs +8 -218
  142. package/dist/scanners/astro.d.mts +6 -0
  143. package/dist/scanners/astro.mjs +256 -0
  144. package/dist/scanners/js.d.mts +6 -0
  145. package/dist/scanners/js.mjs +33 -0
  146. package/dist/scanners/regex-scopes.d.mts +14 -0
  147. package/dist/scanners/regex-scopes.mjs +41 -0
  148. package/dist/scanners/regex.d.mts +9 -0
  149. package/dist/{regex-AYVhuSb6.mjs → scanners/regex.mjs} +2 -40
  150. package/dist/scanners/svelte.d.mts +6 -0
  151. package/dist/{scanners-DhnnVp7s.mjs → scanners/svelte.mjs} +3 -3
  152. package/dist/scanners/vue.d.mts +6 -0
  153. package/dist/scanners/vue.mjs +172 -0
  154. package/dist/scanners.d.mts +9 -50
  155. package/dist/scanners.mjs +36 -4
  156. package/dist/sfc-blocks-DaGKDZsb.mjs +213 -0
  157. package/dist/shared-BWaXUmwA.mjs +70 -0
  158. package/dist/shared-D-tbsYmc.mjs +30 -0
  159. package/dist/shared-D4NJBKEP.mjs +17 -0
  160. package/dist/shared-Tq06G0gp.mjs +6 -0
  161. package/dist/shared-meYeVckh.mjs +11 -0
  162. package/dist/vue-compiler-0sfLIiiL.mjs +8 -0
  163. package/package.json +67 -3
  164. package/dist/formats-CFkM5co0.mjs +0 -1370
  165. package/dist/presets-Co5SlnKr.mjs +0 -1187
  166. package/dist/sfc-blocks-BqQ8m9rX.mjs +0 -161
  167. package/dist/yaml-plugin.d.mts +0 -8
  168. package/dist/yaml-plugin.mjs +0 -68
@@ -0,0 +1,83 @@
1
+ import { doubleBraces, nesting } from "./placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/i18next/plugin.ts
4
+ /** `defaultNS` and `fallbackNS` from the i18next init code (`i18n.ts`, `next-i18next.config.js`), as keys without a namespace use them. */
5
+ async function findNamespaces(host) {
6
+ const files = await host.glob(["**/*i18n*.{js,mjs,cjs,ts,mts,cts}", "**/i18n/index.{js,ts}"], {
7
+ ignore: ["**/node_modules/**", "**/dist/**"],
8
+ gitignore: true
9
+ });
10
+ const found = {
11
+ default: void 0,
12
+ fallback: void 0
13
+ };
14
+ for (const file of files.slice(0, 20)) {
15
+ const text = await host.readFile(file) ?? "";
16
+ found.default ??= /\bdefaultNS\s*:\s*['"`]([^'"`]+)['"`]/.exec(text)?.[1];
17
+ const fallback = /\bfallbackNS\s*:\s*(\[[^\]]*\]|['"`][^'"`]+['"`])/.exec(text)?.[1];
18
+ found.fallback ??= fallback ? [...fallback.matchAll(/['"`]([^'"`]+)['"`]/g)].map((m) => m[1]) : void 0;
19
+ }
20
+ return found;
21
+ }
22
+ const i18nextPlugin = createLibraryPlugin({
23
+ name: "x18n:i18next",
24
+ namespace: {
25
+ separator: ":",
26
+ default: "translation",
27
+ fromPath: "slash"
28
+ },
29
+ extra: async (draft, ctx) => {
30
+ const user = ctx.user.namespace;
31
+ if (user?.default && user.fallback) return;
32
+ const found = await findNamespaces(ctx.host);
33
+ draft.namespace = {
34
+ ...draft.namespace,
35
+ default: user?.default ?? found.default ?? draft.namespace.default,
36
+ fallback: user?.fallback ?? found.fallback ?? draft.namespace.fallback
37
+ };
38
+ },
39
+ calls: [
40
+ {
41
+ callee: [
42
+ "t",
43
+ "i18next.t",
44
+ "i18n.t"
45
+ ],
46
+ namespace: {
47
+ arg: 1,
48
+ property: "ns"
49
+ }
50
+ },
51
+ {
52
+ callee: [
53
+ "getFixedT",
54
+ "i18next.getFixedT",
55
+ "i18n.getFixedT"
56
+ ],
57
+ factory: true,
58
+ returns: ["t"],
59
+ namespace: { arg: 1 },
60
+ keyPrefix: { arg: 2 }
61
+ },
62
+ {
63
+ callee: "tr",
64
+ types: ["TFunction"]
65
+ }
66
+ ],
67
+ placeholders: [doubleBraces, nesting],
68
+ derivedKeys: [
69
+ "{key}_ordinal_{ordinal}",
70
+ "{key}_{plural}",
71
+ "{key}_*"
72
+ ],
73
+ translatePrompt: (draft, ctx) => {
74
+ draft.notes.push(`i18next plural keys end in _${ctx.localeInfo.pluralCategories.join(", _")} for ${ctx.targetLocale}; write one key per category.`);
75
+ },
76
+ templates: [{
77
+ template: "i18next.t('{key}'{args})",
78
+ kinds: ["js-string", "js-template"],
79
+ imports: ["import i18next from 'i18next'"]
80
+ }]
81
+ });
82
+ //#endregion
83
+ export { i18nextPlugin as t };
@@ -0,0 +1,12 @@
1
+ //#region src/presets/shared/plural-forms.ts
2
+ /** Not `{plural}`: easy_localization ignores CLDR plural rules by default, and both libraries fall back to `other`. */
3
+ const pluralForms = [
4
+ "zero",
5
+ "one",
6
+ "two",
7
+ "few",
8
+ "many",
9
+ "other"
10
+ ];
11
+ //#endregion
12
+ export { pluralForms as t };
@@ -0,0 +1,6 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/cargo-i18n/index.d.ts
3
+ /** cargo-i18n with the Fluent system: `i18n.toml`, `{assets_dir}/{locale}/{crate}.ftl` and the `fl!` macro of `i18n-embed-fl`. */
4
+ export declare function cargoI18n(): Preset;
5
+ //#endregion
6
+ export { cargoI18n as default };
@@ -0,0 +1,28 @@
1
+ import { fluent } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/cargo-i18n/index.ts
4
+ /** cargo-i18n with the Fluent system: `i18n.toml`, `{assets_dir}/{locale}/{crate}.ftl` and the `fl!` macro of `i18n-embed-fl`. */
5
+ function cargoI18n() {
6
+ return {
7
+ name: "cargo-i18n",
8
+ plugins: [createLibraryPlugin({
9
+ name: "x18n:cargo-i18n",
10
+ regex: [{
11
+ extensions: ["rs"],
12
+ patterns: ["\\bfl!\\(\\s*(?:[^,\"]+,\\s*)?\"({key})\""]
13
+ }],
14
+ derivedKeys: ["{key}.*"],
15
+ extra: async (draft, ctx) => {
16
+ const toml = await ctx.host.readFile("i18n.toml") ?? "";
17
+ const fallback = /^\s*fallback_language\s*=\s*["']([^"']+)["']/m.exec(toml)?.[1];
18
+ if (fallback) draft.sourceLocale = fallback;
19
+ const assetsDir = /^\s*assets_dir\s*=\s*["']([^"']+)["']/m.exec(toml)?.[1]?.replace(/^\.\/|\/$/g, "") ?? "i18n";
20
+ draft.resources = [...draft.resources, { pattern: `${assetsDir}/{locale}/*.ftl` }];
21
+ },
22
+ templates: [{ template: "fl!(LANGUAGE_LOADER, \"{key}\")" }],
23
+ placeholders: [fluent]
24
+ })]
25
+ };
26
+ }
27
+ //#endregion
28
+ export { cargoI18n, cargoI18n as default };
@@ -0,0 +1,6 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/chrome-extension/index.d.ts
3
+ /** Chrome and WebExtension `_locales/{locale}/messages.json`: `{ "name": { "message": "..." } }` reads as `name`. */
4
+ export declare function chromeExtension(): Preset;
5
+ //#endregion
6
+ export { chromeExtension as default };
@@ -0,0 +1,52 @@
1
+ import { dollars } from "../placeholders.mjs";
2
+ import { createLibraryPlugin, isMessageLeaf } from "@x18n/core";
3
+ //#region src/presets/chrome-extension/index.ts
4
+ /** Chrome and WebExtension `_locales/{locale}/messages.json`: `{ "name": { "message": "..." } }` reads as `name`. */
5
+ function chromeExtension() {
6
+ return {
7
+ name: "chrome-extension",
8
+ plugins: [createLibraryPlugin({
9
+ name: "x18n:chrome-extension",
10
+ calls: [{ callee: [
11
+ "chrome.i18n.getMessage",
12
+ "browser.i18n.getMessage",
13
+ "i18n.getMessage"
14
+ ] }],
15
+ regex: [{
16
+ extensions: [
17
+ "json",
18
+ "html",
19
+ "css"
20
+ ],
21
+ patterns: ["__MSG_({key})__"]
22
+ }],
23
+ resources: [{ pattern: "_locales/{locale}/messages.json" }, { pattern: "{src,public,extension}/_locales/{locale}/messages.json" }],
24
+ transformResource: {
25
+ applies: (ctx) => /(?:^|\/)_locales\/[^/]+\/messages\.json$/.test(ctx.path),
26
+ read(tree) {
27
+ const out = {};
28
+ for (const [name, entry] of Object.entries(tree)) {
29
+ const message = isMessageLeaf(entry) ? void 0 : entry.message;
30
+ if (message !== void 0 && isMessageLeaf(message)) out[name] = message;
31
+ }
32
+ return out;
33
+ },
34
+ toStored: (path) => [path.join("."), "message"]
35
+ },
36
+ templates: [{
37
+ template: "chrome.i18n.getMessage('{key}')",
38
+ kinds: ["js-string", "js-template"]
39
+ }],
40
+ placeholders: [dollars]
41
+ }), {
42
+ name: "x18n:chrome-extension-source-locale",
43
+ async config(draft, ctx) {
44
+ const manifest = await ctx.host.readFile("manifest.json") ?? await ctx.host.readFile("src/manifest.json") ?? await ctx.host.readFile("public/manifest.json");
45
+ const locale = manifest ? /"default_locale"\s*:\s*"([^"]+)"/.exec(manifest)?.[1] : void 0;
46
+ if (locale) draft.sourceLocale = locale;
47
+ }
48
+ }]
49
+ };
50
+ }
51
+ //#endregion
52
+ export { chromeExtension, chromeExtension as default };
@@ -0,0 +1,6 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/dotnet-resx/index.d.ts
3
+ /** .NET `IStringLocalizer` and strongly typed resources over `.resx` files: `Strings.resx` holds the source locale, `Strings.de.resx` German. */
4
+ export declare function dotnetResx(): Preset;
5
+ //#endregion
6
+ export { dotnetResx as default };
@@ -0,0 +1,64 @@
1
+ import { dotnet } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/dotnet-resx/index.ts
4
+ /** .NET satellite assemblies: `X.<culture>.resx` translates `X.resx`, so `Views.Shared.Nav.resx` alone is a source file. */
5
+ const resxFinder = {
6
+ id: "dotnet-resx",
7
+ async find(ctx) {
8
+ const paths = new Set(await ctx.host.glob(["**/*.resx"], {
9
+ ignore: [
10
+ "**/node_modules/**",
11
+ "**/bin/**",
12
+ "**/obj/**"
13
+ ],
14
+ gitignore: false
15
+ }));
16
+ return [...paths].map((path) => {
17
+ const satellite = /^(.+)\.([^./]+)\.resx$/.exec(path);
18
+ return {
19
+ path,
20
+ locale: satellite && paths.has(`${satellite[1]}.resx`) ? satellite[2] : ctx.config.sourceLocale,
21
+ namespace: void 0
22
+ };
23
+ });
24
+ },
25
+ resolveNew({ locale, model }, ctx) {
26
+ if (model?.finder !== "dotnet-resx") return void 0;
27
+ const suffix = model.path.endsWith(`.${model.locale}.resx`) ? `.${model.locale}.resx` : ".resx";
28
+ const base = model.path.slice(0, -suffix.length);
29
+ return locale === ctx.config.sourceLocale ? `${base}.resx` : `${base}.${locale}.resx`;
30
+ }
31
+ };
32
+ /** .NET `IStringLocalizer` and strongly typed resources over `.resx` files: `Strings.resx` holds the source locale, `Strings.de.resx` German. */
33
+ function dotnetResx() {
34
+ return {
35
+ name: "dotnet-resx",
36
+ plugins: [createLibraryPlugin({
37
+ name: "x18n:dotnet-resx",
38
+ regex: [{
39
+ extensions: [
40
+ "cs",
41
+ "cshtml",
42
+ "razor"
43
+ ],
44
+ patterns: [
45
+ "\\b(?:\\w*[Ll]ocali[sz]er|L|Loc)\\[\\s*\"([^\"]+)\"",
46
+ "\\b\\w*[Ll]ocali[sz]er\\.Get(?:String|Html)\\(\\s*\"([^\"]+)\"",
47
+ "(?<![\\w.])(?:Properties\\.)?Resources\\.(?!ResourceManager\\b|Culture\\b)([A-Za-z_]\\w*)\\b(?![.(<])"
48
+ ]
49
+ }],
50
+ finders: [resxFinder],
51
+ keyStyle: "flat",
52
+ templates: [{
53
+ template: "@Localizer[\"{key}\"]",
54
+ files: ["**/*.cshtml", "**/*.razor"]
55
+ }, {
56
+ template: "_localizer[\"{key}\"]",
57
+ files: ["**/*.cs"]
58
+ }],
59
+ placeholders: [dotnet]
60
+ })]
61
+ };
62
+ }
63
+ //#endregion
64
+ export { dotnetResx as default, dotnetResx };
@@ -0,0 +1,6 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/easy-localization/index.d.ts
3
+ /** `easy_localization`: `'key'.tr()`, `tr('key')`, `context.tr('key')`, plural and gender forms as nested keys. */
4
+ export declare function easyLocalization(): Preset;
5
+ //#endregion
6
+ export { easyLocalization as default };
@@ -0,0 +1,36 @@
1
+ import { braces, linked, positionalBraces } from "../placeholders.mjs";
2
+ import { t as pluralForms } from "../plural-forms-B7_QX4nG.mjs";
3
+ import { createLibraryPlugin } from "@x18n/core";
4
+ //#region src/presets/easy-localization/index.ts
5
+ /** `easy_localization`: `'key'.tr()`, `tr('key')`, `context.tr('key')`, plural and gender forms as nested keys. */
6
+ function easyLocalization() {
7
+ return {
8
+ name: "easy-localization",
9
+ plugins: [createLibraryPlugin({
10
+ name: "x18n:easy-localization",
11
+ regex: [{
12
+ extensions: ["dart"],
13
+ patterns: [
14
+ "['\"]({key})['\"]\\s*\\.(?:tr|plural)\\(",
15
+ "(?<![\\w$])Text\\(\\s*['\"]({key})['\"]\\s*\\)\\s*\\.(?:tr|plural)\\(",
16
+ "(?<![\\w$.])(?:context\\.)?(?:tr|plural)\\(\\s*['\"]({key})['\"]"
17
+ ]
18
+ }],
19
+ derivedKeys: [
20
+ ...pluralForms,
21
+ "male",
22
+ "female"
23
+ ].map((form) => `{key}.${form}`),
24
+ resources: [{ pattern: "assets/translations/{locale}.{ext}" }],
25
+ keyStyle: "nested",
26
+ templates: [{ template: "'{key}'.tr()" }],
27
+ placeholders: [
28
+ positionalBraces,
29
+ braces,
30
+ linked
31
+ ]
32
+ })]
33
+ };
34
+ }
35
+ //#endregion
36
+ export { easyLocalization as default, easyLocalization };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/ember-intl/index.d.ts
3
+ export declare function emberIntl(): Preset;
4
+ //#endregion
5
+ export { emberIntl as default };
@@ -0,0 +1,31 @@
1
+ import { icu } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/ember-intl/index.ts
4
+ function emberIntl() {
5
+ return {
6
+ name: "ember-intl",
7
+ plugins: [createLibraryPlugin({
8
+ name: "x18n:ember-intl",
9
+ calls: [{ callee: ["intl.t"] }],
10
+ regex: [{
11
+ extensions: [
12
+ "hbs",
13
+ "gjs",
14
+ "gts"
15
+ ],
16
+ patterns: ["\\{\\{\\s*t\\s+['\"`]({key})['\"`]", "\\(\\s*t\\s+['\"`]({key})['\"`]"]
17
+ }],
18
+ resources: [{ pattern: "translations/{locale}.{ext}" }, { pattern: "translations/{namespaces}/{locale}.{ext}" }],
19
+ templates: [{
20
+ template: "{{t '{key}'}}",
21
+ files: ["**/*.hbs"]
22
+ }, {
23
+ template: "this.intl.t('{key}'{args})",
24
+ kinds: ["js-string", "js-template"]
25
+ }],
26
+ placeholders: [icu]
27
+ })]
28
+ };
29
+ }
30
+ //#endregion
31
+ export { emberIntl as default, emberIntl };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/fluent-react/index.d.ts
3
+ export declare function fluentReact(): Preset;
4
+ //#endregion
5
+ export { fluentReact as default };
@@ -0,0 +1,46 @@
1
+ import { fluent } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/fluent-react/index.ts
4
+ function fluentReact() {
5
+ return {
6
+ name: "fluent-react",
7
+ plugins: [createLibraryPlugin({
8
+ name: "x18n:fluent-react",
9
+ calls: [{
10
+ callee: "Localized",
11
+ key: {
12
+ arg: 0,
13
+ property: "id"
14
+ }
15
+ }, { callee: [
16
+ "l10n.getString",
17
+ "props.getString",
18
+ "this.props.getString"
19
+ ] }],
20
+ derivedKeys: ["{key}.*"],
21
+ resources: [
22
+ { pattern: "public/locales/{locale}/*.ftl" },
23
+ { pattern: "locales/{locale}.ftl" },
24
+ { pattern: "src/locales/{locale}.ftl" }
25
+ ],
26
+ templates: [
27
+ {
28
+ template: "<Localized id=\"{key}\" />",
29
+ kinds: ["jsx-text"],
30
+ imports: ["import { Localized } from '@fluent/react'"]
31
+ },
32
+ {
33
+ template: "{attr}={l10n.getString('{key}'{args})}",
34
+ kinds: ["jsx-attribute"]
35
+ },
36
+ {
37
+ template: "l10n.getString('{key}'{args})",
38
+ kinds: ["js-string", "js-template"]
39
+ }
40
+ ],
41
+ placeholders: [fluent]
42
+ })]
43
+ };
44
+ }
45
+ //#endregion
46
+ export { fluentReact as default, fluentReact };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/fluent-vue/index.d.ts
3
+ export declare function fluentVue(): Preset;
4
+ //#endregion
5
+ export { fluentVue as default };
@@ -0,0 +1,51 @@
1
+ import { n as sfcFluentBlocks } from "../sfc-blocks-DaGKDZsb.mjs";
2
+ import { fluent } from "../placeholders.mjs";
3
+ import { createLibraryPlugin } from "@x18n/core";
4
+ //#region src/presets/fluent-vue/index.ts
5
+ function fluentVue() {
6
+ return {
7
+ name: "fluent-vue",
8
+ plugins: [createLibraryPlugin({
9
+ name: "x18n:fluent-vue",
10
+ calls: [{ callee: [
11
+ "$t",
12
+ "$ta",
13
+ "fluent.format",
14
+ "fluent.formatAttrs",
15
+ "this.$t",
16
+ "this.$ta"
17
+ ] }, {
18
+ callee: "useFluent",
19
+ factory: true,
20
+ returns: [
21
+ "$t",
22
+ "$ta",
23
+ "format",
24
+ "formatAttrs"
25
+ ]
26
+ }],
27
+ regex: [{
28
+ extensions: ["vue"],
29
+ patterns: ["v-t:({key})[\\s\\n=>]", "<i18n[\\s\\n]+path=['\"`]({key})['\"`]"]
30
+ }],
31
+ resources: [{ pattern: "locales/{locale}.ftl" }, { pattern: "src/locales/{locale}.ftl" }],
32
+ templates: [
33
+ {
34
+ template: "{{ $t('{key}'{args}) }}",
35
+ kinds: ["vue-template-text"]
36
+ },
37
+ {
38
+ template: ":{attr}=\"$t('{key}'{args})\"",
39
+ kinds: ["vue-attribute"]
40
+ },
41
+ {
42
+ template: "$t('{key}'{args})",
43
+ kinds: ["js-string", "js-template"]
44
+ }
45
+ ],
46
+ placeholders: [fluent]
47
+ }), sfcFluentBlocks()]
48
+ };
49
+ }
50
+ //#endregion
51
+ export { fluentVue as default, fluentVue };
@@ -0,0 +1,6 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/flutter-translate/index.d.ts
3
+ /** `flutter_translate`: `translate('key')`, `translatePlural('key', n)` with plural forms as nested keys. */
4
+ export declare function flutterTranslate(): Preset;
5
+ //#endregion
6
+ export { flutterTranslate as default };
@@ -0,0 +1,30 @@
1
+ import { braces, doubleBraces } from "../placeholders.mjs";
2
+ import { t as pluralForms } from "../plural-forms-B7_QX4nG.mjs";
3
+ import { createLibraryPlugin } from "@x18n/core";
4
+ //#region src/presets/flutter-translate/index.ts
5
+ /** `flutter_translate`: `translate('key')`, `translatePlural('key', n)` with plural forms as nested keys. */
6
+ function flutterTranslate() {
7
+ return {
8
+ name: "flutter-translate",
9
+ plugins: [createLibraryPlugin({
10
+ name: "x18n:flutter-translate",
11
+ regex: [{
12
+ extensions: ["dart"],
13
+ patterns: ["(?<![\\w$.])translate(?:Plural)?\\(\\s*['\"]({key})['\"]"]
14
+ }],
15
+ derivedKeys: [
16
+ ...pluralForms,
17
+ "0",
18
+ "1",
19
+ "2",
20
+ "else"
21
+ ].map((form) => `{key}.${form}`),
22
+ resources: [{ pattern: "assets/i18n/{locale}.{ext}" }],
23
+ keyStyle: "nested",
24
+ templates: [{ template: "translate('{key}')" }],
25
+ placeholders: [braces, doubleBraces]
26
+ })]
27
+ };
28
+ }
29
+ //#endregion
30
+ export { flutterTranslate as default, flutterTranslate };
@@ -0,0 +1,6 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/flutter/index.d.ts
3
+ /** Flutter with `flutter_i18n`: JSON or YAML assets, `FlutterI18n.translate(context, 'key')`. */
4
+ export declare function flutter(): Preset;
5
+ //#endregion
6
+ export { flutter as default };
@@ -0,0 +1,21 @@
1
+ import { braces } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/flutter/index.ts
4
+ /** Flutter with `flutter_i18n`: JSON or YAML assets, `FlutterI18n.translate(context, 'key')`. */
5
+ function flutter() {
6
+ return {
7
+ name: "flutter",
8
+ plugins: [createLibraryPlugin({
9
+ name: "x18n:flutter",
10
+ regex: [{
11
+ extensions: ["dart"],
12
+ patterns: ["[^\\w\\d]FlutterI18n\\.(?:plural|translate)\\(\\s*[\\w\\d.]+,\\s*['\"`]({key})['\"`]", "[^\\w\\d]I18n(?:Plural|Text)\\(\\s*['\"`]({key})['\"`]"]
13
+ }],
14
+ resources: [{ pattern: "assets/flutter_i18n/{locale}.{ext}" }, { pattern: "assets/i18n/{locale}.{ext}" }],
15
+ templates: [{ template: "FlutterI18n.translate(context, '{key}')" }],
16
+ placeholders: [braces]
17
+ })]
18
+ };
19
+ }
20
+ //#endregion
21
+ export { flutter as default, flutter };
@@ -0,0 +1,6 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/general/index.d.ts
3
+ /** Always last: hard-string extraction templates for plain JS, TS and HTML. */
4
+ export declare function general(): Preset;
5
+ //#endregion
6
+ export { general as default };
@@ -0,0 +1,17 @@
1
+ import { defaultTemplates } from "../extractors.mjs";
2
+ //#region src/presets/general/index.ts
3
+ /** Always last: hard-string extraction templates for plain JS, TS and HTML. */
4
+ function general() {
5
+ return {
6
+ name: "general",
7
+ plugins: [{
8
+ name: "x18n:general",
9
+ extractors: [{
10
+ id: "general",
11
+ templates: defaultTemplates
12
+ }]
13
+ }]
14
+ };
15
+ }
16
+ //#endregion
17
+ export { general as default, general };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/globalize/index.d.ts
3
+ export declare function globalize(): Preset;
4
+ //#endregion
5
+ export { globalize as default };
@@ -0,0 +1,25 @@
1
+ import { icu } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/globalize/index.ts
4
+ function globalize() {
5
+ return {
6
+ name: "globalize",
7
+ plugins: [createLibraryPlugin({
8
+ name: "x18n:globalize",
9
+ calls: [{ callee: [
10
+ "Globalize.messageFormatter",
11
+ "Globalize.formatMessage",
12
+ "globalize.messageFormatter",
13
+ "globalize.formatMessage"
14
+ ] }],
15
+ normalizeKey: (raw) => raw.includes("/") ? raw.replace(/\//g, ".") : void 0,
16
+ templates: [{
17
+ template: "Globalize.formatMessage('{key}'{args})",
18
+ kinds: ["js-string", "js-template"]
19
+ }],
20
+ placeholders: [icu]
21
+ })]
22
+ };
23
+ }
24
+ //#endregion
25
+ export { globalize as default, globalize };
@@ -0,0 +1,6 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/gravity-ui-i18n/index.d.ts
3
+ /** @gravity-ui/i18n keysets as key prefixes. Adapted from the i18n-ally (MIT) gravity-i18n framework of lokalise/i18n-ally#1124. */
4
+ export declare function gravityUiI18n(): Preset;
5
+ //#endregion
6
+ export { gravityUiI18n as default };
@@ -0,0 +1,41 @@
1
+ import { doubleBraces } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/gravity-ui-i18n/index.ts
4
+ /** @gravity-ui/i18n keysets as key prefixes. Adapted from the i18n-ally (MIT) gravity-i18n framework of lokalise/i18n-ally#1124. */
5
+ function gravityUiI18n() {
6
+ return {
7
+ name: "gravity-ui-i18n",
8
+ plugins: [createLibraryPlugin({
9
+ name: "x18n:gravity-ui-i18n",
10
+ calls: [
11
+ {
12
+ callee: ["i18n.i18n", "i18nInstance.i18n"],
13
+ key: 1,
14
+ keyPrefix: { arg: 0 }
15
+ },
16
+ {
17
+ callee: ["i18n.keyset", "i18nInstance.keyset"],
18
+ factory: true,
19
+ keyPrefix: { arg: 0 }
20
+ },
21
+ {
22
+ callee: ["i18n.bind", "i18nInstance.i18n.bind"],
23
+ factory: true,
24
+ keyPrefix: { arg: 1 }
25
+ }
26
+ ],
27
+ derivedKeys: [
28
+ "zero",
29
+ "one",
30
+ "two",
31
+ "few",
32
+ "many",
33
+ "other"
34
+ ].map((form) => `{key}.${form}`),
35
+ resources: [{ pattern: "src/i18n-keysets/{namespaces}/{locale}.json" }, { pattern: "src/**/{namespace}/i18n/{locale}.json" }],
36
+ placeholders: [doubleBraces]
37
+ })]
38
+ };
39
+ }
40
+ //#endregion
41
+ export { gravityUiI18n as default, gravityUiI18n };
@@ -0,0 +1,5 @@
1
+ import { Preset } from "@x18n/core";
2
+ //#region src/presets/i18n-js/index.d.ts
3
+ export declare function i18nJs(): Preset;
4
+ //#endregion
5
+ export { i18nJs as default };
@@ -0,0 +1,19 @@
1
+ import { percentBraces } from "../placeholders.mjs";
2
+ import { createLibraryPlugin } from "@x18n/core";
3
+ //#region src/presets/i18n-js/index.ts
4
+ function i18nJs() {
5
+ return {
6
+ name: "i18n-js",
7
+ plugins: [createLibraryPlugin({
8
+ name: "x18n:i18n-js",
9
+ calls: [{ callee: ["I18n.t", "i18n.t"] }],
10
+ templates: [{
11
+ template: "i18n.t('{key}'{args})",
12
+ kinds: ["js-string", "js-template"]
13
+ }],
14
+ placeholders: [percentBraces]
15
+ })]
16
+ };
17
+ }
18
+ //#endregion
19
+ export { i18nJs as default, i18nJs };