UNPKG

i18next-phrase-in-context-editor-post-processor

Version:
3 lines (2 loc) 2.67 kB
function t(){return t=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},t.apply(this,arguments)}require("@sagi.io/globalthis"),module.exports=/*#__PURE__*/function(){n.interpolateKey=function(t,e,i){return e+"phrase_"+t+i};var e,i,r=n.prototype;function n(e){this.defaultConfig={prefix:"{{__",suffix:"__}}",fullReparse:!0,useOldICE:!1,scriptAutoLoad:!0,origin:"i18next-phrase-in-context-editor-post-processor"},this.phraseScript=void 0,this.type="postProcessor",this.name="phraseInContextEditor",this.config=t({},globalThis.PHRASEAPP_CONFIG,e),this.phraseEnabled=e.phraseEnabled}return r.loadInContextEditorScript=function(){if("undefined"!=typeof window){var t=document.createElement("script");t.type=this.config.useOldICE?"text/javascript":"module",t.async=!0,t.src=this.IN_CONTEXT_EDITOR_SCRIPT_URL;var e=document.getElementsByTagName("script")[0];return e&&e.parentNode?e.parentNode.insertBefore(t,e):document.body.appendChild(t),t}},r.interpolateKey=function(t){return n.interpolateKey(t,this.config.prefix,this.config.suffix)},r.process=function(t,e,i,r){return this.phraseEnabled?this.interpolateKey(e[0]):t},r.toScriptHTML=function(){return"<script>window.PHRASEAPP_ENABLED=true;window.PHRASEAPP_CONFIG="+JSON.stringify(this.config)+'<\/script><script type="text/javascript" async src="'+this.IN_CONTEXT_EDITOR_SCRIPT_URL+'"><\/script>'},e=n,(i=[{key:"IN_CONTEXT_EDITOR_SCRIPT_URL",get:function(){return this.config.useOldICE?"https://phrase.com/assets/in-context-editor/2.0/app.js?"+(new Date).getTime():"https://cdn.phrase.com/strings/plugins/editor/latest/ice/index.js"}},{key:"phraseEnabled",get:function(){return globalThis.PHRASEAPP_ENABLED},set:function(t){globalThis.PHRASEAPP_ENABLED=t,t&&this.config.scriptAutoLoad&&!this.phraseScript&&(this.phraseScript=this.loadInContextEditorScript())}},{key:"config",get:function(){return globalThis.PHRASEAPP_CONFIG},set:function(e){globalThis.PHRASEAPP_CONFIG=t({},this.defaultConfig,e)}}])&&function(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,"symbol"==typeof(n=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key))?n:String(n),r)}var n}(e.prototype,i),Object.defineProperty(e,"prototype",{writable:!1}),n}(); //# sourceMappingURL=i18next-phrase-in-context-editor-post-processor.js.map