@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,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,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,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,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,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,21 @@
|
|
|
1
|
+
import { n as scriptExtensions } from "../shared-D4NJBKEP.mjs";
|
|
2
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
3
|
+
//#region src/presets/i18n-tag/index.ts
|
|
4
|
+
function i18nTag() {
|
|
5
|
+
return {
|
|
6
|
+
name: "i18n-tag",
|
|
7
|
+
plugins: [createLibraryPlugin({
|
|
8
|
+
name: "x18n:i18n-tag",
|
|
9
|
+
regex: [{
|
|
10
|
+
extensions: [...scriptExtensions, "vue"],
|
|
11
|
+
patterns: ["i18n`({key})`"]
|
|
12
|
+
}],
|
|
13
|
+
templates: [{
|
|
14
|
+
template: "i18n`{key}`",
|
|
15
|
+
kinds: ["js-string", "js-template"]
|
|
16
|
+
}]
|
|
17
|
+
})]
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { i18nTag as default, i18nTag };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Preset } from "@x18n/core";
|
|
2
|
+
//#region src/presets/i18next-shopify/index.d.ts
|
|
3
|
+
/** Shopify's i18next format: plural and ordinal forms as nested keys (`{key}.one`). */
|
|
4
|
+
export declare function i18nextShopify(): Preset;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { i18nextShopify as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { braces } from "../placeholders.mjs";
|
|
2
|
+
import reactI18next from "./react-i18next.mjs";
|
|
3
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
4
|
+
//#region src/presets/i18next-shopify/index.ts
|
|
5
|
+
/** Shopify's i18next format: plural and ordinal forms as nested keys (`{key}.one`). */
|
|
6
|
+
function i18nextShopify() {
|
|
7
|
+
const derivedKeys = [
|
|
8
|
+
"{key}.ordinal.{ordinal}",
|
|
9
|
+
"{key}.{plural}",
|
|
10
|
+
...["plural", ...Array.from({ length: 10 }, (_, i) => String(i))].map((form) => `{key}.${form}`)
|
|
11
|
+
];
|
|
12
|
+
return {
|
|
13
|
+
name: "i18next-shopify",
|
|
14
|
+
plugins: [...reactI18next().plugins, createLibraryPlugin({
|
|
15
|
+
name: "x18n:i18next-shopify",
|
|
16
|
+
derivedKeys,
|
|
17
|
+
keyStyle: "nested",
|
|
18
|
+
placeholders: [braces]
|
|
19
|
+
})]
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { i18nextShopify as default, i18nextShopify };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Preset } from "@x18n/core";
|
|
2
|
+
//#region src/presets/i18nice/index.d.ts
|
|
3
|
+
/** i18nice and python-i18n, which it forked: `{namespace}.{locale}.yml` files that start with the locale, `i18n.t('namespace.key')`. */
|
|
4
|
+
export declare function i18nice(): Preset;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { i18nice as default };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { percentBraces } from "../placeholders.mjs";
|
|
2
|
+
import { t as localeRoot } from "../locale-root-C_rch3IQ.mjs";
|
|
3
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
4
|
+
//#region src/presets/i18nice/index.ts
|
|
5
|
+
/** i18nice and python-i18n, which it forked: `{namespace}.{locale}.yml` files that start with the locale, `i18n.t('namespace.key')`. */
|
|
6
|
+
function i18nice() {
|
|
7
|
+
return {
|
|
8
|
+
name: "i18nice",
|
|
9
|
+
plugins: [createLibraryPlugin({
|
|
10
|
+
name: "x18n:i18nice",
|
|
11
|
+
regex: [{
|
|
12
|
+
extensions: ["py"],
|
|
13
|
+
patterns: ["(?<![\\w.])(?:i18n\\.)?t\\(\\s*['\"]({key})['\"]"]
|
|
14
|
+
}],
|
|
15
|
+
resources: [{ pattern: "translations/{namespaces}.{locale}.{ext}" }, { pattern: "locales/{namespaces}.{locale}.{ext}" }],
|
|
16
|
+
derivedKeys: [
|
|
17
|
+
"{key}.zero",
|
|
18
|
+
"{key}.one",
|
|
19
|
+
"{key}.few",
|
|
20
|
+
"{key}.many"
|
|
21
|
+
],
|
|
22
|
+
transformResource: localeRoot((ctx) => /\.(?:ya?ml|json)$/.test(ctx.path) && ctx.path.slice(0, ctx.path.lastIndexOf(".")).endsWith(`.${ctx.locale}`)),
|
|
23
|
+
templates: [{ template: "i18n.t('{key}')" }],
|
|
24
|
+
placeholders: [percentBraces]
|
|
25
|
+
})]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { i18nice as default, i18nice };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
2
|
+
//#region src/presets/jekyll/index.ts
|
|
3
|
+
function jekyll() {
|
|
4
|
+
return {
|
|
5
|
+
name: "jekyll",
|
|
6
|
+
plugins: [createLibraryPlugin({
|
|
7
|
+
name: "x18n:jekyll",
|
|
8
|
+
regex: [{
|
|
9
|
+
extensions: [
|
|
10
|
+
"html",
|
|
11
|
+
"md",
|
|
12
|
+
"liquid"
|
|
13
|
+
],
|
|
14
|
+
patterns: ["\\{%\\s+t\\s+({key})\\s+%\\}"]
|
|
15
|
+
}],
|
|
16
|
+
resources: [{ pattern: "_i18n/{locale}.yml" }],
|
|
17
|
+
keyStyle: "nested",
|
|
18
|
+
templates: [{ template: "{% t {key} %}" }]
|
|
19
|
+
})]
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { jekyll as default, jekyll };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Preset } from "@x18n/core";
|
|
2
|
+
//#region src/presets/laravel-vue-i18n/index.d.ts
|
|
3
|
+
/** laravel-vue-i18n: the Laravel translation files read from Vue, so keys match the `laravel` preset. */
|
|
4
|
+
export declare function laravelVueI18n(): Preset;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { laravelVueI18n as default };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { colon } from "../placeholders.mjs";
|
|
2
|
+
import { n as laravelResources, t as laravelKey } from "../shared-meYeVckh.mjs";
|
|
3
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
4
|
+
//#region src/presets/laravel-vue-i18n/index.ts
|
|
5
|
+
/** laravel-vue-i18n: the Laravel translation files read from Vue, so keys match the `laravel` preset. */
|
|
6
|
+
function laravelVueI18n() {
|
|
7
|
+
return {
|
|
8
|
+
name: "laravel-vue-i18n",
|
|
9
|
+
plugins: [createLibraryPlugin({
|
|
10
|
+
name: "x18n:laravel-vue-i18n",
|
|
11
|
+
calls: [{ callee: [
|
|
12
|
+
"trans",
|
|
13
|
+
"wTrans",
|
|
14
|
+
"transChoice",
|
|
15
|
+
"wTransChoice",
|
|
16
|
+
"trans_choice",
|
|
17
|
+
"$t",
|
|
18
|
+
"$tChoice"
|
|
19
|
+
] }],
|
|
20
|
+
resources: laravelResources,
|
|
21
|
+
normalizeKey: laravelKey,
|
|
22
|
+
extra: async (draft, ctx) => {
|
|
23
|
+
draft.extract = {
|
|
24
|
+
keygen: "source",
|
|
25
|
+
...draft.extract
|
|
26
|
+
};
|
|
27
|
+
const phpFiles = await ctx.host.glob(["lang/*/**/*.php", "resources/lang/*/**/*.php"], { gitignore: false });
|
|
28
|
+
const locales = new Set(phpFiles.map((path) => {
|
|
29
|
+
const segments = path.split("/");
|
|
30
|
+
return segments[segments.indexOf("lang") + 1];
|
|
31
|
+
}));
|
|
32
|
+
draft.ignoreLocales = [...draft.ignoreLocales, ...[...locales].map((locale) => `php_${locale}`)];
|
|
33
|
+
},
|
|
34
|
+
templates: [
|
|
35
|
+
{
|
|
36
|
+
template: "{{ $t('{key}'{args}) }}",
|
|
37
|
+
kinds: ["vue-template-text"]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
template: ":{attr}=\"$t('{key}'{args})\"",
|
|
41
|
+
kinds: ["vue-attribute"]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
template: "trans('{key}'{args})",
|
|
45
|
+
kinds: ["js-string", "js-template"],
|
|
46
|
+
imports: ["import { trans } from 'laravel-vue-i18n'"]
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
placeholders: [colon]
|
|
50
|
+
})]
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { laravelVueI18n as default, laravelVueI18n };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Preset } from "@x18n/core";
|
|
2
|
+
//#region src/presets/laravel/index.d.ts
|
|
3
|
+
/** Laravel: `lang/{locale}/{file}.php` arrays and `lang/{locale}.json`; keys are `file.key`. Exclusive like i18n-ally. */
|
|
4
|
+
export declare function laravel(): Preset;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { laravel as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { colon } from "../placeholders.mjs";
|
|
2
|
+
import { n as laravelResources, t as laravelKey } from "../shared-meYeVckh.mjs";
|
|
3
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
4
|
+
//#region src/presets/laravel/index.ts
|
|
5
|
+
/** Laravel: `lang/{locale}/{file}.php` arrays and `lang/{locale}.json`; keys are `file.key`. Exclusive like i18n-ally. */
|
|
6
|
+
function laravel() {
|
|
7
|
+
return {
|
|
8
|
+
name: "laravel",
|
|
9
|
+
plugins: [createLibraryPlugin({
|
|
10
|
+
name: "x18n:laravel",
|
|
11
|
+
regex: [{
|
|
12
|
+
extensions: ["php"],
|
|
13
|
+
patterns: ["[^\\w\\d](?:__|trans|@lang|trans_choice|Lang::get|Lang::choice)\\(\\s*'([^']+)'", "[^\\w\\d](?:__|trans|@lang|trans_choice|Lang::get|Lang::choice)\\(\\s*\"([^\"]+)\""]
|
|
14
|
+
}],
|
|
15
|
+
resources: laravelResources,
|
|
16
|
+
normalizeKey: laravelKey,
|
|
17
|
+
templates: [{ template: "__('{key}')" }],
|
|
18
|
+
placeholders: [colon]
|
|
19
|
+
})]
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { laravel as default, laravel };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { icu } from "../placeholders.mjs";
|
|
2
|
+
import { n as scriptExtensions } from "../shared-D4NJBKEP.mjs";
|
|
3
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
4
|
+
//#region src/presets/lingui/index.ts
|
|
5
|
+
function lingui() {
|
|
6
|
+
return {
|
|
7
|
+
name: "lingui",
|
|
8
|
+
plugins: [createLibraryPlugin({
|
|
9
|
+
name: "x18n:lingui",
|
|
10
|
+
calls: [
|
|
11
|
+
{ callee: [
|
|
12
|
+
"i18n._",
|
|
13
|
+
"i18n.t",
|
|
14
|
+
"t",
|
|
15
|
+
"_"
|
|
16
|
+
] },
|
|
17
|
+
{
|
|
18
|
+
callee: [
|
|
19
|
+
"t",
|
|
20
|
+
"msg",
|
|
21
|
+
"defineMessage",
|
|
22
|
+
"i18n._",
|
|
23
|
+
"Trans"
|
|
24
|
+
],
|
|
25
|
+
key: {
|
|
26
|
+
arg: 0,
|
|
27
|
+
property: "id"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
callee: "useLingui",
|
|
32
|
+
factory: true,
|
|
33
|
+
returns: ["t", "_"]
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
regex: [{
|
|
37
|
+
extensions: scriptExtensions,
|
|
38
|
+
patterns: ["\\bt`({key})`", "<Trans>[\\s]*({key})[\\s]*<\\/Trans>"]
|
|
39
|
+
}],
|
|
40
|
+
resources: [{ pattern: "src/locales/{locale}/messages.po" }, { pattern: "locales/{locale}/messages.po" }],
|
|
41
|
+
extra: (draft) => {
|
|
42
|
+
draft.extract = {
|
|
43
|
+
keygen: "source",
|
|
44
|
+
...draft.extract
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
templates: [{
|
|
48
|
+
template: "<Trans>{key}</Trans>",
|
|
49
|
+
kinds: ["jsx-text"],
|
|
50
|
+
imports: ["import { Trans } from '@lingui/react/macro'"]
|
|
51
|
+
}, {
|
|
52
|
+
template: "t`{key}`",
|
|
53
|
+
kinds: ["js-string", "js-template"],
|
|
54
|
+
imports: ["import { t } from '@lingui/core/macro'"]
|
|
55
|
+
}],
|
|
56
|
+
placeholders: [icu]
|
|
57
|
+
})]
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { lingui as default, lingui };
|