@freelog/tools-lib 0.1.124 → 0.1.127
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/i18n/I18nNext.d.ts +5 -5
- package/dist/tools-lib.cjs.development.js +22 -16
- package/dist/tools-lib.cjs.development.js.map +1 -1
- package/dist/tools-lib.cjs.production.min.js +1 -1
- package/dist/tools-lib.cjs.production.min.js.map +1 -1
- package/dist/tools-lib.esm.js +22 -16
- package/dist/tools-lib.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/i18n/I18nNext.ts +27 -23
package/dist/tools-lib.esm.js
CHANGED
|
@@ -3286,6 +3286,7 @@ var FUtil = {
|
|
|
3286
3286
|
};
|
|
3287
3287
|
|
|
3288
3288
|
var ossJsonUrl = 'https://freelog-i18n.oss-cn-shenzhen.aliyuncs.com/configs/i18n.json';
|
|
3289
|
+
var ossJsonUrl_Test = 'https://freelog-i18n.oss-cn-shenzhen.aliyuncs.com/configs-test/i18n.json';
|
|
3289
3290
|
var localStorage_i18nextLng_key = 'locale';
|
|
3290
3291
|
var localStorage_i18nextResources_key = 'i18nextResources';
|
|
3291
3292
|
var allLanguage = [{
|
|
@@ -3295,7 +3296,6 @@ var allLanguage = [{
|
|
|
3295
3296
|
value: 'zh_CN',
|
|
3296
3297
|
label: '简体中文'
|
|
3297
3298
|
}];
|
|
3298
|
-
var self;
|
|
3299
3299
|
|
|
3300
3300
|
var I18nNext = /*#__PURE__*/function () {
|
|
3301
3301
|
function I18nNext() {
|
|
@@ -3303,22 +3303,28 @@ var I18nNext = /*#__PURE__*/function () {
|
|
|
3303
3303
|
this._taskQueue = []; // private _currentLanguage: LanguageKeyType = window.localStorage.getItem(localStorage_i18nextLng_key) as null || 'zh_CN';
|
|
3304
3304
|
|
|
3305
3305
|
this._currentLanguage = Cookies.get(localStorage_i18nextLng_key) || 'zh_CN';
|
|
3306
|
-
|
|
3307
|
-
|
|
3306
|
+
this.ready();
|
|
3307
|
+
this.ready = this.ready.bind(this);
|
|
3308
|
+
this.t = this.t.bind(this);
|
|
3309
|
+
this.changeLanguage = this.changeLanguage.bind(this);
|
|
3310
|
+
this.getAllLanguage = this.getAllLanguage.bind(this);
|
|
3311
|
+
this.getCurrentLanguage = this.getCurrentLanguage.bind(this);
|
|
3308
3312
|
}
|
|
3309
3313
|
|
|
3310
3314
|
var _proto = I18nNext.prototype;
|
|
3311
3315
|
|
|
3312
3316
|
_proto.ready = /*#__PURE__*/function () {
|
|
3313
3317
|
var _ready = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
3318
|
+
var _this = this;
|
|
3319
|
+
|
|
3314
3320
|
var exc, handleTasks, promise;
|
|
3315
3321
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
3316
3322
|
while (1) {
|
|
3317
3323
|
switch (_context2.prev = _context2.next) {
|
|
3318
3324
|
case 0:
|
|
3319
3325
|
exc = function exc() {
|
|
3320
|
-
while (
|
|
3321
|
-
var task =
|
|
3326
|
+
while (_this._taskQueue.length > 0) {
|
|
3327
|
+
var task = _this._taskQueue.shift();
|
|
3322
3328
|
|
|
3323
3329
|
task && task();
|
|
3324
3330
|
}
|
|
@@ -3330,7 +3336,7 @@ var I18nNext = /*#__PURE__*/function () {
|
|
|
3330
3336
|
while (1) {
|
|
3331
3337
|
switch (_context.prev = _context.next) {
|
|
3332
3338
|
case 0:
|
|
3333
|
-
if (!(
|
|
3339
|
+
if (!(_this._loadingData === 'End')) {
|
|
3334
3340
|
_context.next = 3;
|
|
3335
3341
|
break;
|
|
3336
3342
|
}
|
|
@@ -3339,7 +3345,7 @@ var I18nNext = /*#__PURE__*/function () {
|
|
|
3339
3345
|
return _context.abrupt("return");
|
|
3340
3346
|
|
|
3341
3347
|
case 3:
|
|
3342
|
-
if (!(
|
|
3348
|
+
if (!(_this._loadingData === 'Start')) {
|
|
3343
3349
|
_context.next = 5;
|
|
3344
3350
|
break;
|
|
3345
3351
|
}
|
|
@@ -3348,9 +3354,9 @@ var I18nNext = /*#__PURE__*/function () {
|
|
|
3348
3354
|
|
|
3349
3355
|
case 5:
|
|
3350
3356
|
// NO_START
|
|
3351
|
-
|
|
3357
|
+
_this._loadingData = 'Start';
|
|
3352
3358
|
_context.next = 8;
|
|
3353
|
-
return
|
|
3359
|
+
return _this._handleData();
|
|
3354
3360
|
|
|
3355
3361
|
case 8:
|
|
3356
3362
|
// console.log('######');
|
|
@@ -3370,7 +3376,7 @@ var I18nNext = /*#__PURE__*/function () {
|
|
|
3370
3376
|
}();
|
|
3371
3377
|
|
|
3372
3378
|
promise = new Promise(function (resolve) {
|
|
3373
|
-
|
|
3379
|
+
_this._taskQueue.push(resolve);
|
|
3374
3380
|
});
|
|
3375
3381
|
handleTasks();
|
|
3376
3382
|
return _context2.abrupt("return", promise);
|
|
@@ -3408,7 +3414,7 @@ var I18nNext = /*#__PURE__*/function () {
|
|
|
3408
3414
|
};
|
|
3409
3415
|
|
|
3410
3416
|
_proto.getCurrentLanguage = function getCurrentLanguage() {
|
|
3411
|
-
return
|
|
3417
|
+
return this._currentLanguage;
|
|
3412
3418
|
};
|
|
3413
3419
|
|
|
3414
3420
|
_proto._handleData = /*#__PURE__*/function () {
|
|
@@ -3418,7 +3424,7 @@ var I18nNext = /*#__PURE__*/function () {
|
|
|
3418
3424
|
while (1) {
|
|
3419
3425
|
switch (_context3.prev = _context3.next) {
|
|
3420
3426
|
case 0:
|
|
3421
|
-
lng =
|
|
3427
|
+
lng = this._currentLanguage;
|
|
3422
3428
|
resource = window.localStorage.getItem(localStorage_i18nextResources_key); // const resource: string | undefined = Cookies.get(decodeURIComponent(localStorage_i18nextResources_key));
|
|
3423
3429
|
|
|
3424
3430
|
i18nextResources = resource ? JSON.parse(resource) : null;
|
|
@@ -3429,7 +3435,7 @@ var I18nNext = /*#__PURE__*/function () {
|
|
|
3429
3435
|
}
|
|
3430
3436
|
|
|
3431
3437
|
_context3.next = 6;
|
|
3432
|
-
return
|
|
3438
|
+
return this._fetchData();
|
|
3433
3439
|
|
|
3434
3440
|
case 6:
|
|
3435
3441
|
i18nextResources = _context3.sent;
|
|
@@ -3437,7 +3443,7 @@ var I18nNext = /*#__PURE__*/function () {
|
|
|
3437
3443
|
break;
|
|
3438
3444
|
|
|
3439
3445
|
case 9:
|
|
3440
|
-
|
|
3446
|
+
this._fetchData();
|
|
3441
3447
|
|
|
3442
3448
|
case 10:
|
|
3443
3449
|
_context3.next = 12;
|
|
@@ -3460,7 +3466,7 @@ var I18nNext = /*#__PURE__*/function () {
|
|
|
3460
3466
|
return _context3.stop();
|
|
3461
3467
|
}
|
|
3462
3468
|
}
|
|
3463
|
-
}, _callee3);
|
|
3469
|
+
}, _callee3, this);
|
|
3464
3470
|
}));
|
|
3465
3471
|
|
|
3466
3472
|
function _handleData() {
|
|
@@ -3479,7 +3485,7 @@ var I18nNext = /*#__PURE__*/function () {
|
|
|
3479
3485
|
switch (_context4.prev = _context4.next) {
|
|
3480
3486
|
case 0:
|
|
3481
3487
|
_context4.next = 2;
|
|
3482
|
-
return axios.get(ossJsonUrl, {
|
|
3488
|
+
return axios.get(window.location.origin.includes('.freelog.com') ? ossJsonUrl : ossJsonUrl_Test, {
|
|
3483
3489
|
withCredentials: false
|
|
3484
3490
|
});
|
|
3485
3491
|
|