@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.
- package/dist/angular-templates-DqIOGfzT.mjs +8 -0
- 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 +211 -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 +30 -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 +200 -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 +113 -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 +28 -22
- package/dist/{vue-CF4pe-Yr.mjs → js-CV-ECNJG.mjs} +67 -222
- package/dist/json-CyjI8bjp.d.mts +8 -0
- package/dist/json-Db-8qSbE.mjs +73 -0
- package/dist/jsx-templates-B1J0no3i.mjs +17 -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-js.d.mts +5 -0
- package/dist/presets/i18n-js.mjs +19 -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-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/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-BWaXUmwA.mjs +70 -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 +67 -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,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,7 @@
|
|
|
1
|
+
import { Preset } from "@x18n/core";
|
|
2
|
+
//#region src/presets/ruby-rails/index.d.ts
|
|
3
|
+
export declare function rubyRails(): Preset;
|
|
4
|
+
/** `t('.title')` in `app/views/users/index.html.erb` means `users.index.title`. */
|
|
5
|
+
export declare function railsLazyKey(raw: string, path: string): string | undefined;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { rubyRails as default };
|
|
@@ -0,0 +1,44 @@
|
|
|
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/ruby-rails/index.ts
|
|
5
|
+
function rubyRails() {
|
|
6
|
+
return {
|
|
7
|
+
name: "ruby-rails",
|
|
8
|
+
plugins: [createLibraryPlugin({
|
|
9
|
+
name: "x18n:ruby-rails",
|
|
10
|
+
regex: [{
|
|
11
|
+
extensions: [
|
|
12
|
+
"rb",
|
|
13
|
+
"erb",
|
|
14
|
+
"haml",
|
|
15
|
+
"slim"
|
|
16
|
+
],
|
|
17
|
+
patterns: [
|
|
18
|
+
"[^\\w\\d]t(?:\\(| )\\s*['\"`]({key})['\"`]",
|
|
19
|
+
"[^\\w\\d]t\\(:({key})\\)",
|
|
20
|
+
"I18n\\.t\\(\\s*['\"`]({key})['\"`]"
|
|
21
|
+
]
|
|
22
|
+
}],
|
|
23
|
+
resources: [
|
|
24
|
+
{ pattern: "config/locales/{locale}.yml" },
|
|
25
|
+
{ pattern: "config/locales/**/*.{locale}.yml" },
|
|
26
|
+
{ pattern: "config/locales/{locale}/**/*.yml" }
|
|
27
|
+
],
|
|
28
|
+
normalizeKey: (raw, ctx) => railsLazyKey(raw, ctx.path),
|
|
29
|
+
transformResource: localeRoot((ctx) => /\.ya?ml$/.test(ctx.path)),
|
|
30
|
+
templates: [{ template: "t('{key}')" }],
|
|
31
|
+
placeholders: [percentBraces]
|
|
32
|
+
})]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const viewSuffix = /(?:\.html)?\.(?:erb|haml|slim)$/;
|
|
36
|
+
/** `t('.title')` in `app/views/users/index.html.erb` means `users.index.title`. */
|
|
37
|
+
function railsLazyKey(raw, path) {
|
|
38
|
+
if (!raw.startsWith(".")) return void 0;
|
|
39
|
+
const match = /(?:^|\/)app\/views\/(.+)$/.exec(path);
|
|
40
|
+
if (!match) return void 0;
|
|
41
|
+
return `${match[1].replace(viewSuffix, "").split("/").map((segment) => segment.replace(/^_/, "")).join(".")}${raw}`;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { rubyRails as default, rubyRails, railsLazyKey };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { doubleBraces } from "../placeholders.mjs";
|
|
2
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
3
|
+
//#region src/presets/solid-primitives-i18n/index.ts
|
|
4
|
+
function solidPrimitivesI18n() {
|
|
5
|
+
return {
|
|
6
|
+
name: "solid-primitives-i18n",
|
|
7
|
+
plugins: [createLibraryPlugin({
|
|
8
|
+
name: "x18n:solid-primitives-i18n",
|
|
9
|
+
calls: [{ callee: ["t", "i18n.t"] }],
|
|
10
|
+
templates: [
|
|
11
|
+
{
|
|
12
|
+
template: "{t('{key}'{args})}",
|
|
13
|
+
kinds: ["jsx-text"]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
template: "{attr}={t('{key}'{args})}",
|
|
17
|
+
kinds: ["jsx-attribute"]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
template: "t('{key}'{args})",
|
|
21
|
+
kinds: ["js-string", "js-template"]
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
placeholders: [doubleBraces]
|
|
25
|
+
})]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { solidPrimitivesI18n as default, solidPrimitivesI18n };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { icu } from "../placeholders.mjs";
|
|
2
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
3
|
+
//#region src/presets/svelte-i18n/index.ts
|
|
4
|
+
function svelteI18n() {
|
|
5
|
+
return {
|
|
6
|
+
name: "svelte-i18n",
|
|
7
|
+
plugins: [createLibraryPlugin({
|
|
8
|
+
name: "x18n:svelte-i18n",
|
|
9
|
+
calls: [{ callee: [
|
|
10
|
+
"$_",
|
|
11
|
+
"$t",
|
|
12
|
+
"$format",
|
|
13
|
+
"_",
|
|
14
|
+
"t",
|
|
15
|
+
"format",
|
|
16
|
+
"$json",
|
|
17
|
+
"json"
|
|
18
|
+
] }],
|
|
19
|
+
templates: [{
|
|
20
|
+
template: "{$_('{key}'{args})}",
|
|
21
|
+
kinds: ["svelte-text"],
|
|
22
|
+
imports: ["import { _ } from 'svelte-i18n'"]
|
|
23
|
+
}, {
|
|
24
|
+
template: "{attr}={$_('{key}'{args})}",
|
|
25
|
+
kinds: ["svelte-attribute"],
|
|
26
|
+
imports: ["import { _ } from 'svelte-i18n'"]
|
|
27
|
+
}],
|
|
28
|
+
placeholders: [icu]
|
|
29
|
+
})]
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { svelteI18n as default, svelteI18n };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { t as i18nextPlugin } from "../plugin-Cb1b0axD.mjs";
|
|
2
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
3
|
+
//#region src/presets/svelte-i18next/index.ts
|
|
4
|
+
function svelteI18next() {
|
|
5
|
+
return {
|
|
6
|
+
name: "svelte-i18next",
|
|
7
|
+
plugins: [i18nextPlugin, createLibraryPlugin({
|
|
8
|
+
name: "x18n:svelte-i18next",
|
|
9
|
+
calls: [{
|
|
10
|
+
callee: "$i18n.t",
|
|
11
|
+
namespace: {
|
|
12
|
+
arg: 1,
|
|
13
|
+
property: "ns"
|
|
14
|
+
}
|
|
15
|
+
}],
|
|
16
|
+
templates: [{
|
|
17
|
+
template: "{$i18n.t('{key}'{args})}",
|
|
18
|
+
kinds: ["svelte-text"]
|
|
19
|
+
}, {
|
|
20
|
+
template: "{attr}={$i18n.t('{key}'{args})}",
|
|
21
|
+
kinds: ["svelte-attribute"]
|
|
22
|
+
}]
|
|
23
|
+
})]
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { svelteI18next as default, svelteI18next };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { doubleBraces } from "../placeholders.mjs";
|
|
2
|
+
import regexScopes from "../scanners/regex-scopes.mjs";
|
|
3
|
+
import { t as angularTemplates } from "../angular-templates-DqIOGfzT.mjs";
|
|
4
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
5
|
+
//#region src/presets/transloco/index.ts
|
|
6
|
+
function transloco() {
|
|
7
|
+
return {
|
|
8
|
+
name: "transloco",
|
|
9
|
+
plugins: [createLibraryPlugin({
|
|
10
|
+
name: "x18n:transloco",
|
|
11
|
+
namespace: { fromPath: "camel" },
|
|
12
|
+
calls: [{ callee: [
|
|
13
|
+
"translate",
|
|
14
|
+
"translocoService.translate",
|
|
15
|
+
"transloco.translate",
|
|
16
|
+
"translocoService.selectTranslate",
|
|
17
|
+
"transloco.selectTranslate"
|
|
18
|
+
] }],
|
|
19
|
+
regex: [{
|
|
20
|
+
extensions: angularTemplates,
|
|
21
|
+
patterns: [
|
|
22
|
+
"[`'\"]({key})[`'\"][\\s\\n]*\\|[\\s\\n]*transloco\\b",
|
|
23
|
+
"[^\\w\\d]t\\([\\s\\n]*['\"`]({key})['\"`]",
|
|
24
|
+
"[^*\\w\\d]transloco=['\"`]({key})['\"`]"
|
|
25
|
+
]
|
|
26
|
+
}],
|
|
27
|
+
resources: [{ pattern: "src/assets/i18n/{locale}.json" }, { pattern: "src/assets/i18n/{namespaces}/{locale}.json" }],
|
|
28
|
+
templates: [{
|
|
29
|
+
template: "{{ '{key}' | transloco }}",
|
|
30
|
+
kinds: ["html-text"]
|
|
31
|
+
}, {
|
|
32
|
+
template: "translate('{key}'{args})",
|
|
33
|
+
kinds: ["js-string", "js-template"],
|
|
34
|
+
imports: ["import { translate } from '@jsverse/transloco'"]
|
|
35
|
+
}],
|
|
36
|
+
placeholders: [doubleBraces]
|
|
37
|
+
}), regexScopes("\\*transloco=\"[^\"]*read:\\s*'([^']+)'", "transloco-read", {
|
|
38
|
+
as: "keyPrefix",
|
|
39
|
+
extensions: ["html"]
|
|
40
|
+
})]
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { transloco as default, transloco };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { typedBraces } from "../placeholders.mjs";
|
|
2
|
+
import { n as scriptExtensions } from "../shared-D4NJBKEP.mjs";
|
|
3
|
+
import { createLibraryPlugin } from "@x18n/core";
|
|
4
|
+
//#region src/presets/typesafe-i18n/index.ts
|
|
5
|
+
/** Usage regex and resource layout after lokalise/i18n-ally#681. */
|
|
6
|
+
function typesafeI18n() {
|
|
7
|
+
return {
|
|
8
|
+
name: "typesafe-i18n",
|
|
9
|
+
plugins: [createLibraryPlugin({
|
|
10
|
+
name: "x18n:typesafe-i18n",
|
|
11
|
+
regex: [{
|
|
12
|
+
extensions: [
|
|
13
|
+
...scriptExtensions,
|
|
14
|
+
"vue",
|
|
15
|
+
"svelte"
|
|
16
|
+
],
|
|
17
|
+
patterns: ["\\bLL\\.({key})\\("]
|
|
18
|
+
}],
|
|
19
|
+
resources: [{ pattern: "src/i18n/{locale}/index.{ext}" }, { pattern: "src/i18n/{locale}/{namespace}/index.{ext}" }],
|
|
20
|
+
keyStyle: "nested",
|
|
21
|
+
templates: [
|
|
22
|
+
{
|
|
23
|
+
template: "{$LL.{key}({args})}",
|
|
24
|
+
kinds: ["svelte-text"]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
template: "{attr}={$LL.{key}({args})}",
|
|
28
|
+
kinds: ["svelte-attribute"]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
template: "$LL.{key}({args})",
|
|
32
|
+
kinds: ["js-string", "js-template"],
|
|
33
|
+
files: ["**/*.svelte"]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
template: "{{ LL.{key}({args}) }}",
|
|
37
|
+
kinds: ["vue-template-text"]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
template: ":{attr}=\"LL.{key}({args})\"",
|
|
41
|
+
kinds: ["vue-attribute"]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
template: "{LL.{key}({args})}",
|
|
45
|
+
kinds: ["jsx-text"]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
template: "{attr}={LL.{key}({args})}",
|
|
49
|
+
kinds: ["jsx-attribute"]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
template: "LL.{key}({args})",
|
|
53
|
+
kinds: ["js-string", "js-template"]
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
placeholders: [typedBraces]
|
|
57
|
+
})]
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { typesafeI18n as default, typesafeI18n };
|
|
@@ -0,0 +1,35 @@
|
|
|
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/ui5/index.ts
|
|
5
|
+
function ui5() {
|
|
6
|
+
return {
|
|
7
|
+
name: "ui5",
|
|
8
|
+
plugins: [createLibraryPlugin({
|
|
9
|
+
name: "x18n:ui5",
|
|
10
|
+
regex: [{
|
|
11
|
+
extensions: [
|
|
12
|
+
"xml",
|
|
13
|
+
"json",
|
|
14
|
+
...scriptExtensions
|
|
15
|
+
],
|
|
16
|
+
patterns: ["\\{i18n>({key})\\}"]
|
|
17
|
+
}, {
|
|
18
|
+
extensions: scriptExtensions,
|
|
19
|
+
patterns: ["getResourceBundle\\(\\)\\.getText\\(\\s*['\"`]({key})['\"`]"]
|
|
20
|
+
}],
|
|
21
|
+
resources: [{ pattern: "webapp/i18n/i18n_{locale}.properties" }, { pattern: "webapp/i18n/i18n.properties" }],
|
|
22
|
+
keyStyle: "flat",
|
|
23
|
+
templates: [{
|
|
24
|
+
template: "{i18n>{key}}",
|
|
25
|
+
files: ["**/*.xml"]
|
|
26
|
+
}, {
|
|
27
|
+
template: "this.getResourceBundle().getText('{key}')",
|
|
28
|
+
kinds: ["js-string", "js-template"]
|
|
29
|
+
}],
|
|
30
|
+
placeholders: [braces]
|
|
31
|
+
})]
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { ui5 as default, ui5 };
|