locize 3.0.5 → 3.1.0

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.
@@ -3,6 +3,7 @@ import { PostProcessor } from 'i18next-subliminal';
3
3
  export { unwrap } from 'i18next-subliminal';
4
4
  import { start } from './process.js';
5
5
  import { startLegacy } from './processLegacy.js';
6
+ import { getQsParameterByName } from './utils.js';
6
7
 
7
8
  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; }
8
9
  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; }
@@ -10,89 +11,94 @@ var isInIframe = typeof window !== 'undefined';
10
11
  try {
11
12
  isInIframe = self !== top;
12
13
  } catch (e) {}
14
+ function configurePostProcessor(i18next, options) {
15
+ i18next.use(PostProcessor);
16
+ if (typeof options.postProcess === 'string') {
17
+ options.postProcess = [options.postProcess, 'subliminal'];
18
+ } else if (Array.isArray(options.postProcess)) {
19
+ options.postProcess.push('subliminal');
20
+ } else {
21
+ options.postProcess = 'subliminal';
22
+ }
23
+ options.postProcessPassResolved = true;
24
+ }
25
+ function getImplementation(i18n) {
26
+ var impl = {
27
+ getResource: function getResource(lng, ns, key) {
28
+ return i18n.getResource(lng, ns, key);
29
+ },
30
+ setResource: function setResource(lng, ns, key, value) {
31
+ return i18n.addResource(lng, ns, key, value, {
32
+ silent: true
33
+ });
34
+ },
35
+ getResourceBundle: function getResourceBundle(lng, ns, cb) {
36
+ i18n.loadNamespaces(ns, function () {
37
+ cb(i18n.getResourceBundle(lng, ns));
38
+ });
39
+ },
40
+ getLng: function getLng() {
41
+ return i18n.languages[0];
42
+ },
43
+ getSourceLng: function getSourceLng() {
44
+ var fallback = i18n.options.fallbackLng;
45
+ if (typeof fallback === 'string') return fallback;
46
+ if (Array.isArray(fallback)) return fallback[fallback.length - 1];
47
+ if (fallback && fallback["default"]) {
48
+ if (typeof fallback["default"] === 'string') return fallback;
49
+ if (Array.isArray(fallback["default"])) return fallback["default"][fallback["default"].length - 1];
50
+ }
51
+ if (typeof fallback === 'function') {
52
+ var res = fallback(i18n.resolvedLanguage);
53
+ if (typeof res === 'string') return res;
54
+ if (Array.isArray(res)) return res[res.length - 1];
55
+ }
56
+ return 'dev';
57
+ },
58
+ getLocizeDetails: function getLocizeDetails() {
59
+ var backendName;
60
+ if (i18n.services.backendConnector.backend && i18n.services.backendConnector.backend.options && i18n.services.backendConnector.backend.options.loadPath && i18n.services.backendConnector.backend.options.loadPath.indexOf('.locize.') > 0) {
61
+ backendName = 'I18NextLocizeBackend';
62
+ } else {
63
+ backendName = i18n.services.backendConnector.backend ? i18n.services.backendConnector.backend.constructor.name : 'options.resources';
64
+ }
65
+ var opts = {
66
+ backendName: backendName,
67
+ sourceLng: impl.getSourceLng(),
68
+ i18nFormat: i18n.options.compatibilityJSON === 'v3' ? 'i18next_v3' : 'i18next_v4',
69
+ i18nFramework: 'i18next',
70
+ isLocizify: i18n.options.isLocizify,
71
+ defaultNS: i18n.options.defaultNS
72
+ };
73
+ if (!i18n.options.backend && !i18n.options.editor) return opts;
74
+ var pickFrom = i18n.options.backend || i18n.options.editor;
75
+ return _objectSpread(_objectSpread({}, opts), {}, {
76
+ projectId: pickFrom.projectId,
77
+ version: pickFrom.version
78
+ });
79
+ },
80
+ bindLanguageChange: function bindLanguageChange(cb) {
81
+ i18n.on('languageChanged', cb);
82
+ },
83
+ bindMissingKeyHandler: function bindMissingKeyHandler(cb) {
84
+ i18n.options.missingKeyHandler = function (lng, ns, k, val, isUpdate, opts) {
85
+ if (!isUpdate) cb(lng, ns, k, val);
86
+ };
87
+ },
88
+ triggerRerender: function triggerRerender() {
89
+ i18n.emit('editorSaved');
90
+ }
91
+ };
92
+ return impl;
93
+ }
13
94
  var i18next;
14
95
  var locizePlugin = {
15
96
  type: '3rdParty',
16
97
  init: function init(i18n) {
17
98
  var options = i18n.options;
18
99
  i18next = i18n;
19
- if (!isInIframe) {
20
- i18next.use(PostProcessor);
21
- if (typeof options.postProcess === 'string') {
22
- options.postProcess = [options.postProcess, 'subliminal'];
23
- } else if (Array.isArray(options.postProcess)) {
24
- options.postProcess.push('subliminal');
25
- } else {
26
- options.postProcess = 'subliminal';
27
- }
28
- options.postProcessPassResolved = true;
29
- }
30
- var impl = {
31
- getResource: function getResource(lng, ns, key) {
32
- return i18n.getResource(lng, ns, key);
33
- },
34
- setResource: function setResource(lng, ns, key, value) {
35
- return i18n.addResource(lng, ns, key, value, {
36
- silent: true
37
- });
38
- },
39
- getResourceBundle: function getResourceBundle(lng, ns, cb) {
40
- i18n.loadNamespaces(ns, function () {
41
- cb(i18n.getResourceBundle(lng, ns));
42
- });
43
- },
44
- getLng: function getLng() {
45
- return i18n.languages[0];
46
- },
47
- getSourceLng: function getSourceLng() {
48
- var fallback = i18n.options.fallbackLng;
49
- if (typeof fallback === 'string') return fallback;
50
- if (Array.isArray(fallback)) return fallback[fallback.length - 1];
51
- if (fallback && fallback["default"]) {
52
- if (typeof fallback["default"] === 'string') return fallback;
53
- if (Array.isArray(fallback["default"])) return fallback["default"][fallback["default"].length - 1];
54
- }
55
- if (typeof fallback === 'function') {
56
- var res = fallback(i18n.resolvedLanguage);
57
- if (typeof res === 'string') return res;
58
- if (Array.isArray(res)) return res[res.length - 1];
59
- }
60
- return 'dev';
61
- },
62
- getLocizeDetails: function getLocizeDetails() {
63
- var backendName;
64
- if (i18n.services.backendConnector.backend && i18n.services.backendConnector.backend.options && i18n.services.backendConnector.backend.options.loadPath && i18n.services.backendConnector.backend.options.loadPath.indexOf('.locize.') > 0) {
65
- backendName = 'I18NextLocizeBackend';
66
- } else {
67
- backendName = i18n.services.backendConnector.backend ? i18n.services.backendConnector.backend.constructor.name : 'options.resources';
68
- }
69
- var opts = {
70
- backendName: backendName,
71
- sourceLng: impl.getSourceLng(),
72
- i18nFormat: i18n.options.compatibilityJSON === 'v3' ? 'i18next_v3' : 'i18next_v4',
73
- i18nFramework: 'i18next',
74
- isLocizify: i18n.options.isLocizify,
75
- defaultNS: i18n.options.defaultNS
76
- };
77
- if (!i18n.options.backend && !i18n.options.editor) return opts;
78
- var pickFrom = i18n.options.backend || i18n.options.editor;
79
- return _objectSpread(_objectSpread({}, opts), {}, {
80
- projectId: pickFrom.projectId,
81
- version: pickFrom.version
82
- });
83
- },
84
- bindLanguageChange: function bindLanguageChange(cb) {
85
- i18n.on('languageChanged', cb);
86
- },
87
- bindMissingKeyHandler: function bindMissingKeyHandler(cb) {
88
- i18n.options.missingKeyHandler = function (lng, ns, k, val, isUpdate, opts) {
89
- if (!isUpdate) cb(lng, ns, k, val);
90
- };
91
- },
92
- triggerRerender: function triggerRerender() {
93
- i18n.emit('editorSaved');
94
- }
95
- };
100
+ if (!isInIframe) configurePostProcessor(i18next, options);
101
+ var impl = getImplementation(i18n);
96
102
  if (!isInIframe) {
97
103
  start(impl);
98
104
  } else {
@@ -100,5 +106,24 @@ var locizePlugin = {
100
106
  }
101
107
  }
102
108
  };
109
+ var locizeEditorPlugin = function locizeEditorPlugin() {
110
+ var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
111
+ opt.qsProp = opt.qsProp || 'incontext';
112
+ return {
113
+ type: '3rdParty',
114
+ init: function init(i18n) {
115
+ var options = i18n.options;
116
+ i18next = i18n;
117
+ var showInContext = getQsParameterByName(opt.qsProp) === 'true';
118
+ if (!isInIframe && showInContext) configurePostProcessor(i18next, options);
119
+ var impl = getImplementation(i18n);
120
+ if (!isInIframe && showInContext) {
121
+ start(impl);
122
+ } else {
123
+ startLegacy(impl);
124
+ }
125
+ }
126
+ };
127
+ };
103
128
 
104
- export { locizePlugin };
129
+ export { locizeEditorPlugin, locizePlugin };
@@ -1,7 +1,18 @@
1
1
  import { debounce } from './utils.js';
2
2
  import { validAttributes } from './vars.js';
3
3
 
4
+ var mutationTriggeringElements = {};
4
5
  function ignoreMutation(ele) {
6
+ if (ele.uniqueID) {
7
+ var info = mutationTriggeringElements[ele.uniqueID];
8
+ if (info && info.triggered > 10 && info.lastTriggerDate + 500 < Date.now()) {
9
+ if (!info.warned && console) {
10
+ console.warn('locize ::: ignoring element change - an element is rerendering too often in short interval', '\n', 'consider adding the "data-locize-editor-ignore:" attribute to the element:', ele);
11
+ info.warned = true;
12
+ }
13
+ return true;
14
+ }
15
+ }
5
16
  var ret = ele.dataset && (ele.dataset.i18nextEditorElement === 'true' || ele.dataset.locizeEditorIgnore === 'true');
6
17
  if (!ret && ele.parentElement) return ignoreMutation(ele.parentElement);
7
18
  return ret;
@@ -30,6 +41,12 @@ function createObserver(ele, handle) {
30
41
  if (mutation.type === 'attributes' && !validAttributes.includes(mutation.attributeName)) {
31
42
  return;
32
43
  }
44
+ Object.keys(mutationTriggeringElements).forEach(function (k) {
45
+ var info = mutationTriggeringElements[k];
46
+ if (info.lastTriggerDate + 60000 < Date.now()) {
47
+ delete mutationTriggeringElements[k];
48
+ }
49
+ });
33
50
  if (mutation.type === 'childList') {
34
51
  var notOurs = 0;
35
52
  if (!ignoreMutation(mutation.target)) {
@@ -45,8 +62,18 @@ function createObserver(ele, handle) {
45
62
  if (notOurs === 0) return;
46
63
  }
47
64
  triggerMutation = true;
65
+ if (mutation.target && mutation.target.uniqueID) {
66
+ var info = mutationTriggeringElements[mutation.target.uniqueID] || {
67
+ triggered: 0
68
+ };
69
+ info.triggered = info.triggered + 1;
70
+ info.lastTriggerDate = Date.now();
71
+ mutationTriggeringElements[mutation.target.uniqueID] = info;
72
+ }
48
73
  var includedAlready = targetEles.reduce(function (mem, element) {
49
- if (mem || element.contains(mutation.target) || !mutation.target.parentElement) return true;
74
+ if (mem || element.contains(mutation.target) || !mutation.target.parentElement) {
75
+ return true;
76
+ }
50
77
  return false;
51
78
  }, false);
52
79
  if (!includedAlready) {
package/dist/esm/utils.js CHANGED
@@ -119,5 +119,15 @@ function getElementNamespace(el) {
119
119
  find(el);
120
120
  return found;
121
121
  }
122
+ function getQsParameterByName(name, url) {
123
+ if (typeof window === 'undefined') return null;
124
+ if (!url) url = window.location.href.toLowerCase();
125
+ name = name.replace(/[\[\]]/g, '\\$&');
126
+ var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
127
+ var results = regex.exec(url);
128
+ if (!results) return null;
129
+ if (!results[2]) return '';
130
+ return decodeURIComponent(results[2].replace(/\+/g, ' '));
131
+ }
122
132
 
123
- export { debounce, getClickedElement, getElementI18nKey, getElementNamespace, getElementText, getWindow, isWindow, offset };
133
+ export { debounce, getClickedElement, getElementI18nKey, getElementNamespace, getElementText, getQsParameterByName, getWindow, isWindow, offset };
@@ -493,6 +493,7 @@
493
493
  function handler$6(payload) {
494
494
  api.initialized = true;
495
495
  clearInterval(api.initInterval);
496
+ delete api.initInterval;
496
497
  api.sendCurrentParsedContent();
497
498
  api.sendCurrentTargetLanguage();
498
499
  }
@@ -2398,8 +2399,29 @@
2398
2399
  find(el);
2399
2400
  return found;
2400
2401
  }
2402
+ function getQsParameterByName(name, url) {
2403
+ if (typeof window === 'undefined') return null;
2404
+ if (!url) url = window.location.href.toLowerCase();
2405
+ name = name.replace(/[\[\]]/g, '\\$&');
2406
+ var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
2407
+ var results = regex.exec(url);
2408
+ if (!results) return null;
2409
+ if (!results[2]) return '';
2410
+ return decodeURIComponent(results[2].replace(/\+/g, ' '));
2411
+ }
2401
2412
 
2413
+ var mutationTriggeringElements = {};
2402
2414
  function ignoreMutation(ele) {
2415
+ if (ele.uniqueID) {
2416
+ var info = mutationTriggeringElements[ele.uniqueID];
2417
+ if (info && info.triggered > 10 && info.lastTriggerDate + 500 < Date.now()) {
2418
+ if (!info.warned && console) {
2419
+ console.warn('locize ::: ignoring element change - an element is rerendering too often in short interval', '\n', 'consider adding the "data-locize-editor-ignore:" attribute to the element:', ele);
2420
+ info.warned = true;
2421
+ }
2422
+ return true;
2423
+ }
2424
+ }
2403
2425
  var ret = ele.dataset && (ele.dataset.i18nextEditorElement === 'true' || ele.dataset.locizeEditorIgnore === 'true');
2404
2426
  if (!ret && ele.parentElement) return ignoreMutation(ele.parentElement);
2405
2427
  return ret;
@@ -2428,6 +2450,12 @@
2428
2450
  if (mutation.type === 'attributes' && !validAttributes.includes(mutation.attributeName)) {
2429
2451
  return;
2430
2452
  }
2453
+ Object.keys(mutationTriggeringElements).forEach(function (k) {
2454
+ var info = mutationTriggeringElements[k];
2455
+ if (info.lastTriggerDate + 60000 < Date.now()) {
2456
+ delete mutationTriggeringElements[k];
2457
+ }
2458
+ });
2431
2459
  if (mutation.type === 'childList') {
2432
2460
  var notOurs = 0;
2433
2461
  if (!ignoreMutation(mutation.target)) {
@@ -2443,8 +2471,18 @@
2443
2471
  if (notOurs === 0) return;
2444
2472
  }
2445
2473
  triggerMutation = true;
2474
+ if (mutation.target && mutation.target.uniqueID) {
2475
+ var info = mutationTriggeringElements[mutation.target.uniqueID] || {
2476
+ triggered: 0
2477
+ };
2478
+ info.triggered = info.triggered + 1;
2479
+ info.lastTriggerDate = Date.now();
2480
+ mutationTriggeringElements[mutation.target.uniqueID] = info;
2481
+ }
2446
2482
  var includedAlready = targetEles.reduce(function (mem, element) {
2447
- if (mem || element.contains(mutation.target) || !mutation.target.parentElement) return true;
2483
+ if (mem || element.contains(mutation.target) || !mutation.target.parentElement) {
2484
+ return true;
2485
+ }
2448
2486
  return false;
2449
2487
  }, false);
2450
2488
  if (!includedAlready) {
@@ -2862,89 +2900,94 @@
2862
2900
  try {
2863
2901
  isInIframe = self !== top;
2864
2902
  } catch (e) {}
2903
+ function configurePostProcessor(i18next, options) {
2904
+ i18next.use(SubliminalPostProcessor);
2905
+ if (typeof options.postProcess === 'string') {
2906
+ options.postProcess = [options.postProcess, 'subliminal'];
2907
+ } else if (Array.isArray(options.postProcess)) {
2908
+ options.postProcess.push('subliminal');
2909
+ } else {
2910
+ options.postProcess = 'subliminal';
2911
+ }
2912
+ options.postProcessPassResolved = true;
2913
+ }
2914
+ function getImplementation(i18n) {
2915
+ var impl = {
2916
+ getResource: function getResource(lng, ns, key) {
2917
+ return i18n.getResource(lng, ns, key);
2918
+ },
2919
+ setResource: function setResource(lng, ns, key, value) {
2920
+ return i18n.addResource(lng, ns, key, value, {
2921
+ silent: true
2922
+ });
2923
+ },
2924
+ getResourceBundle: function getResourceBundle(lng, ns, cb) {
2925
+ i18n.loadNamespaces(ns, function () {
2926
+ cb(i18n.getResourceBundle(lng, ns));
2927
+ });
2928
+ },
2929
+ getLng: function getLng() {
2930
+ return i18n.languages[0];
2931
+ },
2932
+ getSourceLng: function getSourceLng() {
2933
+ var fallback = i18n.options.fallbackLng;
2934
+ if (typeof fallback === 'string') return fallback;
2935
+ if (Array.isArray(fallback)) return fallback[fallback.length - 1];
2936
+ if (fallback && fallback["default"]) {
2937
+ if (typeof fallback["default"] === 'string') return fallback;
2938
+ if (Array.isArray(fallback["default"])) return fallback["default"][fallback["default"].length - 1];
2939
+ }
2940
+ if (typeof fallback === 'function') {
2941
+ var res = fallback(i18n.resolvedLanguage);
2942
+ if (typeof res === 'string') return res;
2943
+ if (Array.isArray(res)) return res[res.length - 1];
2944
+ }
2945
+ return 'dev';
2946
+ },
2947
+ getLocizeDetails: function getLocizeDetails() {
2948
+ var backendName;
2949
+ if (i18n.services.backendConnector.backend && i18n.services.backendConnector.backend.options && i18n.services.backendConnector.backend.options.loadPath && i18n.services.backendConnector.backend.options.loadPath.indexOf('.locize.') > 0) {
2950
+ backendName = 'I18NextLocizeBackend';
2951
+ } else {
2952
+ backendName = i18n.services.backendConnector.backend ? i18n.services.backendConnector.backend.constructor.name : 'options.resources';
2953
+ }
2954
+ var opts = {
2955
+ backendName: backendName,
2956
+ sourceLng: impl.getSourceLng(),
2957
+ i18nFormat: i18n.options.compatibilityJSON === 'v3' ? 'i18next_v3' : 'i18next_v4',
2958
+ i18nFramework: 'i18next',
2959
+ isLocizify: i18n.options.isLocizify,
2960
+ defaultNS: i18n.options.defaultNS
2961
+ };
2962
+ if (!i18n.options.backend && !i18n.options.editor) return opts;
2963
+ var pickFrom = i18n.options.backend || i18n.options.editor;
2964
+ return _objectSpread(_objectSpread({}, opts), {}, {
2965
+ projectId: pickFrom.projectId,
2966
+ version: pickFrom.version
2967
+ });
2968
+ },
2969
+ bindLanguageChange: function bindLanguageChange(cb) {
2970
+ i18n.on('languageChanged', cb);
2971
+ },
2972
+ bindMissingKeyHandler: function bindMissingKeyHandler(cb) {
2973
+ i18n.options.missingKeyHandler = function (lng, ns, k, val, isUpdate, opts) {
2974
+ if (!isUpdate) cb(lng, ns, k, val);
2975
+ };
2976
+ },
2977
+ triggerRerender: function triggerRerender() {
2978
+ i18n.emit('editorSaved');
2979
+ }
2980
+ };
2981
+ return impl;
2982
+ }
2865
2983
  var i18next;
2866
2984
  var locizePlugin = {
2867
2985
  type: '3rdParty',
2868
2986
  init: function init(i18n) {
2869
2987
  var options = i18n.options;
2870
2988
  i18next = i18n;
2871
- if (!isInIframe) {
2872
- i18next.use(SubliminalPostProcessor);
2873
- if (typeof options.postProcess === 'string') {
2874
- options.postProcess = [options.postProcess, 'subliminal'];
2875
- } else if (Array.isArray(options.postProcess)) {
2876
- options.postProcess.push('subliminal');
2877
- } else {
2878
- options.postProcess = 'subliminal';
2879
- }
2880
- options.postProcessPassResolved = true;
2881
- }
2882
- var impl = {
2883
- getResource: function getResource(lng, ns, key) {
2884
- return i18n.getResource(lng, ns, key);
2885
- },
2886
- setResource: function setResource(lng, ns, key, value) {
2887
- return i18n.addResource(lng, ns, key, value, {
2888
- silent: true
2889
- });
2890
- },
2891
- getResourceBundle: function getResourceBundle(lng, ns, cb) {
2892
- i18n.loadNamespaces(ns, function () {
2893
- cb(i18n.getResourceBundle(lng, ns));
2894
- });
2895
- },
2896
- getLng: function getLng() {
2897
- return i18n.languages[0];
2898
- },
2899
- getSourceLng: function getSourceLng() {
2900
- var fallback = i18n.options.fallbackLng;
2901
- if (typeof fallback === 'string') return fallback;
2902
- if (Array.isArray(fallback)) return fallback[fallback.length - 1];
2903
- if (fallback && fallback["default"]) {
2904
- if (typeof fallback["default"] === 'string') return fallback;
2905
- if (Array.isArray(fallback["default"])) return fallback["default"][fallback["default"].length - 1];
2906
- }
2907
- if (typeof fallback === 'function') {
2908
- var res = fallback(i18n.resolvedLanguage);
2909
- if (typeof res === 'string') return res;
2910
- if (Array.isArray(res)) return res[res.length - 1];
2911
- }
2912
- return 'dev';
2913
- },
2914
- getLocizeDetails: function getLocizeDetails() {
2915
- var backendName;
2916
- if (i18n.services.backendConnector.backend && i18n.services.backendConnector.backend.options && i18n.services.backendConnector.backend.options.loadPath && i18n.services.backendConnector.backend.options.loadPath.indexOf('.locize.') > 0) {
2917
- backendName = 'I18NextLocizeBackend';
2918
- } else {
2919
- backendName = i18n.services.backendConnector.backend ? i18n.services.backendConnector.backend.constructor.name : 'options.resources';
2920
- }
2921
- var opts = {
2922
- backendName: backendName,
2923
- sourceLng: impl.getSourceLng(),
2924
- i18nFormat: i18n.options.compatibilityJSON === 'v3' ? 'i18next_v3' : 'i18next_v4',
2925
- i18nFramework: 'i18next',
2926
- isLocizify: i18n.options.isLocizify,
2927
- defaultNS: i18n.options.defaultNS
2928
- };
2929
- if (!i18n.options.backend && !i18n.options.editor) return opts;
2930
- var pickFrom = i18n.options.backend || i18n.options.editor;
2931
- return _objectSpread(_objectSpread({}, opts), {}, {
2932
- projectId: pickFrom.projectId,
2933
- version: pickFrom.version
2934
- });
2935
- },
2936
- bindLanguageChange: function bindLanguageChange(cb) {
2937
- i18n.on('languageChanged', cb);
2938
- },
2939
- bindMissingKeyHandler: function bindMissingKeyHandler(cb) {
2940
- i18n.options.missingKeyHandler = function (lng, ns, k, val, isUpdate, opts) {
2941
- if (!isUpdate) cb(lng, ns, k, val);
2942
- };
2943
- },
2944
- triggerRerender: function triggerRerender() {
2945
- i18n.emit('editorSaved');
2946
- }
2947
- };
2989
+ if (!isInIframe) configurePostProcessor(i18next, options);
2990
+ var impl = getImplementation(i18n);
2948
2991
  if (!isInIframe) {
2949
2992
  start(impl);
2950
2993
  } else {
@@ -2952,6 +2995,25 @@
2952
2995
  }
2953
2996
  }
2954
2997
  };
2998
+ var locizeEditorPlugin = function locizeEditorPlugin() {
2999
+ var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3000
+ opt.qsProp = opt.qsProp || 'incontext';
3001
+ return {
3002
+ type: '3rdParty',
3003
+ init: function init(i18n) {
3004
+ var options = i18n.options;
3005
+ i18next = i18n;
3006
+ var showInContext = getQsParameterByName(opt.qsProp) === 'true';
3007
+ if (!isInIframe && showInContext) configurePostProcessor(i18next, options);
3008
+ var impl = getImplementation(i18n);
3009
+ if (!isInIframe && showInContext) {
3010
+ start(impl);
3011
+ } else {
3012
+ startLegacy(impl);
3013
+ }
3014
+ }
3015
+ };
3016
+ };
2955
3017
 
2956
3018
  function startStandalone() {
2957
3019
  startLegacy({
@@ -2977,6 +3039,7 @@
2977
3039
  PostProcessor: SubliminalPostProcessor,
2978
3040
  addLocizeSavedHandler: addLocizeSavedHandler,
2979
3041
  locizePlugin: locizePlugin,
3042
+ locizeEditorPlugin: locizeEditorPlugin,
2980
3043
  turnOn: turnOn,
2981
3044
  turnOff: turnOff,
2982
3045
  setEditorLng: setEditorLng,
@@ -2987,6 +3050,7 @@
2987
3050
  exports.addLocizeSavedHandler = addLocizeSavedHandler;
2988
3051
  exports.containsHiddenMeta = containsHiddenMeta;
2989
3052
  exports["default"] = index;
3053
+ exports.locizeEditorPlugin = locizeEditorPlugin;
2990
3054
  exports.locizePlugin = locizePlugin;
2991
3055
  exports.setEditorLng = setEditorLng;
2992
3056
  exports.startStandalone = startStandalone;