@freelog/tools-lib 0.1.105 → 0.1.106
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/tools-lib.cjs.development.js +17 -6
- 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 +17 -6
- package/dist/tools-lib.esm.js.map +1 -1
- package/package.json +67 -65
- package/src/i18n/I18nNext.ts +146 -134
- package/src/i18n/index.ts +7 -7
- package/src/index.ts +9 -9
- package/src/service-API/i18n.ts +35 -35
- package/src/service-API/index.ts +35 -35
- package/src/utils/index.ts +20 -20
|
@@ -12,6 +12,7 @@ var NProgress = _interopDefault(require('nprogress'));
|
|
|
12
12
|
require('nprogress/nprogress.css');
|
|
13
13
|
var CryptoJS = require('crypto-js');
|
|
14
14
|
var i18next = _interopDefault(require('i18next'));
|
|
15
|
+
var Cookies = _interopDefault(require('js-cookie'));
|
|
15
16
|
|
|
16
17
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
17
18
|
try {
|
|
@@ -2990,7 +2991,7 @@ var FUtil = {
|
|
|
2990
2991
|
};
|
|
2991
2992
|
|
|
2992
2993
|
var ossJsonUrl = 'https://freelog-i18n.oss-cn-shenzhen.aliyuncs.com/configs/i18n.json';
|
|
2993
|
-
var localStorage_i18nextLng_key = '
|
|
2994
|
+
var localStorage_i18nextLng_key = 'locale';
|
|
2994
2995
|
var localStorage_i18nextResources_key = 'i18nextResources';
|
|
2995
2996
|
var allLanguage = [{
|
|
2996
2997
|
value: 'en_US',
|
|
@@ -3004,8 +3005,9 @@ var self;
|
|
|
3004
3005
|
var I18nNext = /*#__PURE__*/function () {
|
|
3005
3006
|
function I18nNext() {
|
|
3006
3007
|
this._loadingData = 'NotStart';
|
|
3007
|
-
this._taskQueue = [];
|
|
3008
|
-
|
|
3008
|
+
this._taskQueue = []; // private _currentLanguage: LanguageKeyType = window.localStorage.getItem(localStorage_i18nextLng_key) as null || 'zh_CN';
|
|
3009
|
+
|
|
3010
|
+
this._currentLanguage = Cookies.get(localStorage_i18nextLng_key) || 'zh_CN';
|
|
3009
3011
|
self = this;
|
|
3010
3012
|
self.ready();
|
|
3011
3013
|
}
|
|
@@ -3099,7 +3101,11 @@ var I18nNext = /*#__PURE__*/function () {
|
|
|
3099
3101
|
|
|
3100
3102
|
_proto.changeLanguage = function changeLanguage(lng) {
|
|
3101
3103
|
// return i18next.changeLanguage(lng);
|
|
3102
|
-
window.localStorage.setItem(localStorage_i18nextLng_key, lng)
|
|
3104
|
+
// window.localStorage.setItem(localStorage_i18nextLng_key, lng)
|
|
3105
|
+
Cookies.set(localStorage_i18nextLng_key, lng, {
|
|
3106
|
+
expires: 36525,
|
|
3107
|
+
domain: FUtil.Format.completeUrlByDomain('').replace(/http(s)?:\/\//, '')
|
|
3108
|
+
});
|
|
3103
3109
|
};
|
|
3104
3110
|
|
|
3105
3111
|
_proto.getAllLanguage = function getAllLanguage() {
|
|
@@ -3118,7 +3124,8 @@ var I18nNext = /*#__PURE__*/function () {
|
|
|
3118
3124
|
switch (_context3.prev = _context3.next) {
|
|
3119
3125
|
case 0:
|
|
3120
3126
|
lng = self._currentLanguage;
|
|
3121
|
-
resource = window.localStorage.getItem(localStorage_i18nextResources_key);
|
|
3127
|
+
resource = window.localStorage.getItem(localStorage_i18nextResources_key); // const resource: string | undefined = Cookies.get(decodeURIComponent(localStorage_i18nextResources_key));
|
|
3128
|
+
|
|
3122
3129
|
i18nextResources = resource ? JSON.parse(resource) : null;
|
|
3123
3130
|
|
|
3124
3131
|
if (i18nextResources) {
|
|
@@ -3201,7 +3208,11 @@ var I18nNext = /*#__PURE__*/function () {
|
|
|
3201
3208
|
}
|
|
3202
3209
|
}; // console.log(result, 'result093sdolkfjlsdkjl');
|
|
3203
3210
|
|
|
3204
|
-
window.localStorage.setItem(localStorage_i18nextResources_key, JSON.stringify(result));
|
|
3211
|
+
window.localStorage.setItem(localStorage_i18nextResources_key, JSON.stringify(result)); // Cookies.set(localStorage_i18nextResources_key, encodeURIComponent(JSON.stringify(result)), {
|
|
3212
|
+
// expires: 36525,
|
|
3213
|
+
// domain: FUtil.Format.completeUrlByDomain('').replace(/http(s)?:\/\//, ''),
|
|
3214
|
+
// });
|
|
3215
|
+
|
|
3205
3216
|
return _context4.abrupt("return", result);
|
|
3206
3217
|
|
|
3207
3218
|
case 9:
|