@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.
- package/dist/angular-templates-DqIOGfzT.mjs +8 -0
- package/dist/checks.d.mts +1 -0
- package/dist/checks.mjs +26 -1
- package/dist/extractors.mjs +7 -3
- package/dist/finders.d.mts +4 -1
- package/dist/finders.mjs +1 -1
- package/dist/formats/ecmascript.d.mts +5 -0
- package/dist/formats/ecmascript.mjs +232 -0
- package/dist/formats/ftl.d.mts +5 -0
- package/dist/formats/ftl.mjs +234 -0
- package/dist/formats/ini.d.mts +5 -0
- package/dist/formats/ini.mjs +158 -0
- package/dist/formats/json.d.mts +6 -0
- package/dist/formats/json.mjs +10 -0
- package/dist/formats/json5.d.mts +5 -0
- package/dist/formats/json5.mjs +143 -0
- package/dist/formats/jsonc.d.mts +6 -0
- package/dist/formats/jsonc.mjs +10 -0
- package/dist/formats/php.d.mts +5 -0
- package/dist/formats/php.mjs +198 -0
- package/dist/formats/po.d.mts +5 -0
- package/dist/formats/po.mjs +177 -0
- package/dist/formats/properties.d.mts +5 -0
- package/dist/formats/properties.mjs +123 -0
- package/dist/formats/resx.d.mts +6 -0
- package/dist/formats/resx.mjs +202 -0
- package/dist/formats/yaml.d.mts +5 -0
- package/dist/formats/yaml.mjs +140 -0
- package/dist/formats.d.mts +10 -34
- package/dist/formats.mjs +61 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +30 -22
- package/dist/{vue-CF4pe-Yr.mjs → js-CV-ECNJG.mjs} +67 -222
- package/dist/json-CGNSGS97.mjs +109 -0
- package/dist/json-CyjI8bjp.d.mts +8 -0
- package/dist/jsx-templates-B1J0no3i.mjs +17 -0
- package/dist/literal-gIdB1VGy.mjs +125 -0
- package/dist/locale-root-C_rch3IQ.mjs +15 -0
- package/dist/manifests.d.mts +8 -0
- package/dist/manifests.mjs +66 -2
- package/dist/placeholders.d.mts +11 -0
- package/dist/placeholders.mjs +28 -1
- package/dist/plugin-Cb1b0axD.mjs +83 -0
- package/dist/plural-forms-B7_QX4nG.mjs +12 -0
- package/dist/presets/cargo-i18n.d.mts +6 -0
- package/dist/presets/cargo-i18n.mjs +28 -0
- package/dist/presets/chrome-extension.d.mts +6 -0
- package/dist/presets/chrome-extension.mjs +52 -0
- package/dist/presets/dotnet-resx.d.mts +6 -0
- package/dist/presets/dotnet-resx.mjs +64 -0
- package/dist/presets/easy-localization.d.mts +6 -0
- package/dist/presets/easy-localization.mjs +36 -0
- package/dist/presets/ember-intl.d.mts +5 -0
- package/dist/presets/ember-intl.mjs +31 -0
- package/dist/presets/fluent-react.d.mts +5 -0
- package/dist/presets/fluent-react.mjs +46 -0
- package/dist/presets/fluent-vue.d.mts +5 -0
- package/dist/presets/fluent-vue.mjs +51 -0
- package/dist/presets/flutter-translate.d.mts +6 -0
- package/dist/presets/flutter-translate.mjs +30 -0
- package/dist/presets/flutter.d.mts +6 -0
- package/dist/presets/flutter.mjs +21 -0
- package/dist/presets/general.d.mts +6 -0
- package/dist/presets/general.mjs +17 -0
- package/dist/presets/globalize.d.mts +5 -0
- package/dist/presets/globalize.mjs +25 -0
- package/dist/presets/gravity-ui-i18n.d.mts +6 -0
- package/dist/presets/gravity-ui-i18n.mjs +41 -0
- package/dist/presets/i18n-tag.d.mts +5 -0
- package/dist/presets/i18n-tag.mjs +21 -0
- package/dist/presets/i18next-shopify.d.mts +6 -0
- package/dist/presets/i18next-shopify.mjs +23 -0
- package/dist/presets/i18next.d.mts +5 -0
- package/dist/presets/i18next.mjs +10 -0
- package/dist/presets/i18nice.d.mts +6 -0
- package/dist/presets/i18nice.mjs +29 -0
- package/dist/presets/jekyll.d.mts +5 -0
- package/dist/presets/jekyll.mjs +23 -0
- package/dist/presets/laravel-vue-i18n.d.mts +6 -0
- package/dist/presets/laravel-vue-i18n.mjs +54 -0
- package/dist/presets/laravel.d.mts +6 -0
- package/dist/presets/laravel.mjs +23 -0
- package/dist/presets/lingui.d.mts +5 -0
- package/dist/presets/lingui.mjs +61 -0
- package/dist/presets/next-international.d.mts +5 -0
- package/dist/presets/next-international.mjs +27 -0
- package/dist/presets/next-intl.d.mts +5 -0
- package/dist/presets/next-intl.mjs +55 -0
- package/dist/presets/next-translate.d.mts +5 -0
- package/dist/presets/next-translate.mjs +53 -0
- package/dist/presets/ngx-translate.d.mts +5 -0
- package/dist/presets/ngx-translate.mjs +41 -0
- package/dist/presets/nuxt-i18n-micro.d.mts +5 -0
- package/dist/presets/nuxt-i18n-micro.mjs +81 -0
- package/dist/presets/nuxt-i18n.d.mts +5 -0
- package/dist/presets/nuxt-i18n.mjs +23 -0
- package/dist/presets/paraglide.d.mts +5 -0
- package/dist/presets/paraglide.mjs +38 -0
- package/dist/presets/php-gettext.d.mts +6 -0
- package/dist/presets/php-gettext.mjs +27 -0
- package/dist/presets/php-joomla.d.mts +6 -0
- package/dist/presets/php-joomla.mjs +22 -0
- package/dist/presets/polyglot.d.mts +5 -0
- package/dist/presets/polyglot.mjs +23 -0
- package/dist/presets/python-gettext.d.mts +6 -0
- package/dist/presets/python-gettext.mjs +44 -0
- package/dist/presets/react-i18next.d.mts +5 -0
- package/dist/presets/react-i18next.mjs +67 -0
- package/dist/presets/react-intl.d.mts +5 -0
- package/dist/presets/react-intl.mjs +47 -0
- package/dist/presets/ruby-i18n-js.d.mts +5 -0
- package/dist/presets/ruby-i18n-js.mjs +19 -0
- package/dist/presets/ruby-rails.d.mts +7 -0
- package/dist/presets/ruby-rails.mjs +44 -0
- package/dist/presets/solid-primitives-i18n.d.mts +5 -0
- package/dist/presets/solid-primitives-i18n.mjs +29 -0
- package/dist/presets/svelte-i18n.d.mts +5 -0
- package/dist/presets/svelte-i18n.mjs +33 -0
- package/dist/presets/svelte-i18next.d.mts +5 -0
- package/dist/presets/svelte-i18next.mjs +27 -0
- package/dist/presets/transloco.d.mts +5 -0
- package/dist/presets/transloco.mjs +44 -0
- package/dist/presets/typesafe-i18n.d.mts +6 -0
- package/dist/presets/typesafe-i18n.mjs +61 -0
- package/dist/presets/ui5.d.mts +5 -0
- package/dist/presets/ui5.mjs +35 -0
- package/dist/presets/vscode-extension.d.mts +5 -0
- package/dist/presets/vscode-extension.mjs +53 -0
- package/dist/presets/vue-i18n.d.mts +5 -0
- package/dist/presets/vue-i18n.mjs +59 -0
- package/dist/presets.d.mts +7 -54
- package/dist/presets.mjs +346 -1
- package/dist/reporters/github.d.mts +6 -0
- package/dist/reporters/github.mjs +27 -0
- package/dist/reporters/json.d.mts +6 -0
- package/dist/reporters/json.mjs +24 -0
- package/dist/reporters/markdown.d.mts +6 -0
- package/dist/reporters/markdown.mjs +37 -0
- package/dist/reporters/pretty.d.mts +6 -0
- package/dist/reporters/pretty.mjs +64 -0
- package/dist/reporters/sarif.d.mts +6 -0
- package/dist/reporters/sarif.mjs +48 -0
- package/dist/reporters.d.mts +5 -12
- package/dist/reporters.mjs +8 -218
- package/dist/reviews.d.mts +6 -0
- package/dist/reviews.mjs +35 -0
- package/dist/scanners/astro.d.mts +6 -0
- package/dist/scanners/astro.mjs +256 -0
- package/dist/scanners/js.d.mts +6 -0
- package/dist/scanners/js.mjs +33 -0
- package/dist/scanners/regex-scopes.d.mts +14 -0
- package/dist/scanners/regex-scopes.mjs +41 -0
- package/dist/scanners/regex.d.mts +9 -0
- package/dist/{regex-AYVhuSb6.mjs → scanners/regex.mjs} +2 -40
- package/dist/scanners/svelte.d.mts +6 -0
- package/dist/{scanners-DhnnVp7s.mjs → scanners/svelte.mjs} +3 -3
- package/dist/scanners/vue.d.mts +6 -0
- package/dist/scanners/vue.mjs +172 -0
- package/dist/scanners.d.mts +9 -50
- package/dist/scanners.mjs +36 -4
- package/dist/sfc-blocks-DaGKDZsb.mjs +213 -0
- package/dist/shared-C7ceptwi.mjs +55 -0
- package/dist/shared-D-tbsYmc.mjs +30 -0
- package/dist/shared-D4NJBKEP.mjs +17 -0
- package/dist/shared-Tq06G0gp.mjs +6 -0
- package/dist/shared-meYeVckh.mjs +11 -0
- package/dist/vue-compiler-0sfLIiiL.mjs +8 -0
- package/package.json +68 -3
- package/dist/formats-CFkM5co0.mjs +0 -1370
- package/dist/presets-Co5SlnKr.mjs +0 -1187
- package/dist/sfc-blocks-BqQ8m9rX.mjs +0 -161
- package/dist/yaml-plugin.d.mts +0 -8
- package/dist/yaml-plugin.mjs +0 -68
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { braces } from "../placeholders.mjs";
|
|
2
|
+
import { t as jsxTemplates } from "../jsx-templates-B1J0no3i.mjs";
|
|
3
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
4
|
+
//#region src/presets/next-international/index.ts
|
|
5
|
+
function nextInternational() {
|
|
6
|
+
return {
|
|
7
|
+
name: "next-international",
|
|
8
|
+
plugins: [createLibraryPlugin({
|
|
9
|
+
name: "x18n:next-international",
|
|
10
|
+
calls: [{
|
|
11
|
+
callee: ["useI18n", "getI18n"],
|
|
12
|
+
factory: true,
|
|
13
|
+
returns: ["t"]
|
|
14
|
+
}, {
|
|
15
|
+
callee: ["useScopedI18n", "getScopedI18n"],
|
|
16
|
+
factory: true,
|
|
17
|
+
returns: ["t"],
|
|
18
|
+
keyPrefix: { arg: 0 }
|
|
19
|
+
}],
|
|
20
|
+
resources: [{ pattern: "locales/{locale}.{ext}" }, { pattern: "src/locales/{locale}.{ext}" }],
|
|
21
|
+
templates: jsxTemplates,
|
|
22
|
+
placeholders: [braces]
|
|
23
|
+
})]
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { nextInternational as default, nextInternational };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { icu } from "../placeholders.mjs";
|
|
2
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
3
|
+
//#region src/presets/next-intl/index.ts
|
|
4
|
+
function nextIntl() {
|
|
5
|
+
return {
|
|
6
|
+
name: "next-intl",
|
|
7
|
+
plugins: [createLibraryPlugin({
|
|
8
|
+
name: "x18n:next-intl",
|
|
9
|
+
calls: [{
|
|
10
|
+
callee: ["useTranslations", "getTranslations"],
|
|
11
|
+
factory: true,
|
|
12
|
+
returns: [
|
|
13
|
+
"t",
|
|
14
|
+
"t.rich",
|
|
15
|
+
"t.markup",
|
|
16
|
+
"t.raw",
|
|
17
|
+
"t.has"
|
|
18
|
+
],
|
|
19
|
+
keyPrefix: { arg: 0 }
|
|
20
|
+
}, {
|
|
21
|
+
callee: "getTranslations",
|
|
22
|
+
factory: true,
|
|
23
|
+
returns: [
|
|
24
|
+
"t",
|
|
25
|
+
"t.rich",
|
|
26
|
+
"t.markup",
|
|
27
|
+
"t.raw",
|
|
28
|
+
"t.has"
|
|
29
|
+
],
|
|
30
|
+
keyPrefix: {
|
|
31
|
+
arg: 0,
|
|
32
|
+
property: "namespace"
|
|
33
|
+
}
|
|
34
|
+
}],
|
|
35
|
+
resources: [{ pattern: "messages/{locale}.json" }, { pattern: "src/messages/{locale}.json" }],
|
|
36
|
+
templates: [
|
|
37
|
+
{
|
|
38
|
+
template: "{t('{key}'{args})}",
|
|
39
|
+
kinds: ["jsx-text"]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
template: "{attr}={t('{key}'{args})}",
|
|
43
|
+
kinds: ["jsx-attribute"]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
template: "t('{key}'{args})",
|
|
47
|
+
kinds: ["js-string", "js-template"]
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
placeholders: [icu]
|
|
51
|
+
})]
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { nextIntl as default, nextIntl };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { doubleBraces } from "../placeholders.mjs";
|
|
2
|
+
import { n as scriptExtensions } from "../shared-D4NJBKEP.mjs";
|
|
3
|
+
import { t as jsxTemplates } from "../jsx-templates-B1J0no3i.mjs";
|
|
4
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
5
|
+
//#region src/presets/next-translate/index.ts
|
|
6
|
+
function nextTranslate() {
|
|
7
|
+
return {
|
|
8
|
+
name: "next-translate",
|
|
9
|
+
plugins: [createLibraryPlugin({
|
|
10
|
+
name: "x18n:next-translate",
|
|
11
|
+
namespace: {
|
|
12
|
+
separator: ":",
|
|
13
|
+
default: "common"
|
|
14
|
+
},
|
|
15
|
+
calls: [
|
|
16
|
+
{
|
|
17
|
+
callee: "useTranslation",
|
|
18
|
+
factory: true,
|
|
19
|
+
returns: ["t"],
|
|
20
|
+
namespace: { arg: 0 }
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
callee: "getT",
|
|
24
|
+
factory: true,
|
|
25
|
+
returns: ["t"],
|
|
26
|
+
namespace: { arg: 1 }
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
callee: "Trans",
|
|
30
|
+
key: {
|
|
31
|
+
arg: 0,
|
|
32
|
+
property: "i18nKey"
|
|
33
|
+
},
|
|
34
|
+
namespace: {
|
|
35
|
+
arg: 0,
|
|
36
|
+
property: "ns"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{ callee: "t" }
|
|
40
|
+
],
|
|
41
|
+
regex: [{
|
|
42
|
+
extensions: scriptExtensions,
|
|
43
|
+
patterns: ["[^\\w\\d]t`({key})`"]
|
|
44
|
+
}],
|
|
45
|
+
resources: [{ pattern: "locales/{locale}/{namespace}.json" }],
|
|
46
|
+
keyStyle: "nested",
|
|
47
|
+
templates: jsxTemplates,
|
|
48
|
+
placeholders: [doubleBraces]
|
|
49
|
+
})]
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { nextTranslate as default, nextTranslate };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { doubleBraces } from "../placeholders.mjs";
|
|
2
|
+
import { t as angularTemplates } from "../angular-templates-DqIOGfzT.mjs";
|
|
3
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
4
|
+
//#region src/presets/ngx-translate/index.ts
|
|
5
|
+
function ngxTranslate() {
|
|
6
|
+
return {
|
|
7
|
+
name: "ngx-translate",
|
|
8
|
+
plugins: [createLibraryPlugin({
|
|
9
|
+
name: "x18n:ngx-translate",
|
|
10
|
+
calls: [{ callee: [
|
|
11
|
+
"translate.instant",
|
|
12
|
+
"translate.get",
|
|
13
|
+
"translate.stream",
|
|
14
|
+
"translateService.instant",
|
|
15
|
+
"translateService.get",
|
|
16
|
+
"translateService.stream",
|
|
17
|
+
"_"
|
|
18
|
+
] }],
|
|
19
|
+
regex: [{
|
|
20
|
+
extensions: angularTemplates,
|
|
21
|
+
patterns: [
|
|
22
|
+
"[`'\"]({key})[`'\"][\\s\\n]*\\|[\\s\\n]*translate\\b",
|
|
23
|
+
"[\\s\\n]translate>[\\s\\n]*({key})[\\s\\n]*</",
|
|
24
|
+
"\\[translate\\]=[\"']'({key})'[\"']",
|
|
25
|
+
"\\stranslate=[\"']({key})[\"']"
|
|
26
|
+
]
|
|
27
|
+
}],
|
|
28
|
+
resources: [{ pattern: "src/assets/i18n/{locale}.json" }, { pattern: "src/assets/i18n/{locale}/{namespaces}.json" }],
|
|
29
|
+
templates: [{
|
|
30
|
+
template: "{{ '{key}' | translate }}",
|
|
31
|
+
kinds: ["html-text"]
|
|
32
|
+
}, {
|
|
33
|
+
template: "this.translate.instant('{key}'{args})",
|
|
34
|
+
kinds: ["js-string", "js-template"]
|
|
35
|
+
}],
|
|
36
|
+
placeholders: [doubleBraces]
|
|
37
|
+
})]
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { ngxTranslate as default, ngxTranslate };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { braces } from "../placeholders.mjs";
|
|
2
|
+
import { t as readNuxtConfig } from "../shared-Tq06G0gp.mjs";
|
|
3
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
4
|
+
//#region src/presets/nuxt-i18n-micro/index.ts
|
|
5
|
+
/** Nuxt's route name of a page component, which names its translation folder: `pages/products/[id].vue` is `products-id`. Route groups like `(admin)` are not part of it. */
|
|
6
|
+
function routeName(path) {
|
|
7
|
+
const segments = /^(?:app\/)?pages\/(.+)\.vue$/.exec(path)?.[1]?.split("/").filter((segment) => !/^\(.+\)$/.test(segment));
|
|
8
|
+
if (!segments?.length) return void 0;
|
|
9
|
+
if (segments.length > 1 && segments.at(-1) === "index") segments.pop();
|
|
10
|
+
return segments.join("-").replace(/[[\].]/g, "");
|
|
11
|
+
}
|
|
12
|
+
function nuxtI18nMicro() {
|
|
13
|
+
const returns = [
|
|
14
|
+
"$t",
|
|
15
|
+
"$ts",
|
|
16
|
+
"$tc",
|
|
17
|
+
"$has"
|
|
18
|
+
];
|
|
19
|
+
return {
|
|
20
|
+
name: "nuxt-i18n-micro",
|
|
21
|
+
plugins: [createLibraryPlugin({
|
|
22
|
+
name: "x18n:nuxt-i18n-micro",
|
|
23
|
+
calls: [{ callee: returns }, {
|
|
24
|
+
callee: ["useI18n", "useNuxtApp"],
|
|
25
|
+
factory: true,
|
|
26
|
+
returns
|
|
27
|
+
}],
|
|
28
|
+
templates: [
|
|
29
|
+
{
|
|
30
|
+
template: "{{ $t('{key}'{args}) }}",
|
|
31
|
+
kinds: ["vue-template-text"]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
template: ":{attr}=\"$t('{key}'{args})\"",
|
|
35
|
+
kinds: ["vue-attribute"]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
template: "$t('{key}'{args})",
|
|
39
|
+
kinds: ["js-string", "js-template"],
|
|
40
|
+
files: ["**/*.vue"],
|
|
41
|
+
imports: ["import { useI18n } from '#imports'", "const { $t } = useI18n()"]
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
extra: async (draft, ctx) => {
|
|
45
|
+
const nuxtConfig = await readNuxtConfig(ctx.host);
|
|
46
|
+
const dir = nuxtConfig && /translationDir:\s*['"]([^'"]+)['"]/.exec(nuxtConfig)?.[1]?.replace(/^\.\/|\/$/g, "") || "locales";
|
|
47
|
+
draft.resources = [
|
|
48
|
+
...draft.resources,
|
|
49
|
+
{ pattern: `${dir}/{locale}.json` },
|
|
50
|
+
{ pattern: `${dir}/{namespaces}/{locale}.json` }
|
|
51
|
+
];
|
|
52
|
+
},
|
|
53
|
+
placeholders: [{
|
|
54
|
+
...braces,
|
|
55
|
+
implicit: ["count"]
|
|
56
|
+
}]
|
|
57
|
+
}), {
|
|
58
|
+
name: "x18n:nuxt-i18n-micro-pages",
|
|
59
|
+
scanners: [{
|
|
60
|
+
id: "nuxt-i18n-micro-pages",
|
|
61
|
+
extensions: ["vue"],
|
|
62
|
+
scan(file) {
|
|
63
|
+
const route = routeName(file.path);
|
|
64
|
+
return {
|
|
65
|
+
usages: [],
|
|
66
|
+
scopes: route ? [{
|
|
67
|
+
range: {
|
|
68
|
+
start: 0,
|
|
69
|
+
end: file.text.length
|
|
70
|
+
},
|
|
71
|
+
keyPrefix: `pages.${route}`,
|
|
72
|
+
optionalPrefix: true
|
|
73
|
+
}] : []
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}]
|
|
77
|
+
}]
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
export { nuxtI18nMicro as default, nuxtI18nMicro };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import vueI18n from "./vue-i18n.mjs";
|
|
2
|
+
import { t as readNuxtConfig } from "../shared-Tq06G0gp.mjs";
|
|
3
|
+
//#region src/presets/nuxt-i18n/index.ts
|
|
4
|
+
function nuxtI18n() {
|
|
5
|
+
return {
|
|
6
|
+
name: "nuxt-i18n",
|
|
7
|
+
plugins: [...vueI18n().plugins, {
|
|
8
|
+
name: "x18n:nuxt-i18n",
|
|
9
|
+
async config(draft, ctx) {
|
|
10
|
+
const nuxtConfig = await readNuxtConfig(ctx.host);
|
|
11
|
+
const langDir = nuxtConfig ? /langDir:\s*['"]([^'"]+)['"]/.exec(nuxtConfig)?.[1]?.replace(/^\.\/|\/$/g, "") : void 0;
|
|
12
|
+
const dirs = langDir ? [`i18n/${langDir}`, langDir] : [
|
|
13
|
+
"i18n/locales",
|
|
14
|
+
"locales",
|
|
15
|
+
"lang"
|
|
16
|
+
];
|
|
17
|
+
draft.resources = [...draft.resources, ...dirs.map((dir) => ({ pattern: `${dir}/{locale}.{ext}` }))];
|
|
18
|
+
}
|
|
19
|
+
}]
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { nuxtI18n as default, nuxtI18n };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { braces } from "../placeholders.mjs";
|
|
2
|
+
import { n as scriptExtensions } from "../shared-D4NJBKEP.mjs";
|
|
3
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
4
|
+
//#region src/presets/paraglide/index.ts
|
|
5
|
+
function paraglide() {
|
|
6
|
+
return {
|
|
7
|
+
name: "paraglide",
|
|
8
|
+
plugins: [createLibraryPlugin({
|
|
9
|
+
name: "x18n:paraglide",
|
|
10
|
+
regex: [{
|
|
11
|
+
extensions: [
|
|
12
|
+
...scriptExtensions,
|
|
13
|
+
"vue",
|
|
14
|
+
"svelte",
|
|
15
|
+
"astro"
|
|
16
|
+
],
|
|
17
|
+
patterns: ["\\bm\\.({key})\\(", "\\bm\\[\\s*['\"`]({key})['\"`]\\s*\\]\\("]
|
|
18
|
+
}],
|
|
19
|
+
resources: [{ pattern: "messages/{locale}.json" }],
|
|
20
|
+
templates: [{
|
|
21
|
+
template: "{m.{key}({args})}",
|
|
22
|
+
kinds: [
|
|
23
|
+
"jsx-text",
|
|
24
|
+
"svelte-text",
|
|
25
|
+
"astro-text"
|
|
26
|
+
],
|
|
27
|
+
imports: ["import { m } from '$lib/paraglide/messages'"]
|
|
28
|
+
}, {
|
|
29
|
+
template: "m.{key}({args})",
|
|
30
|
+
kinds: ["js-string", "js-template"],
|
|
31
|
+
imports: ["import { m } from '$lib/paraglide/messages'"]
|
|
32
|
+
}],
|
|
33
|
+
placeholders: [braces]
|
|
34
|
+
})]
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { paraglide as default, paraglide };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Preset } from "@x18n/core";
|
|
2
|
+
//#region src/presets/php-gettext/index.d.ts
|
|
3
|
+
/** PHP gettext with `.po` files. Exclusive and never detected, as in i18n-ally: list it in `presets`. */
|
|
4
|
+
export declare function phpGettext(): Preset;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { phpGettext as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { printf } from "../placeholders.mjs";
|
|
2
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
3
|
+
//#region src/presets/php-gettext/index.ts
|
|
4
|
+
/** PHP gettext with `.po` files. Exclusive and never detected, as in i18n-ally: list it in `presets`. */
|
|
5
|
+
function phpGettext() {
|
|
6
|
+
return {
|
|
7
|
+
name: "php-gettext",
|
|
8
|
+
plugins: [createLibraryPlugin({
|
|
9
|
+
name: "x18n:php-gettext",
|
|
10
|
+
regex: [{
|
|
11
|
+
extensions: ["php"],
|
|
12
|
+
patterns: ["[^\\w\\d](?:gettext|_|__)\\(\\s*['\"`]({key})['\"`]"]
|
|
13
|
+
}],
|
|
14
|
+
resources: [{ pattern: "locale/{locale}/LC_MESSAGES/*.po" }, { pattern: "locales/{locale}.po" }],
|
|
15
|
+
extra: (draft) => {
|
|
16
|
+
draft.extract = {
|
|
17
|
+
keygen: "source",
|
|
18
|
+
...draft.extract
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
templates: [{ template: "gettext('{key}')" }],
|
|
22
|
+
placeholders: [printf]
|
|
23
|
+
})]
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { phpGettext as default, phpGettext };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { printf } from "../placeholders.mjs";
|
|
2
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
3
|
+
//#region src/presets/php-joomla/index.ts
|
|
4
|
+
/** Joomla: INI language files, `Text::_('KEY')`. */
|
|
5
|
+
function phpJoomla() {
|
|
6
|
+
return {
|
|
7
|
+
name: "php-joomla",
|
|
8
|
+
plugins: [createLibraryPlugin({
|
|
9
|
+
name: "x18n:php-joomla",
|
|
10
|
+
regex: [{
|
|
11
|
+
extensions: ["php"],
|
|
12
|
+
patterns: ["J?Text::(?:_|[\\w]+)\\(\\s*['\"]({key})['\"]"]
|
|
13
|
+
}],
|
|
14
|
+
resources: [{ pattern: "language/{locale}/*.ini" }, { pattern: "administrator/language/{locale}/*.ini" }],
|
|
15
|
+
keyStyle: "flat",
|
|
16
|
+
templates: [{ template: "Text::_('{key}')" }],
|
|
17
|
+
placeholders: [printf]
|
|
18
|
+
})]
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { phpJoomla as default, phpJoomla };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { percentBraces } from "../placeholders.mjs";
|
|
2
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
3
|
+
//#region src/presets/polyglot/index.ts
|
|
4
|
+
function polyglot() {
|
|
5
|
+
return {
|
|
6
|
+
name: "polyglot",
|
|
7
|
+
plugins: [createLibraryPlugin({
|
|
8
|
+
name: "x18n:polyglot",
|
|
9
|
+
calls: [{ callee: ["polyglot.t", "I18n.t"] }],
|
|
10
|
+
regex: [{
|
|
11
|
+
extensions: ["rb"],
|
|
12
|
+
patterns: ["(?:polyglot|I18n)\\.t\\(\\s*['\"`]({key})['\"`]"]
|
|
13
|
+
}],
|
|
14
|
+
templates: [{
|
|
15
|
+
template: "polyglot.t('{key}'{args})",
|
|
16
|
+
kinds: ["js-string", "js-template"]
|
|
17
|
+
}],
|
|
18
|
+
placeholders: [percentBraces]
|
|
19
|
+
})]
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { polyglot as default, polyglot };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Preset } from "@x18n/core";
|
|
2
|
+
//#region src/presets/python-gettext/index.d.ts
|
|
3
|
+
/** gettext in Python (Django, Flask-Babel, Babel): `.po` catalogs, `_()`, `gettext()`, `ngettext()` and Django `{% translate %}`. */
|
|
4
|
+
export declare function pythonGettext(): Preset;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { pythonGettext as default };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { pythonPercent } from "../placeholders.mjs";
|
|
2
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
3
|
+
//#region src/presets/python-gettext/index.ts
|
|
4
|
+
const quoted = [String.raw`"([^"\\\n]+)"`, String.raw`'([^'\\\n]+)'`];
|
|
5
|
+
const gettextCall = String.raw`(?<!\w)(?:u?gettext(?:_lazy|_noop)?|lazy_gettext|u?ngettext(?:_lazy)?|lazy_ngettext|_l|_lazy|_)\(\s*`;
|
|
6
|
+
const gettextCalls = quoted.map((string) => String.raw`${gettextCall}${string}(?=\s*[,)])`);
|
|
7
|
+
const djangoTags = quoted.map((string) => String.raw`\{%\s*trans(?:late)?\s+${string}(?=\s*(?:noop\s*)?(?:as\s+\w+\s*)?%\})`);
|
|
8
|
+
/** gettext in Python (Django, Flask-Babel, Babel): `.po` catalogs, `_()`, `gettext()`, `ngettext()` and Django `{% translate %}`. */
|
|
9
|
+
function pythonGettext() {
|
|
10
|
+
return {
|
|
11
|
+
name: "python-gettext",
|
|
12
|
+
plugins: [createLibraryPlugin({
|
|
13
|
+
name: "x18n:python-gettext",
|
|
14
|
+
regex: [{
|
|
15
|
+
extensions: ["py"],
|
|
16
|
+
patterns: gettextCalls
|
|
17
|
+
}, {
|
|
18
|
+
extensions: [
|
|
19
|
+
"html",
|
|
20
|
+
"jinja",
|
|
21
|
+
"jinja2",
|
|
22
|
+
"j2"
|
|
23
|
+
],
|
|
24
|
+
patterns: [...gettextCalls, ...djangoTags]
|
|
25
|
+
}],
|
|
26
|
+
resources: [
|
|
27
|
+
{ pattern: "locale/{locale}/LC_MESSAGES/*.po" },
|
|
28
|
+
{ pattern: "*/locale/{locale}/LC_MESSAGES/*.po" },
|
|
29
|
+
{ pattern: "translations/{locale}/LC_MESSAGES/*.po" },
|
|
30
|
+
{ pattern: "*/translations/{locale}/LC_MESSAGES/*.po" }
|
|
31
|
+
],
|
|
32
|
+
extra: (draft) => {
|
|
33
|
+
draft.extract = {
|
|
34
|
+
keygen: "source",
|
|
35
|
+
...draft.extract
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
templates: [{ template: "_(\"{key}\")" }],
|
|
39
|
+
placeholders: [pythonPercent]
|
|
40
|
+
})]
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { pythonGettext as default, pythonGettext };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { n as scriptExtensions } from "../shared-D4NJBKEP.mjs";
|
|
2
|
+
import regexScopes from "../scanners/regex-scopes.mjs";
|
|
3
|
+
import { t as i18nextPlugin } from "../plugin-Cb1b0axD.mjs";
|
|
4
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
5
|
+
//#region src/presets/react-i18next/index.ts
|
|
6
|
+
function reactI18next() {
|
|
7
|
+
return {
|
|
8
|
+
name: "react-i18next",
|
|
9
|
+
plugins: [
|
|
10
|
+
i18nextPlugin,
|
|
11
|
+
createLibraryPlugin({
|
|
12
|
+
name: "x18n:react-i18next",
|
|
13
|
+
calls: [
|
|
14
|
+
{
|
|
15
|
+
callee: "useTranslation",
|
|
16
|
+
factory: true,
|
|
17
|
+
returns: ["t"],
|
|
18
|
+
namespace: { arg: 0 },
|
|
19
|
+
keyPrefix: {
|
|
20
|
+
arg: 1,
|
|
21
|
+
property: "keyPrefix"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
callee: "Trans",
|
|
26
|
+
key: {
|
|
27
|
+
arg: 0,
|
|
28
|
+
property: "i18nKey"
|
|
29
|
+
},
|
|
30
|
+
namespace: {
|
|
31
|
+
arg: 0,
|
|
32
|
+
property: "ns"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
callee: "Translation",
|
|
37
|
+
factory: true,
|
|
38
|
+
returns: ["t"],
|
|
39
|
+
namespace: {
|
|
40
|
+
arg: 0,
|
|
41
|
+
property: "ns"
|
|
42
|
+
},
|
|
43
|
+
keyPrefix: {
|
|
44
|
+
arg: 0,
|
|
45
|
+
property: "keyPrefix"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
templates: [{
|
|
50
|
+
template: "<Trans i18nKey=\"{key}\" />",
|
|
51
|
+
kinds: ["jsx-text"],
|
|
52
|
+
imports: ["import { Trans } from 'react-i18next'"]
|
|
53
|
+
}, {
|
|
54
|
+
template: "{attr}={i18next.t('{key}'{args})}",
|
|
55
|
+
kinds: ["jsx-attribute"],
|
|
56
|
+
imports: ["import i18next from 'i18next'"]
|
|
57
|
+
}]
|
|
58
|
+
}),
|
|
59
|
+
regexScopes("\\bwithTranslation\\(\\s*(?:\\[?\\s*['\"`](?<namespace>[^'\"`]+)['\"`])?(?:[^)]*?\\bkeyPrefix\\s*:\\s*['\"`](?<keyPrefix>[^'\"`]+)['\"`])?", "react-i18next-hoc", {
|
|
60
|
+
wholeFile: true,
|
|
61
|
+
extensions: scriptExtensions
|
|
62
|
+
})
|
|
63
|
+
]
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { reactI18next as default, reactI18next };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { icu } from "../placeholders.mjs";
|
|
2
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
3
|
+
//#region src/presets/react-intl/index.ts
|
|
4
|
+
function reactIntl() {
|
|
5
|
+
return {
|
|
6
|
+
name: "react-intl",
|
|
7
|
+
plugins: [createLibraryPlugin({
|
|
8
|
+
name: "x18n:react-intl",
|
|
9
|
+
calls: [{
|
|
10
|
+
callee: [
|
|
11
|
+
"intl.formatMessage",
|
|
12
|
+
"formatMessage",
|
|
13
|
+
"defineMessage",
|
|
14
|
+
"FormattedMessage"
|
|
15
|
+
],
|
|
16
|
+
key: {
|
|
17
|
+
arg: 0,
|
|
18
|
+
property: "id"
|
|
19
|
+
}
|
|
20
|
+
}, {
|
|
21
|
+
callee: "defineMessages",
|
|
22
|
+
key: {
|
|
23
|
+
arg: 0,
|
|
24
|
+
property: "*.id"
|
|
25
|
+
}
|
|
26
|
+
}],
|
|
27
|
+
templates: [
|
|
28
|
+
{
|
|
29
|
+
template: "<FormattedMessage id=\"{key}\" />",
|
|
30
|
+
kinds: ["jsx-text"],
|
|
31
|
+
imports: ["import { FormattedMessage } from 'react-intl'"]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
template: "{attr}={intl.formatMessage({ id: '{key}' }{args})}",
|
|
35
|
+
kinds: ["jsx-attribute"]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
template: "intl.formatMessage({ id: '{key}' }{args})",
|
|
39
|
+
kinds: ["js-string", "js-template"]
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
placeholders: [icu]
|
|
43
|
+
})]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
export { reactIntl as default, reactIntl };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { percentBraces } from "../placeholders.mjs";
|
|
2
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
3
|
+
//#region src/presets/ruby-i18n-js/index.ts
|
|
4
|
+
function rubyI18nJs() {
|
|
5
|
+
return {
|
|
6
|
+
name: "ruby-i18n-js",
|
|
7
|
+
plugins: [createLibraryPlugin({
|
|
8
|
+
name: "x18n:ruby-i18n-js",
|
|
9
|
+
calls: [{ callee: ["I18n.t", "i18n.t"] }],
|
|
10
|
+
templates: [{
|
|
11
|
+
template: "i18n.t('{key}'{args})",
|
|
12
|
+
kinds: ["js-string", "js-template"]
|
|
13
|
+
}],
|
|
14
|
+
placeholders: [percentBraces]
|
|
15
|
+
})]
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { rubyI18nJs as default, rubyI18nJs };
|