-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
1 lines (1 loc) · 3.36 KB
/
index.js
1
(function(){"use strict";const w="";function c(a,t,e,o,d,l,i,b){var n=typeof a=="function"?a.options:a;t&&(n.render=t,n.staticRenderFns=e,n._compiled=!0),o&&(n.functional=!0),l&&(n._scopeId="data-v-"+l);var r;if(i?(r=function(s){s=s||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!s&&typeof __VUE_SSR_CONTEXT__<"u"&&(s=__VUE_SSR_CONTEXT__),d&&d.call(this,s),s&&s._registeredComponents&&s._registeredComponents.add(i)},n._ssrRegister=r):d&&(r=b?function(){d.call(this,(n.functional?this.parent:this).$root.$options.shadowRoot)}:d),r)if(n.functional){n._injectStyles=r;var v=n.render;n.render=function($,f){return r.call(f),v($,f)}}else{var u=n.beforeCreate;n.beforeCreate=u?[].concat(u,r):[r]}return{exports:a,options:n}}const h={data(){return{label:"",dateTranslated:"…",dateDefaultLanguage:"…"}},computed:{defaultLanguage(){return console.log(this.$languages),this.$languages.find(a=>a.default===!0).code.toUpperCase()},isDefaultLanguage(){return this.$language.default},helpHtml(){const{dateTranslated:a,dateDefaultLanguage:t,dateModified:e=null,defaultLanguage:o,isOutdated:d,$t:l}=this;let i="";return a&&(a===e?i+=l("tobiaswolf.machine-translation.section.info.translation.short",{dateTranslated:a,dateModified:e})+"<br>":i+=l("tobiaswolf.machine-translation.section.info.translation",{dateTranslated:a,dateModified:e})+"<br>"),a||(i+=l("tobiaswolf.machine-translation.section.info.translationNotTranslated")+"<br>"),i+=l("tobiaswolf.machine-translation.section.info.translationDefaultLanguage",{dateDefaultLanguage:t,defaultLanguage:o})+"<br>",d&&(i+=`<strong>${l("tobiaswolf.machine-translation.section.info.outdated")}</strong><br>`),i}},created(){this.load().then(a=>{this.label=a.label,this.updateProps()})},methods:{updateProps(){this.load().then(a=>{this.dateTranslated=a.dateTranslated,this.dateModified=a.dateModified,this.dateDefaultLanguage=a.dateDefaultLanguage,this.isOutdated=a.isOutdated})},async translate(){this.$urls.api;const a=this.$store.state.content.current,t={forceOverwrite:this.overwrite};await this.$api.request(`machine-translate${a}`,{method:"post",headers:{"x-csrf":this.$system.csrf,"x-language":this.$language.code},body:JSON.stringify(t)}).catch(o=>{console.error(o),this.$panel.notification.error(o)})&&(this.$reload(),this.updateProps())}}};var g=function(){var t=this,e=t._self._c;return e("section",{staticClass:"k-section k-machine-translate-section"},[e("header",{staticClass:"k-section-header"},[e("h2",{staticClass:"k-label k-section-label"},[e("span",{staticClass:"k-label-text"},[t._v(t._s(t.label))])])]),t.isDefaultLanguage?e("k-info-field",{attrs:{text:t.$t("tobiaswolf.machine-translation.section.info.defaultLanguage",{defaultLanguage:t.defaultLanguage})}}):t._e(),t.isDefaultLanguage?t._e():e("k-button",{attrs:{variant:"filled",icon:"globe"},on:{click:t.translate}},[t._v(" "+t._s(t.$t("tobiaswolf.machine-translation.section.translate"))+" ")]),t.isDefaultLanguage?t._e():e("k-input",{attrs:{type:"toggle",text:t.$t("tobiaswolf.machine-translation.section.toggle.overwrite"),name:"overwrite"},model:{value:t.overwrite,callback:function(o){t.overwrite=o},expression:"overwrite"}}),t.isDefaultLanguage?t._e():e("k-text",{staticClass:"k-field-help",attrs:{html:t.helpHtml}})],1)},_=[],p=c(h,g,_,!1,null,null,null,null);const m=p.exports;window.panel.plugin("tobiaswolf/machine-translation",{sections:{"machine-translate":m}})})();