diff --git a/Build/Sources/Core13/localization.js b/Build/Sources/Core13/localization.js new file mode 100644 index 00000000..8ed6f31e --- /dev/null +++ b/Build/Sources/Core13/localization.js @@ -0,0 +1,13 @@ +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ +import DocumentService from"@typo3/core/document-service.js";import $ from"jquery";import{SeverityEnum}from"@typo3/backend/enum/severity.js";import AjaxRequest from"@typo3/core/ajax/ajax-request.js";import Icons from"@typo3/backend/icons.js";import Modal from"@typo3/backend/modal.js";import MultiStepWizard from"@typo3/backend/multi-step-wizard.js";import"@typo3/backend/element/icon-element.js";import{MarkupIdentifiers}from"@typo3/backend/enum/icon-types.js";class Localization{constructor(){this.triggerButton=".t3js-localize",DocumentService.ready().then((()=>{this.initialize()}))}async initialize(){const e=await Icons.getIcon("actions-localize",Icons.sizes.large),t=await Icons.getIcon("actions-edit-copy",Icons.sizes.large),a=await Icons.getIcon("actions-localize-deepl",Icons.sizes.large,null,null,MarkupIdentifiers.inline);$(this.triggerButton).removeClass("disabled"),$(document).on("click",this.triggerButton,(async l=>{l.preventDefault();const o=$(l.currentTarget),n=[],i=[];if(0===o.data("allowTranslate")&&0===o.data("allowCopy"))return void Modal.confirm(TYPO3.lang["window.localization.mixed_mode.title"],TYPO3.lang["window.localization.mixed_mode.message"],SeverityEnum.warning,[{text:TYPO3?.lang?.["button.ok"]||"OK",btnClass:"btn-warning",name:"ok",trigger:(e,t)=>t.hideModal()}]);const c=await(await this.loadAvailableLanguages(parseInt(o.data("pageId"),10),parseInt(o.data("languageId"),10))).resolve();if(o.data("allowTranslate")&&(n.push('

'+TYPO3.lang["localize.educate.translate"]+"

"),i.push("localize")),o.data("allowCopy")&&(n.push('

'+TYPO3.lang["localize.educate.copy"]+"

"),i.push("copyFromLanguage")),n.push('

'+TYPO3.lang["localize.educate.deepltranslate"]+"

"),i.push("localizedeepl"),n.push('

'+TYPO3.lang["localize.educate.deepltranslateAuto"]+"

"),i.push("localizedeeplauto"),1===i.length)MultiStepWizard.set("localizationMode",i[0]);else{const e=document.createElement("div");e.dataset.bsToggle="buttons",e.append(...n.map((e=>document.createRange().createContextualFragment(e)))),MultiStepWizard.addSlide("localize-choose-action",TYPO3.lang["localize.wizard.header_page"].replace("{0}",o.data("page")).replace("{1}",o.data("languageName")),e,SeverityEnum.notice,TYPO3.lang["localize.wizard.step.selectMode"],((e,t)=>{void 0!==t.localizationMode&&MultiStepWizard.unlockNextStep()}))}1===c.length?MultiStepWizard.set("sourceLanguage",c[0].uid):MultiStepWizard.addSlide("localize-choose-language",TYPO3.lang["localize.view.chooseLanguage"],"",SeverityEnum.notice,TYPO3.lang["localize.wizard.step.chooseLanguage"],(async(e,t)=>{void 0!==t.sourceLanguage&&MultiStepWizard.unlockNextStep(),e.html('
'+await Icons.getIcon("spinner-circle",Icons.sizes.large)+"
"),MultiStepWizard.getComponent().on("change",".t3js-language-option",(e=>{MultiStepWizard.set("sourceLanguage",$(e.currentTarget).val()),MultiStepWizard.unlockNextStep()}));const a=$("
",{class:"row"});for(const e of c){const t="language"+e.uid,l=$("",{type:"radio",name:"language",id:t,value:e.uid,class:"btn-check t3js-language-option"}),o=$("