locizify 7.0.0 → 7.0.2
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/CHANGELOG.md +8 -0
- package/dist/commonjs/index.js +14 -37
- package/dist/es/index.js +13 -29
- package/dist/umd/locizify.js +566 -2450
- package/dist/umd/locizify.min.js +2 -2
- package/locizify.js +566 -2450
- package/locizify.min.js +2 -2
- package/package.json +20 -23
- package/rollup.config.js +4 -1
- package/.coveralls.yml +0 -1
- package/.travis.yml +0 -8
package/CHANGELOG.md
CHANGED
package/dist/commonjs/index.js
CHANGED
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
-
|
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
10
|
var _i18nextify = _interopRequireDefault(require("i18nextify"));
|
|
15
|
-
|
|
16
11
|
var _i18nextLocizeBackend = _interopRequireDefault(require("i18next-locize-backend"));
|
|
17
|
-
|
|
18
12
|
var _locize = require("locize");
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
|
-
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
15
|
var i18next = _i18nextify["default"].i18next;
|
|
25
16
|
var enforce = {
|
|
26
17
|
saveMissingTo: 'all'
|
|
@@ -33,11 +24,10 @@ i18next.use(_i18nextLocizeBackend["default"]).use(_locize.locizePlugin);
|
|
|
33
24
|
i18next.on('editorSaved', function () {
|
|
34
25
|
_i18nextify["default"].forceRerender();
|
|
35
26
|
});
|
|
36
|
-
|
|
37
27
|
function getQsParameterByName(name, url) {
|
|
38
28
|
if (typeof window === 'undefined') return null;
|
|
39
|
-
if (!url) url = window.location.href.toLowerCase();
|
|
40
|
-
|
|
29
|
+
if (!url) url = window.location.href.toLowerCase();
|
|
30
|
+
// eslint-disable-next-line no-useless-escape
|
|
41
31
|
name = name.replace(/[\[\]]/g, '\\$&');
|
|
42
32
|
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
|
|
43
33
|
var results = regex.exec(url);
|
|
@@ -45,9 +35,7 @@ function getQsParameterByName(name, url) {
|
|
|
45
35
|
if (!results[2]) return '';
|
|
46
36
|
return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
|
47
37
|
}
|
|
48
|
-
|
|
49
38
|
var originalInit = i18next.init;
|
|
50
|
-
|
|
51
39
|
i18next.init = function () {
|
|
52
40
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
53
41
|
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -55,7 +43,6 @@ i18next.init = function () {
|
|
|
55
43
|
isLocizify: true
|
|
56
44
|
});
|
|
57
45
|
var scriptEle = document.getElementById('locizify');
|
|
58
|
-
|
|
59
46
|
if (scriptEle) {
|
|
60
47
|
var config = {};
|
|
61
48
|
var backend = {};
|
|
@@ -80,7 +67,6 @@ i18next.init = function () {
|
|
|
80
67
|
if (value === 'false') value = false;
|
|
81
68
|
if (attr.toLowerCase() === 'autopilot' && value === '') value = true;
|
|
82
69
|
if (value !== undefined && value !== null) backend[attr] = value;
|
|
83
|
-
|
|
84
70
|
if (!value) {
|
|
85
71
|
value = getQsParameterByName(attr.toLowerCase());
|
|
86
72
|
if (value === 'true') value = true;
|
|
@@ -89,26 +75,22 @@ i18next.init = function () {
|
|
|
89
75
|
if (value !== undefined && value !== null) backend[attr] = value;
|
|
90
76
|
}
|
|
91
77
|
});
|
|
92
|
-
|
|
93
78
|
if (backend.allowedAddOrUpdateHost) {
|
|
94
79
|
backend.allowedAddOrUpdateHosts = [backend.allowedAddOrUpdateHost];
|
|
95
80
|
delete backend.allowedAddOrUpdateHost;
|
|
96
81
|
}
|
|
97
|
-
|
|
98
82
|
options = _objectSpread(_objectSpread(_objectSpread({}, defaults), options), config);
|
|
99
83
|
options.backend = _objectSpread(_objectSpread({}, options.backend), backend);
|
|
100
84
|
}
|
|
101
|
-
|
|
102
85
|
function handleI18nextInitialized(err, t) {
|
|
103
86
|
// ready now
|
|
87
|
+
|
|
104
88
|
// call orginal callback
|
|
105
89
|
callback(err, t);
|
|
106
90
|
}
|
|
107
|
-
|
|
108
91
|
if (!options.backend.apiKey && getQsParameterByName('apikey')) {
|
|
109
92
|
options.backend.apiKey = getQsParameterByName('apikey');
|
|
110
93
|
}
|
|
111
|
-
|
|
112
94
|
if (!options.backend.autoPilot || options.backend.autoPilot === 'false') return originalInit.call(i18next, _objectSpread(_objectSpread({}, options), enforce), handleI18nextInitialized);
|
|
113
95
|
var locizeBackend = new _i18nextLocizeBackend["default"](options.backend);
|
|
114
96
|
locizeBackend.getOptions(function (err, opts) {
|
|
@@ -116,36 +98,31 @@ i18next.init = function () {
|
|
|
116
98
|
originalInit.call(i18next, _objectSpread(_objectSpread(_objectSpread({}, opts), options), enforce), handleI18nextInitialized);
|
|
117
99
|
});
|
|
118
100
|
};
|
|
119
|
-
|
|
120
101
|
_i18nextify["default"].getLanguages = function (callback) {
|
|
121
102
|
if (i18next.services.backendConnector) {
|
|
122
103
|
i18next.services.backendConnector.backend.getLanguages(callback);
|
|
123
104
|
} else {
|
|
124
|
-
var
|
|
125
|
-
i18next.off('initialized',
|
|
105
|
+
var _ready = function ready() {
|
|
106
|
+
i18next.off('initialized', _ready);
|
|
126
107
|
i18next.services.backendConnector.backend.getLanguages(callback);
|
|
127
108
|
};
|
|
128
|
-
|
|
129
|
-
i18next.on('initialized', ready);
|
|
109
|
+
i18next.on('initialized', _ready);
|
|
130
110
|
}
|
|
131
111
|
};
|
|
132
|
-
|
|
133
112
|
_i18nextify["default"].getOptions = function (callback) {
|
|
134
113
|
if (i18next.services.backendConnector) {
|
|
135
114
|
i18next.services.backendConnector.backend.getOptions(callback);
|
|
136
115
|
} else {
|
|
137
|
-
var
|
|
138
|
-
i18next.off('initialized',
|
|
116
|
+
var _ready2 = function ready() {
|
|
117
|
+
i18next.off('initialized', _ready2);
|
|
139
118
|
i18next.services.backendConnector.backend.getOptions(callback);
|
|
140
119
|
};
|
|
141
|
-
|
|
142
|
-
i18next.on('initialized', ready);
|
|
120
|
+
i18next.on('initialized', _ready2);
|
|
143
121
|
}
|
|
144
|
-
};
|
|
145
|
-
|
|
122
|
+
};
|
|
146
123
|
|
|
124
|
+
// add editor functions
|
|
147
125
|
_i18nextify["default"].editor = {
|
|
148
126
|
setEditorLng: _locize.setEditorLng
|
|
149
127
|
};
|
|
150
|
-
var _default = _i18nextify["default"];
|
|
151
|
-
exports["default"] = _default;
|
|
128
|
+
var _default = exports["default"] = _i18nextify["default"];
|
package/dist/es/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
-
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
5
|
import i18nextify from 'i18nextify';
|
|
9
6
|
import LocizeBackend from 'i18next-locize-backend';
|
|
10
7
|
import { locizePlugin, setEditorLng } from 'locize';
|
|
@@ -20,11 +17,10 @@ i18next.use(LocizeBackend).use(locizePlugin);
|
|
|
20
17
|
i18next.on('editorSaved', function () {
|
|
21
18
|
i18nextify.forceRerender();
|
|
22
19
|
});
|
|
23
|
-
|
|
24
20
|
function getQsParameterByName(name, url) {
|
|
25
21
|
if (typeof window === 'undefined') return null;
|
|
26
|
-
if (!url) url = window.location.href.toLowerCase();
|
|
27
|
-
|
|
22
|
+
if (!url) url = window.location.href.toLowerCase();
|
|
23
|
+
// eslint-disable-next-line no-useless-escape
|
|
28
24
|
name = name.replace(/[\[\]]/g, '\\$&');
|
|
29
25
|
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
|
|
30
26
|
var results = regex.exec(url);
|
|
@@ -32,9 +28,7 @@ function getQsParameterByName(name, url) {
|
|
|
32
28
|
if (!results[2]) return '';
|
|
33
29
|
return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
|
34
30
|
}
|
|
35
|
-
|
|
36
31
|
var originalInit = i18next.init;
|
|
37
|
-
|
|
38
32
|
i18next.init = function () {
|
|
39
33
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
40
34
|
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -42,7 +36,6 @@ i18next.init = function () {
|
|
|
42
36
|
isLocizify: true
|
|
43
37
|
});
|
|
44
38
|
var scriptEle = document.getElementById('locizify');
|
|
45
|
-
|
|
46
39
|
if (scriptEle) {
|
|
47
40
|
var config = {};
|
|
48
41
|
var backend = {};
|
|
@@ -67,7 +60,6 @@ i18next.init = function () {
|
|
|
67
60
|
if (value === 'false') value = false;
|
|
68
61
|
if (attr.toLowerCase() === 'autopilot' && value === '') value = true;
|
|
69
62
|
if (value !== undefined && value !== null) backend[attr] = value;
|
|
70
|
-
|
|
71
63
|
if (!value) {
|
|
72
64
|
value = getQsParameterByName(attr.toLowerCase());
|
|
73
65
|
if (value === 'true') value = true;
|
|
@@ -76,26 +68,22 @@ i18next.init = function () {
|
|
|
76
68
|
if (value !== undefined && value !== null) backend[attr] = value;
|
|
77
69
|
}
|
|
78
70
|
});
|
|
79
|
-
|
|
80
71
|
if (backend.allowedAddOrUpdateHost) {
|
|
81
72
|
backend.allowedAddOrUpdateHosts = [backend.allowedAddOrUpdateHost];
|
|
82
73
|
delete backend.allowedAddOrUpdateHost;
|
|
83
74
|
}
|
|
84
|
-
|
|
85
75
|
options = _objectSpread(_objectSpread(_objectSpread({}, defaults), options), config);
|
|
86
76
|
options.backend = _objectSpread(_objectSpread({}, options.backend), backend);
|
|
87
77
|
}
|
|
88
|
-
|
|
89
78
|
function handleI18nextInitialized(err, t) {
|
|
90
79
|
// ready now
|
|
80
|
+
|
|
91
81
|
// call orginal callback
|
|
92
82
|
callback(err, t);
|
|
93
83
|
}
|
|
94
|
-
|
|
95
84
|
if (!options.backend.apiKey && getQsParameterByName('apikey')) {
|
|
96
85
|
options.backend.apiKey = getQsParameterByName('apikey');
|
|
97
86
|
}
|
|
98
|
-
|
|
99
87
|
if (!options.backend.autoPilot || options.backend.autoPilot === 'false') return originalInit.call(i18next, _objectSpread(_objectSpread({}, options), enforce), handleI18nextInitialized);
|
|
100
88
|
var locizeBackend = new LocizeBackend(options.backend);
|
|
101
89
|
locizeBackend.getOptions(function (err, opts) {
|
|
@@ -103,34 +91,30 @@ i18next.init = function () {
|
|
|
103
91
|
originalInit.call(i18next, _objectSpread(_objectSpread(_objectSpread({}, opts), options), enforce), handleI18nextInitialized);
|
|
104
92
|
});
|
|
105
93
|
};
|
|
106
|
-
|
|
107
94
|
i18nextify.getLanguages = function (callback) {
|
|
108
95
|
if (i18next.services.backendConnector) {
|
|
109
96
|
i18next.services.backendConnector.backend.getLanguages(callback);
|
|
110
97
|
} else {
|
|
111
|
-
var
|
|
112
|
-
i18next.off('initialized',
|
|
98
|
+
var _ready = function ready() {
|
|
99
|
+
i18next.off('initialized', _ready);
|
|
113
100
|
i18next.services.backendConnector.backend.getLanguages(callback);
|
|
114
101
|
};
|
|
115
|
-
|
|
116
|
-
i18next.on('initialized', ready);
|
|
102
|
+
i18next.on('initialized', _ready);
|
|
117
103
|
}
|
|
118
104
|
};
|
|
119
|
-
|
|
120
105
|
i18nextify.getOptions = function (callback) {
|
|
121
106
|
if (i18next.services.backendConnector) {
|
|
122
107
|
i18next.services.backendConnector.backend.getOptions(callback);
|
|
123
108
|
} else {
|
|
124
|
-
var
|
|
125
|
-
i18next.off('initialized',
|
|
109
|
+
var _ready2 = function ready() {
|
|
110
|
+
i18next.off('initialized', _ready2);
|
|
126
111
|
i18next.services.backendConnector.backend.getOptions(callback);
|
|
127
112
|
};
|
|
128
|
-
|
|
129
|
-
i18next.on('initialized', ready);
|
|
113
|
+
i18next.on('initialized', _ready2);
|
|
130
114
|
}
|
|
131
|
-
};
|
|
132
|
-
|
|
115
|
+
};
|
|
133
116
|
|
|
117
|
+
// add editor functions
|
|
134
118
|
i18nextify.editor = {
|
|
135
119
|
setEditorLng: setEditorLng
|
|
136
120
|
};
|