@x18n/builtins 0.0.8 → 0.0.10
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/index.mjs +1 -1
- package/dist/{presets-C-DdV8pj.mjs → presets-DJrGl3HR.mjs} +61 -1
- package/dist/presets.d.mts +2 -0
- package/dist/presets.mjs +1 -1
- package/dist/reporters.d.mts +1 -1
- package/dist/reporters.mjs +34 -17
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { a as json5, c as ini, i as php, l as ftl, n as properties, o as json, r
|
|
|
4
4
|
import { i as js, n as vue } from "./vue-5GFR5hft.mjs";
|
|
5
5
|
import { manifests } from "./manifests.mjs";
|
|
6
6
|
import { n as regex } from "./regex-B9TBGgXC.mjs";
|
|
7
|
-
import { t as presets } from "./presets-
|
|
7
|
+
import { t as presets } from "./presets-DJrGl3HR.mjs";
|
|
8
8
|
import { reporters } from "./reporters.mjs";
|
|
9
9
|
import { t as svelte } from "./scanners-B27IEH4_.mjs";
|
|
10
10
|
//#region src/index.ts
|
|
@@ -1083,6 +1083,64 @@ function chromeExtension() {
|
|
|
1083
1083
|
]
|
|
1084
1084
|
};
|
|
1085
1085
|
}
|
|
1086
|
+
function solidPrimitivesI18n() {
|
|
1087
|
+
return {
|
|
1088
|
+
name: "solid-primitives-i18n",
|
|
1089
|
+
detect: dependsOn(["@solid-primitives/i18n"]),
|
|
1090
|
+
plugins: [library({
|
|
1091
|
+
name: "solid-primitives-i18n",
|
|
1092
|
+
calls: [{ callee: ["t", "i18n.t"] }],
|
|
1093
|
+
templates: [
|
|
1094
|
+
{
|
|
1095
|
+
template: "{t('{key}'{args})}",
|
|
1096
|
+
kinds: ["jsx-text"]
|
|
1097
|
+
},
|
|
1098
|
+
{
|
|
1099
|
+
template: "{attr}={t('{key}'{args})}",
|
|
1100
|
+
kinds: ["jsx-attribute"]
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
template: "t('{key}'{args})",
|
|
1104
|
+
kinds: ["js-string", "js-template"]
|
|
1105
|
+
}
|
|
1106
|
+
]
|
|
1107
|
+
}), placeholders(doubleBraces)]
|
|
1108
|
+
};
|
|
1109
|
+
}
|
|
1110
|
+
function paraglide() {
|
|
1111
|
+
return {
|
|
1112
|
+
name: "paraglide",
|
|
1113
|
+
detect: dependsOn([
|
|
1114
|
+
"@inlang/paraglide-js",
|
|
1115
|
+
"@inlang/paraglide-sveltekit",
|
|
1116
|
+
"@inlang/paraglide-next",
|
|
1117
|
+
"@inlang/paraglide-astro",
|
|
1118
|
+
"@inlang/paraglide-vite"
|
|
1119
|
+
]),
|
|
1120
|
+
plugins: [library({
|
|
1121
|
+
name: "paraglide",
|
|
1122
|
+
regex: [{
|
|
1123
|
+
extensions: [
|
|
1124
|
+
...scriptExtensions,
|
|
1125
|
+
"vue",
|
|
1126
|
+
"svelte",
|
|
1127
|
+
"astro"
|
|
1128
|
+
],
|
|
1129
|
+
patterns: ["\\bm\\.({key})\\(", "\\bm\\[\\s*['\"`]({key})['\"`]\\s*\\]\\("]
|
|
1130
|
+
}],
|
|
1131
|
+
resources: [{ pattern: "messages/{locale}.json" }],
|
|
1132
|
+
templates: [{
|
|
1133
|
+
template: "{m.{key}({args})}",
|
|
1134
|
+
kinds: ["jsx-text", "svelte-text"],
|
|
1135
|
+
imports: ["import { m } from '$lib/paraglide/messages'"]
|
|
1136
|
+
}, {
|
|
1137
|
+
template: "m.{key}({args})",
|
|
1138
|
+
kinds: ["js-string", "js-template"],
|
|
1139
|
+
imports: ["import { m } from '$lib/paraglide/messages'"]
|
|
1140
|
+
}]
|
|
1141
|
+
}), placeholders(braces)]
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1086
1144
|
//#endregion
|
|
1087
1145
|
//#region src/presets/index.ts
|
|
1088
1146
|
/**
|
|
@@ -1101,6 +1159,8 @@ const presets = {
|
|
|
1101
1159
|
"next-intl": () => nextIntl(),
|
|
1102
1160
|
"react-intl": () => reactIntl(),
|
|
1103
1161
|
"svelte-i18n": () => svelteI18n(),
|
|
1162
|
+
"solid-primitives-i18n": () => solidPrimitivesI18n(),
|
|
1163
|
+
"paraglide": () => paraglide(),
|
|
1104
1164
|
"ngx-translate": () => ngxTranslate(),
|
|
1105
1165
|
"transloco": () => transloco(),
|
|
1106
1166
|
"lingui": () => lingui(),
|
|
@@ -1121,4 +1181,4 @@ const presets = {
|
|
|
1121
1181
|
"general": () => general()
|
|
1122
1182
|
};
|
|
1123
1183
|
//#endregion
|
|
1124
|
-
export {
|
|
1184
|
+
export { vscodeExtension as A, general as C, reactI18next as D, nuxtI18n as E, ngxTranslate as M, transloco as N, reactIntl as O, flutter as S, nextIntl as T, laravel as _, globalize as a, railsLazyKey as b, i18nextShopify as c, nextTranslate as d, paraglide as f, jekyll as g, ui5 as h, fluentVue as i, vueI18n as j, svelteI18n as k, lingui as l, solidPrimitivesI18n as m, chromeExtension as n, i18nJs as o, polyglot as p, emberIntl as r, i18nTag as s, presets as t, nextInternational as u, phpGettext as v, i18next as w, rubyRails as x, phpJoomla as y };
|
package/dist/presets.d.mts
CHANGED
|
@@ -46,6 +46,8 @@ export declare function emberIntl(): Preset;
|
|
|
46
46
|
export declare function i18nJs(): Preset;
|
|
47
47
|
/** Chrome and WebExtension `_locales/{locale}/messages.json`: `{ "name": { "message": "..." } }` reads as `name`. */
|
|
48
48
|
export declare function chromeExtension(): Preset;
|
|
49
|
+
export declare function solidPrimitivesI18n(): Preset;
|
|
50
|
+
export declare function paraglide(): Preset;
|
|
49
51
|
//#endregion
|
|
50
52
|
//#region src/presets/index.d.ts
|
|
51
53
|
/**
|
package/dist/presets.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as chromeExtension, r as emberIntl, i as fluentVue,
|
|
1
|
+
export { n as chromeExtension, r as emberIntl, i as fluentVue, S as flutter, C as general, a as globalize, o as i18nJs, s as i18nTag, w as i18next, c as i18nextShopify, g as jekyll, _ as laravel, l as lingui, u as nextInternational, T as nextIntl, d as nextTranslate, M as ngxTranslate, E as nuxtI18n, f as paraglide, v as phpGettext, y as phpJoomla, p as polyglot, t as presets, b as railsLazyKey, D as reactI18next, O as reactIntl, x as rubyRails, m as solidPrimitivesI18n, k as svelteI18n, N as transloco, h as ui5, A as vscodeExtension, j as vueI18n } from "./presets-DJrGl3HR.mjs";
|
package/dist/reporters.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin, Reporter } from "@x18n/core";
|
|
2
2
|
//#region src/reporters/index.d.ts
|
|
3
|
-
/**
|
|
3
|
+
/** `path:line:col`, then the severity, message and check, a code frame, and a summary. */
|
|
4
4
|
export declare const prettyReporter: Reporter;
|
|
5
5
|
/** The versioned JSON contract of `x18n check --json`. */
|
|
6
6
|
export declare const jsonReporter: Reporter;
|
package/dist/reporters.mjs
CHANGED
|
@@ -33,40 +33,57 @@ const severityColor = {
|
|
|
33
33
|
info: "blue",
|
|
34
34
|
hint: "gray"
|
|
35
35
|
};
|
|
36
|
-
|
|
36
|
+
/** The severity as a highlighted label, like ` ERROR `. */
|
|
37
|
+
function badge(ctx, severity) {
|
|
38
|
+
const label = ` ${severity.toUpperCase()} `;
|
|
39
|
+
return ctx.color ? `\u001B[1;7;${codes[severityColor[severity]]}m${label}\u001B[0m` : label;
|
|
40
|
+
}
|
|
41
|
+
/** The marked line with one line of context on each side, and `~` under the range. */
|
|
42
|
+
function codeFrame(text, start, end, severity, ctx) {
|
|
37
43
|
const index = createLineIndex(text);
|
|
38
44
|
const from = index.position(start);
|
|
39
45
|
const to = index.position(end);
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const gutter = "
|
|
44
|
-
|
|
46
|
+
const first = Math.max(0, from.line - 1);
|
|
47
|
+
const last = Math.min(index.lineCount - 1, from.line + 1);
|
|
48
|
+
const pad = String(last + 1).length;
|
|
49
|
+
const gutter = (n) => `${paint(ctx, "gray", n.padStart(pad))} ${paint(ctx, "gray", "│")} `;
|
|
50
|
+
const width = Math.max(1, (to.line === from.line ? to.character : index.line(from.line).length) - from.character);
|
|
51
|
+
const lines = [];
|
|
52
|
+
for (let n = first; n <= last; n++) {
|
|
53
|
+
const line = index.line(n);
|
|
54
|
+
lines.push(`${gutter(String(n + 1))}${n === from.line ? line : paint(ctx, "gray", line)}`);
|
|
55
|
+
if (n === from.line) lines.push(`${gutter("")}${" ".repeat(from.character)}${paint(ctx, severityColor[severity], "~".repeat(width))}`);
|
|
56
|
+
}
|
|
57
|
+
return lines.join("\n");
|
|
45
58
|
}
|
|
46
|
-
/**
|
|
59
|
+
/** `path:line:col`, then the severity, message and check, a code frame, and a summary. */
|
|
47
60
|
const prettyReporter = {
|
|
48
61
|
id: "pretty",
|
|
49
62
|
report(inputs, ctx) {
|
|
50
|
-
const
|
|
63
|
+
const blocks = [];
|
|
51
64
|
for (const input of inputs) for (const d of input.diagnostics) {
|
|
52
|
-
const head = `${
|
|
65
|
+
const head = `${badge(ctx, d.severity)} ${d.message} ${paint(ctx, "gray", d.code)}`;
|
|
53
66
|
if (!d.location) {
|
|
54
|
-
|
|
67
|
+
blocks.push(head);
|
|
55
68
|
continue;
|
|
56
69
|
}
|
|
57
70
|
const text = input.text(d.location.path);
|
|
58
71
|
const position = createLineIndex(text ?? "").position(d.location.range.start);
|
|
59
|
-
const where = `${paint(ctx, "cyan", ctx.displayPath(d.location.path, input.project))}
|
|
60
|
-
const frame = text !== void 0 && d.location.range.end > d.location.range.start ? `\n${codeFrame(text, d.location.range.start, d.location.range.end, ctx)}
|
|
61
|
-
|
|
72
|
+
const where = `${paint(ctx, "cyan", ctx.displayPath(d.location.path, input.project))}${paint(ctx, "gray", `:${position.line + 1}:${position.character + 1}`)}`;
|
|
73
|
+
const frame = text !== void 0 && d.location.range.end > d.location.range.start ? `\n${codeFrame(text, d.location.range.start, d.location.range.end, d.severity, ctx)}` : "";
|
|
74
|
+
blocks.push(`${where}\n${head}${frame}`);
|
|
62
75
|
}
|
|
63
76
|
const sum = totals(inputs);
|
|
64
|
-
if (sum.errors + sum.warnings === 0)
|
|
77
|
+
if (sum.errors + sum.warnings === 0) blocks.push(paint(ctx, "gray", "Found no errors."));
|
|
65
78
|
else {
|
|
66
|
-
const parts = [
|
|
67
|
-
|
|
79
|
+
const parts = [
|
|
80
|
+
sum.errors ? paint(ctx, "red", `✖ ${plural(sum.errors, "error")}`) : "",
|
|
81
|
+
sum.warnings ? paint(ctx, "yellow", `⚠ ${plural(sum.warnings, "warning")}`) : "",
|
|
82
|
+
paint(ctx, "gray", plural(sum.files, "file"))
|
|
83
|
+
].filter(Boolean);
|
|
84
|
+
blocks.push(parts.join(" "));
|
|
68
85
|
}
|
|
69
|
-
return `${
|
|
86
|
+
return `${blocks.join("\n\n")}\n`;
|
|
70
87
|
}
|
|
71
88
|
};
|
|
72
89
|
/** The versioned JSON contract of `x18n check --json`. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x18n/builtins",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"description": "Built-in x18n plugins and presets: formats, locale finders, scanners, checks and reporters",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@vue/compiler-sfc": "^3.5.44",
|
|
36
|
-
"@x18n/core": "0.0.
|
|
36
|
+
"@x18n/core": "0.0.10",
|
|
37
37
|
"json5": "^2.2.3",
|
|
38
38
|
"jsonc-parser": "^3.3.1",
|
|
39
39
|
"oxc-parser": "^0.155.0",
|