Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tant-intl

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tant-intl - npm Package Compare versions

Comparing version 2.0.7 to 3.0.1

22

es/cli.js

@@ -49,2 +49,3 @@ #!/usr/bin/env node

const lanObj = {};
const lanTagObj = {};
Object.keys(d).forEach((key) => {

@@ -56,19 +57,28 @@ Object.keys(d[key].value).forEach((lan) => {

lanObj[lan][key] = d[key].value[lan];
d[key].tags.forEach((tag) => {
if (!lanObj[`${lan}-${tag}`]) {
lanObj[`${lan}-${tag}`] = {};
}
lanObj[`${lan}-${tag}`][key] = d[key].value[lan];
});
});
});
const path = `${projectDir}/public/intl`;
if (!(0, fs_1.existsSync)(`${projectDir}/public`)) {
(0, fs_1.mkdirSync)(`${projectDir}/public`);
}
(0, fs_1.readdirSync)(`${projectDir}/public/intl`).forEach((fileName) => {
const path = `${projectDir}/public/intl`;
if (!(0, fs_1.existsSync)(path)) {
(0, fs_1.mkdirSync)(path);
}
(0, fs_1.readdirSync)(path).forEach((fileName) => {
if (fileName.endsWith('.json')) {
(0, fs_1.unlinkSync)(`${projectDir}/public/intl/${fileName}`);
(0, fs_1.unlinkSync)(`${path}/${fileName}`);
}
});
Object.keys(lanObj).forEach((key) => {
if (!(0, fs_1.existsSync)(path)) {
(0, fs_1.mkdirSync)(path);
}
(0, fs_1.writeFileSync)(`${path}/${key}.json`, JSON.stringify(lanObj[key]));
});
Object.keys(lanTagObj).forEach((key) => {
(0, fs_1.writeFileSync)(`${path}/${key}.json`, JSON.stringify(lanTagObj[key]));
});
success('语言包发生更新,请刷新页面');

@@ -75,0 +85,0 @@ };

@@ -6,4 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getLocale = exports.setLocale = exports.formatMessage = void 0;
exports.getIntlMessage = exports.getLocale = exports.setLocale = exports.formatMessage = void 0;
const react_1 = __importDefault(require("react"));
const superagent_1 = __importDefault(require("superagent"));
/**

@@ -79,1 +80,24 @@ * 获取链接字符串

exports.getLocale = getLocale;
/**
* 获取文案内容
*/
const getIntlMessage = async (tags = []) => {
const lan = window.localStorage.getItem('umi_locale') || 'zh-CN';
const intl = window.intl;
if (!tags || tags?.length === 0) {
await superagent_1.default.get(`/intl/${lan}.json`).then((res) => {
window.intl = Object.assign(intl, res.body);
});
}
await Promise.all(tags.map(tag => superagent_1.default.get(`/intl/${lan}-${tag}.json`)
.then((res) => {
return res.body;
})
.catch((err) => {
console.log(err);
return {};
}))).then((arr) => {
window.intl = Object.assign(intl, ...arr);
});
};
exports.getIntlMessage = getIntlMessage;

@@ -49,2 +49,3 @@ #!/usr/bin/env node

var lanObj = {};
var lanTagObj = {};
Object.keys(d).forEach(function (key) {

@@ -56,19 +57,28 @@ Object.keys(d[key].value).forEach(function (lan) {

lanObj[lan][key] = d[key].value[lan];
d[key].tags.forEach(function (tag) {
if (!lanObj["".concat(lan, "-").concat(tag)]) {
lanObj["".concat(lan, "-").concat(tag)] = {};
}
lanObj["".concat(lan, "-").concat(tag)][key] = d[key].value[lan];
});
});
});
var path = "".concat(projectDir, "/public/intl");
if (!(0, fs_1.existsSync)("".concat(projectDir, "/public"))) {
(0, fs_1.mkdirSync)("".concat(projectDir, "/public"));
}
(0, fs_1.readdirSync)("".concat(projectDir, "/public/intl")).forEach(function (fileName) {
var path = "".concat(projectDir, "/public/intl");
if (!(0, fs_1.existsSync)(path)) {
(0, fs_1.mkdirSync)(path);
}
(0, fs_1.readdirSync)(path).forEach(function (fileName) {
if (fileName.endsWith('.json')) {
(0, fs_1.unlinkSync)("".concat(projectDir, "/public/intl/").concat(fileName));
(0, fs_1.unlinkSync)("".concat(path, "/").concat(fileName));
}
});
Object.keys(lanObj).forEach(function (key) {
if (!(0, fs_1.existsSync)(path)) {
(0, fs_1.mkdirSync)(path);
}
(0, fs_1.writeFileSync)("".concat(path, "/").concat(key, ".json"), JSON.stringify(lanObj[key]));
});
Object.keys(lanTagObj).forEach(function (key) {
(0, fs_1.writeFileSync)("".concat(path, "/").concat(key, ".json"), JSON.stringify(lanTagObj[key]));
});
success('语言包发生更新,请刷新页面');

@@ -75,0 +85,0 @@ };

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,4 +51,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.getLocale = exports.setLocale = exports.formatMessage = void 0;
exports.getIntlMessage = exports.getLocale = exports.setLocale = exports.formatMessage = void 0;
var react_1 = __importDefault(require("react"));
var superagent_1 = __importDefault(require("superagent"));
/**

@@ -80,1 +126,40 @@ * 获取链接字符串

exports.getLocale = getLocale;
/**
* 获取文案内容
*/
var getIntlMessage = function (tags) {
if (tags === void 0) { tags = []; }
return __awaiter(void 0, void 0, void 0, function () {
var lan, intl;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
lan = window.localStorage.getItem('umi_locale') || 'zh-CN';
intl = window.intl;
if (!(!tags || (tags === null || tags === void 0 ? void 0 : tags.length) === 0)) return [3 /*break*/, 2];
return [4 /*yield*/, superagent_1.default.get("/intl/".concat(lan, ".json")).then(function (res) {
window.intl = Object.assign(intl, res.body);
})];
case 1:
_a.sent();
_a.label = 2;
case 2: return [4 /*yield*/, Promise.all(tags.map(function (tag) {
return superagent_1.default.get("/intl/".concat(lan, "-").concat(tag, ".json"))
.then(function (res) {
return res.body;
})
.catch(function (err) {
console.log(err);
return {};
});
})).then(function (arr) {
window.intl = Object.assign.apply(Object, __spreadArray([intl], arr, false));
})];
case 3:
_a.sent();
return [2 /*return*/];
}
});
});
};
exports.getIntlMessage = getIntlMessage;
{
"name": "tant-intl",
"version": "2.0.7",
"version": "3.0.1",
"description": "依托于飞书表格做文案管理的多语言组件",

@@ -26,6 +26,7 @@ "main": "es/index.js",

"@types/node": "^17.0.21",
"@types/superagent": "^4.1.15",
"babel-core": "^6.26.3",
"ts-loader": "^8.3.0",
"typescript": "^4.5.5",
"webpack-cli": "^4.9.2",
"babel-core": "^6.26.3"
"webpack-cli": "^4.9.2"
},

@@ -36,3 +37,2 @@ "bin": {

"files": [
"dist",
"lib",

@@ -44,4 +44,5 @@ "es"

"feishu-excel": "^1.0.4",
"react": "^17.0.2"
"react": "^17.0.2",
"superagent": "^7.1.1"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc