vue-i18n-phrase-in-context-editor
Version:
Integrate Phrase In-Context Editor into your Vue I18n app with ease!
2 lines • 2.87 kB
JavaScript
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["vue-i18n-phrase-in-context-editor"]=t():e["vue-i18n-phrase-in-context-editor"]=t()})("undefined"!==typeof self?self:this,function(){return function(){var e={231:function(){(function(){"object"!==typeof globalThis&&(Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__)})()}},t={};function r(i){var n=t[i];if(void 0!==n)return n.exports;var o=t[i]={exports:{}};return e[i](o,o.exports,r),o.exports}!function(){r.d=function(e,t){for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})}}(),function(){r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}(),function(){r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}}(),function(){r.p=""}();var i={};return function(){"use strict";if(r.r(i),r.d(i,{VueI18nPhraseFormatter:function(){return n},default:function(){return p}}),"undefined"!==typeof window){var e=window.document.currentScript,t=e&&e.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);t&&(r.p=t[1])}r(231);class n{constructor(e){this.prefix=e.prefix,this.suffix=e.suffix}interpolate(e,t,r){return[this.prefix,"phrase_",r,this.suffix]}}class o{constructor(e,t){this.vueI18n=e,this.config={...globalThis.PHRASEAPP_CONFIG,...t},this.phraseEnabled=t.phraseEnabled}loadInContextEditor(){this.phraseScript=document.createElement("script"),this.phraseScript.async=!0,this.config.useOldICE?(this.phraseScript.type="text/javascript",this.phraseScript.src=`https://phrase.com/assets/in-context-editor/2.0/app.js?${(new Date).getTime()}`):(this.phraseScript.type="module",this.phraseScript.src="https://cdn.phrase.com/strings/plugins/editor/latest/ice/index.js");const e=document.getElementsByTagName("script")[0];e?.parentNode?e.parentNode.insertBefore(this.phraseScript,e):document.body.appendChild(this.phraseScript)}set phraseEnabled(e){globalThis.PHRASEAPP_ENABLED=e,e?(this.phraseScript||this.loadInContextEditor(),this.previousVueI18nFormatter=this.vueI18n.formatter,this.vueI18n.formatter=new n({prefix:this.config.prefix,suffix:this.config.suffix})):this.previousVueI18nFormatter&&(this.vueI18n.formatter=this.previousVueI18nFormatter)}get phraseEnabled(){return globalThis.PHRASEAPP_ENABLED}set config(e){globalThis.PHRASEAPP_CONFIG={...o.defaultConfig,...e}}get config(){return globalThis.PHRASEAPP_CONFIG}}o.defaultConfig={prefix:"{{__",suffix:"__}}",useOldICE:!1,fullReparse:!0,origin:"vue-i18n-phrase-in-context-editor"};var s=o,p=s}(),i}()});
//# sourceMappingURL=vue-i18n-phrase-in-context-editor.umd.min.js.map