@awsless/i18n 0.0.15 → 0.0.16
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 +5 -5
- package/package.json +1 -1
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] = {};
|
|
@@ -148,16 +149,15 @@ import { parse } from "@swc/core";
|
|
|
148
149
|
import { simple } from "swc-walk";
|
|
149
150
|
var findTypescriptTranslatable = async (code) => {
|
|
150
151
|
const found = [];
|
|
151
|
-
const ast = await parse(code, {
|
|
152
|
-
|
|
153
|
-
});
|
|
152
|
+
const ast = await parse(code, { syntax: "typescript" });
|
|
153
|
+
const bytes = Buffer.from(code, "utf8");
|
|
154
154
|
simple(ast, {
|
|
155
155
|
TaggedTemplateExpression(node) {
|
|
156
156
|
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") {
|
|
157
|
-
const content =
|
|
157
|
+
const content = bytes.subarray(
|
|
158
158
|
node.template.span.start - ast.span.start + 1,
|
|
159
159
|
node.template.span.end - ast.span.start - 1
|
|
160
|
-
);
|
|
160
|
+
).toString("utf8");
|
|
161
161
|
found.push(content);
|
|
162
162
|
}
|
|
163
163
|
}
|