@awsless/i18n 0.0.15 → 0.0.17
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.js +26 -13
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -38,6 +38,7 @@ var Cache = class {
|
|
|
38
38
|
constructor(data = {}) {
|
|
39
39
|
this.data = data;
|
|
40
40
|
}
|
|
41
|
+
data;
|
|
41
42
|
set(source, locale, translation) {
|
|
42
43
|
if (!this.data[source]) {
|
|
43
44
|
this.data[source] = {};
|
|
@@ -146,22 +147,34 @@ var findSvelteTranslatable = (code) => {
|
|
|
146
147
|
// src/find/typescript.ts
|
|
147
148
|
import { parse } from "@swc/core";
|
|
148
149
|
import { simple } from "swc-walk";
|
|
150
|
+
import { BaseVisitor } from "swc-walk/baseVisitor";
|
|
151
|
+
var PatchedBaseVisitor = class extends BaseVisitor {
|
|
152
|
+
FunctionBody(node, state, callback) {
|
|
153
|
+
for (const statement of node.stmts) {
|
|
154
|
+
callback(statement, state);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
var baseVisitor = new PatchedBaseVisitor();
|
|
149
159
|
var findTypescriptTranslatable = async (code) => {
|
|
150
160
|
const found = [];
|
|
151
|
-
const ast = await parse(code, {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
const ast = await parse(code, { syntax: "typescript" });
|
|
162
|
+
const bytes = Buffer.from(code, "utf8");
|
|
163
|
+
simple(
|
|
164
|
+
ast,
|
|
165
|
+
{
|
|
166
|
+
TaggedTemplateExpression(node) {
|
|
167
|
+
if (node.tag.type === "MemberExpression" && node.tag.object.type === "Identifier" && node.tag.object.value === "lang" && node.tag.property.type === "Identifier" && node.tag.property.value === "t") {
|
|
168
|
+
const content = bytes.subarray(
|
|
169
|
+
node.template.span.start - ast.span.start + 1,
|
|
170
|
+
node.template.span.end - ast.span.start - 1
|
|
171
|
+
).toString("utf8");
|
|
172
|
+
found.push(content);
|
|
173
|
+
}
|
|
162
174
|
}
|
|
163
|
-
}
|
|
164
|
-
|
|
175
|
+
},
|
|
176
|
+
baseVisitor
|
|
177
|
+
);
|
|
165
178
|
return found;
|
|
166
179
|
};
|
|
167
180
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/i18n",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"glob": "^10.3.9",
|
|
61
61
|
"line-column": "^1.0.2",
|
|
62
62
|
"magic-string": "^0.30.18",
|
|
63
|
-
"swc-walk": "
|
|
63
|
+
"swc-walk": "3.0.0-rc.0",
|
|
64
64
|
"zod": "^4.1.11"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|