locizify 5.2.5 → 5.2.8
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 +13 -0
- package/README.md +2 -0
- package/dist/commonjs/index.js +5 -1
- package/dist/es/index.js +6 -2
- package/dist/umd/locizify.js +56 -61
- package/dist/umd/locizify.min.js +1 -1
- package/locizify.js +56 -61
- package/locizify.min.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -481,4 +481,6 @@ isOff = locizify.editor.turnOff(); // -> true
|
|
|
481
481
|
isOff = locizify.editor.turnOn(); // -> false
|
|
482
482
|
|
|
483
483
|
locizify.editor.showLocizeLink(); // -> shows link to open directly in locize InContext editor
|
|
484
|
+
|
|
485
|
+
locizify.editor.setEditorLng('en'); // -> sets the appropriate language in the InContext editor
|
|
484
486
|
```
|
package/dist/commonjs/index.js
CHANGED
|
@@ -40,6 +40,9 @@ i18next.use(_i18nextLocizeBackend["default"]).use(_locize.locizePlugin);
|
|
|
40
40
|
i18next.on('editorSaved', function () {
|
|
41
41
|
_i18nextify["default"].forceRerender();
|
|
42
42
|
});
|
|
43
|
+
i18next.on('languageChanged', function (lng) {
|
|
44
|
+
window.document.documentElement.lang = lng;
|
|
45
|
+
});
|
|
43
46
|
var originalInit = i18next.init;
|
|
44
47
|
|
|
45
48
|
i18next.init = function () {
|
|
@@ -128,7 +131,8 @@ _i18nextify["default"].getOptions = function (callback) {
|
|
|
128
131
|
_i18nextify["default"].editor = {
|
|
129
132
|
turnOn: _locize.turnOn,
|
|
130
133
|
turnOff: _locize.turnOff,
|
|
131
|
-
showLocizeLink: _locize.showLocizeLink
|
|
134
|
+
showLocizeLink: _locize.showLocizeLink,
|
|
135
|
+
setEditorLng: _locize.setEditorLng
|
|
132
136
|
};
|
|
133
137
|
var _default = _i18nextify["default"];
|
|
134
138
|
exports["default"] = _default;
|
package/dist/es/index.js
CHANGED
|
@@ -7,7 +7,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
7
7
|
|
|
8
8
|
import i18nextify from 'i18nextify';
|
|
9
9
|
import LocizeBackend from 'i18next-locize-backend';
|
|
10
|
-
import { locizePlugin, turnOn, turnOff, showLocizeLink } from 'locize';
|
|
10
|
+
import { locizePlugin, turnOn, turnOff, showLocizeLink, setEditorLng } from 'locize';
|
|
11
11
|
var i18next = i18nextify.i18next;
|
|
12
12
|
var enforce = {
|
|
13
13
|
saveMissingTo: 'all'
|
|
@@ -27,6 +27,9 @@ i18next.use(LocizeBackend).use(locizePlugin);
|
|
|
27
27
|
i18next.on('editorSaved', function () {
|
|
28
28
|
i18nextify.forceRerender();
|
|
29
29
|
});
|
|
30
|
+
i18next.on('languageChanged', function (lng) {
|
|
31
|
+
window.document.documentElement.lang = lng;
|
|
32
|
+
});
|
|
30
33
|
var originalInit = i18next.init;
|
|
31
34
|
|
|
32
35
|
i18next.init = function () {
|
|
@@ -115,6 +118,7 @@ i18nextify.getOptions = function (callback) {
|
|
|
115
118
|
i18nextify.editor = {
|
|
116
119
|
turnOn: turnOn,
|
|
117
120
|
turnOff: turnOff,
|
|
118
|
-
showLocizeLink: showLocizeLink
|
|
121
|
+
showLocizeLink: showLocizeLink,
|
|
122
|
+
setEditorLng: setEditorLng
|
|
119
123
|
};
|
|
120
124
|
export default i18nextify;
|
package/dist/umd/locizify.js
CHANGED
|
@@ -9657,20 +9657,40 @@
|
|
|
9657
9657
|
|
|
9658
9658
|
I18NextLocizeBackend.type = 'backend';
|
|
9659
9659
|
|
|
9660
|
-
function
|
|
9661
|
-
|
|
9660
|
+
function ownKeys$9(object, enumerableOnly) {
|
|
9661
|
+
var keys = Object.keys(object);
|
|
9662
9662
|
|
|
9663
|
-
if (
|
|
9664
|
-
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
_typeof$4 = function _typeof(obj) {
|
|
9669
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
9670
|
-
};
|
|
9663
|
+
if (Object.getOwnPropertySymbols) {
|
|
9664
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
9665
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
9666
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
9667
|
+
})), keys.push.apply(keys, symbols);
|
|
9671
9668
|
}
|
|
9672
9669
|
|
|
9673
|
-
return
|
|
9670
|
+
return keys;
|
|
9671
|
+
}
|
|
9672
|
+
|
|
9673
|
+
function _objectSpread2$1(target) {
|
|
9674
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
9675
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
9676
|
+
i % 2 ? ownKeys$9(Object(source), !0).forEach(function (key) {
|
|
9677
|
+
_defineProperty$4(target, key, source[key]);
|
|
9678
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$9(Object(source)).forEach(function (key) {
|
|
9679
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
9680
|
+
});
|
|
9681
|
+
}
|
|
9682
|
+
|
|
9683
|
+
return target;
|
|
9684
|
+
}
|
|
9685
|
+
|
|
9686
|
+
function _typeof$4(obj) {
|
|
9687
|
+
"@babel/helpers - typeof";
|
|
9688
|
+
|
|
9689
|
+
return _typeof$4 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
9690
|
+
return typeof obj;
|
|
9691
|
+
} : function (obj) {
|
|
9692
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
9693
|
+
}, _typeof$4(obj);
|
|
9674
9694
|
}
|
|
9675
9695
|
|
|
9676
9696
|
function _defineProperty$4(obj, key, value) {
|
|
@@ -9688,40 +9708,6 @@
|
|
|
9688
9708
|
return obj;
|
|
9689
9709
|
}
|
|
9690
9710
|
|
|
9691
|
-
function ownKeys$9(object, enumerableOnly) {
|
|
9692
|
-
var keys = Object.keys(object);
|
|
9693
|
-
|
|
9694
|
-
if (Object.getOwnPropertySymbols) {
|
|
9695
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
9696
|
-
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
9697
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
9698
|
-
});
|
|
9699
|
-
keys.push.apply(keys, symbols);
|
|
9700
|
-
}
|
|
9701
|
-
|
|
9702
|
-
return keys;
|
|
9703
|
-
}
|
|
9704
|
-
|
|
9705
|
-
function _objectSpread2$1(target) {
|
|
9706
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
9707
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
9708
|
-
|
|
9709
|
-
if (i % 2) {
|
|
9710
|
-
ownKeys$9(Object(source), true).forEach(function (key) {
|
|
9711
|
-
_defineProperty$4(target, key, source[key]);
|
|
9712
|
-
});
|
|
9713
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
9714
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
9715
|
-
} else {
|
|
9716
|
-
ownKeys$9(Object(source)).forEach(function (key) {
|
|
9717
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
9718
|
-
});
|
|
9719
|
-
}
|
|
9720
|
-
}
|
|
9721
|
-
|
|
9722
|
-
return target;
|
|
9723
|
-
}
|
|
9724
|
-
|
|
9725
9711
|
function isWindow(obj) {
|
|
9726
9712
|
return obj != null && obj === obj.window;
|
|
9727
9713
|
}
|
|
@@ -9883,7 +9869,7 @@
|
|
|
9883
9869
|
var pB = parseFloat(style.getPropertyValue('padding-bottom'));
|
|
9884
9870
|
var pR = parseFloat(style.getPropertyValue('padding-right'));
|
|
9885
9871
|
var pL = parseFloat(style.getPropertyValue('padding-left'));
|
|
9886
|
-
var sizing = style.getPropertyValue('box-sizing');
|
|
9872
|
+
var sizing = style.getPropertyValue('box-sizing'); // eslint-disable-next-line consistent-return
|
|
9887
9873
|
|
|
9888
9874
|
function getFallbackNS() {
|
|
9889
9875
|
var i18next = options.getI18next();
|
|
@@ -9964,11 +9950,24 @@
|
|
|
9964
9950
|
var handleLocizeSaved;
|
|
9965
9951
|
var scriptTurnedOff; // used to flag turnOff by developers using the exported functions -> disable the editor function by code
|
|
9966
9952
|
|
|
9953
|
+
var pendingMsgs = [];
|
|
9954
|
+
|
|
9967
9955
|
function addLocizeSavedHandler(hnd) {
|
|
9968
9956
|
handleLocizeSaved = hnd;
|
|
9969
9957
|
}
|
|
9970
9958
|
|
|
9971
|
-
|
|
9959
|
+
function setEditorLng(lng) {
|
|
9960
|
+
var msg = {
|
|
9961
|
+
message: 'setLng',
|
|
9962
|
+
lng: lng
|
|
9963
|
+
};
|
|
9964
|
+
|
|
9965
|
+
if (source) {
|
|
9966
|
+
source.postMessage(msg, origin);
|
|
9967
|
+
} else {
|
|
9968
|
+
pendingMsgs.push(msg);
|
|
9969
|
+
}
|
|
9970
|
+
}
|
|
9972
9971
|
|
|
9973
9972
|
function onAddedKey(lng, ns, key, value) {
|
|
9974
9973
|
var msg = {
|
|
@@ -10104,22 +10103,14 @@
|
|
|
10104
10103
|
return scriptTurnedOff;
|
|
10105
10104
|
}
|
|
10106
10105
|
|
|
10107
|
-
|
|
10108
|
-
// console.warn('setLng', lng);
|
|
10109
|
-
if (source) source.postMessage({
|
|
10110
|
-
message: 'setLng',
|
|
10111
|
-
lng: lng
|
|
10112
|
-
}, origin);
|
|
10113
|
-
}
|
|
10114
|
-
|
|
10115
|
-
var oldHref = document.location.href;
|
|
10106
|
+
var oldHref = window.document.location.href;
|
|
10116
10107
|
window.addEventListener('load', function () {
|
|
10117
|
-
var bodyList = document.querySelector('body');
|
|
10118
|
-
var observer = new MutationObserver(function (mutations) {
|
|
10108
|
+
var bodyList = window.document.querySelector('body');
|
|
10109
|
+
var observer = new window.MutationObserver(function (mutations) {
|
|
10119
10110
|
mutations.forEach(function (mutation) {
|
|
10120
|
-
if (oldHref
|
|
10111
|
+
if (oldHref !== window.document.location.href) {
|
|
10121
10112
|
// console.warn('url changed', oldHref, document.location.href);
|
|
10122
|
-
oldHref = document.location.href;
|
|
10113
|
+
oldHref = window.document.location.href;
|
|
10123
10114
|
if (source) source.postMessage({
|
|
10124
10115
|
message: 'hrefChanged',
|
|
10125
10116
|
href: oldHref
|
|
@@ -10148,6 +10139,9 @@
|
|
|
10148
10139
|
i18next$1.on('editorSaved', () => {
|
|
10149
10140
|
i18nextify.forceRerender();
|
|
10150
10141
|
});
|
|
10142
|
+
i18next$1.on('languageChanged', lng => {
|
|
10143
|
+
window.document.documentElement.lang = lng;
|
|
10144
|
+
});
|
|
10151
10145
|
var originalInit = i18next$1.init;
|
|
10152
10146
|
|
|
10153
10147
|
i18next$1.init = function () {
|
|
@@ -10234,7 +10228,8 @@
|
|
|
10234
10228
|
i18nextify.editor = {
|
|
10235
10229
|
turnOn,
|
|
10236
10230
|
turnOff,
|
|
10237
|
-
showLocizeLink
|
|
10231
|
+
showLocizeLink,
|
|
10232
|
+
setEditorLng
|
|
10238
10233
|
};
|
|
10239
10234
|
|
|
10240
10235
|
return i18nextify;
|