-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
15 changed files
with
112 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,11 @@ | |
"homepage": "https://github.com/ibexa/automated-translation", | ||
"type": "ibexa-bundle", | ||
"authors": [ | ||
{ | ||
"name": "Ibexa AS", | ||
"homepage": "https://ibexa.co", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Novactive", | ||
"homepage": "http://www.novactive.us", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
services: | ||
ibexa.automated_translation.adminui.component.javascripts: | ||
ibexa.automated_translation.component.javascripts: | ||
parent: Ibexa\AdminUi\Component\TwigComponent | ||
public: false | ||
arguments: | ||
$template: '@@IbexaAutomatedTranslation/adminui/javascripts.html.twig' | ||
$template: '@@ibexadesign/automated_translation/javascripts.html.twig' | ||
tags: | ||
- { name: ibexa.admin_ui.component, group: 'script-body' } | ||
|
||
ibexa.automated_translation.component.add_translation_body: | ||
parent: Ibexa\AdminUi\Component\TwigComponent | ||
arguments: | ||
$template: '@@ibexadesign/automated_translation/form_fields.html.twig' | ||
tags: | ||
- { name: ibexa.admin_ui.component, group: 'form-content-add-translation-body' } |
16 changes: 2 additions & 14 deletions
16
src/bundle/Resources/public/admin/css/ibexa-automated-translation.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,3 @@ | ||
.ibexa-automated-translation { | ||
.modal-body { | ||
display: flex; | ||
flex-direction: column; | ||
padding-bottom: 8.75rem; | ||
|
||
.modal-body-base { | ||
display: flex; | ||
} | ||
|
||
.ibexa-automated-translation-services-container { | ||
padding-top: 15pt; | ||
} | ||
} | ||
.ibexa-automated-translation-services-container { | ||
padding-top: 15pt; | ||
} |
72 changes: 16 additions & 56 deletions
72
src/bundle/Resources/public/admin/js/ibexa-automated-translation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,17 @@ | ||
jQuery(function () { | ||
let $ = jQuery; | ||
let $form = $("form[name=add-translation]", "#add-translation-modal"); | ||
let $container = $(".ibexa-automated-translation-services-container:first", $form); | ||
let $error = $(".ibexa-automated-translation-error", $container); | ||
|
||
$form.click(function () { | ||
$error.addClass("invisible"); | ||
}); | ||
|
||
$container.find(".ibexa-field-edit--ezboolean .ibexa-data-source__label").click(function () { | ||
let $input = $(this).find("input[type='checkbox']"); | ||
let isChecked = $input.attr('checked') === 'checked'; | ||
|
||
if (isChecked) { | ||
$input.removeAttr('checked'); | ||
$(this).removeClass('is-checked'); | ||
} else { | ||
$(this).addClass('is-checked'); | ||
$input.attr('checked', 'checked'); | ||
} | ||
return false; | ||
}); | ||
|
||
$container.find(".ibexa-data-source__label.is-checked").each(() => { | ||
$form.find('.ibexa-btn--create-translation').prop("disabled", false); | ||
}); | ||
|
||
$container.find(".ibexa-dropdown__source select option:selected").each(() => { | ||
$form.find('.ibexa-btn--create-translation').prop("disabled", false); | ||
}); | ||
|
||
$("form[name=add-translation]").submit(function () { | ||
let targetLang = $("select[name=add-translation\\[language\\]]").val(); | ||
let sourceLang = $("select[name=add-translation\\[base_language\\]]").val(); | ||
let mapping = $container.data('languages-mapping'); | ||
let $serviceSelector = $("#add-translation_translatorAlias"); | ||
let serviceAlias = $serviceSelector.val(); | ||
if ($serviceSelector.is("[type=checkbox]") && !$serviceSelector.is(":checked")) { | ||
serviceAlias = ''; | ||
} | ||
|
||
if (!serviceAlias.length) { | ||
return true; | ||
} | ||
|
||
let translationAvailable = (typeof sourceLang === 'undefined' || -1 !== $.inArray(sourceLang, mapping[serviceAlias])) && (-1 !== $.inArray(targetLang, mapping[serviceAlias])); | ||
if (false === translationAvailable) { | ||
$error.removeClass("invisible"); | ||
if ($container.find(".ibexa-field-edit--ezboolean .ibexa-data-source__label").hasClass('is-checked')) { | ||
$container.find(".ibexa-field-edit--ezboolean .ibexa-data-source__label").click(); | ||
return false; | ||
((doc) => { | ||
const TRANSLATOR_SELECT_SELECTOR = '#add-translation_translatorAlias'; | ||
const BASE_LANGUAGE_SELECT_SELECTOR = '#add-translation_base_language'; | ||
|
||
const translatorSelect = doc.querySelector(TRANSLATOR_SELECT_SELECTOR); | ||
const baseLanguageSelect = doc.querySelector(BASE_LANGUAGE_SELECT_SELECTOR); | ||
if (baseLanguageSelect && translatorSelect) { | ||
baseLanguageSelect.addEventListener('change', () => { | ||
translatorSelect.disabled = !baseLanguageSelect.value; | ||
|
||
const translationSelectWrapper = translatorSelect.closest('.ibexa-dropdown'); | ||
if (translationSelectWrapper) { | ||
translationSelectWrapper.classList.toggle('ibexa-dropdown--disabled', !baseLanguageSelect.value); | ||
} | ||
} | ||
return true; | ||
}); | ||
}); | ||
}); | ||
} | ||
}) (document); |
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
src/bundle/Resources/translations/ibexa_automated_translation.en.xliff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2"> | ||
<file source-language="en" target-language="en" datatype="plaintext" original="not.available"> | ||
<header> | ||
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/> | ||
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note> | ||
</header> | ||
<body> | ||
<trans-unit id="6cd2ce682c3546de9a86ff3390701d81e46a99e2" resname="ibexa.language.create.language_code"> | ||
<source>Language code</source> | ||
<target state="new">Language code</target> | ||
<note>key: ibexa.language.create.language_code</note> | ||
</trans-unit> | ||
<trans-unit id="e7de62309ac728e1694040c140243cf918c33e60" resname="tab.translations.remote.translation.service"> | ||
<source>Use automatic translation</source> | ||
<target state="new">Use automatic translation</target> | ||
<note>key: tab.translations.remote.translation.service</note> | ||
</trans-unit> | ||
<trans-unit id="9c26b8f27857a53af3b30f1c0b0963d344fe2996" resname="tab.translations.remote.translation.service.with"> | ||
<source>Use automatic translation with %alias%</source> | ||
<target state="new">Use automatic translation with %alias%</target> | ||
<note>key: tab.translations.remote.translation.service.with</note> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
src/bundle/Resources/views/themes/admin/automated_translation/form_fields.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{% trans_default_domain 'ibexa_automated_translation' %} | ||
|
||
{% if form.vars.autotranslated_data is defined %} | ||
<div class="ibexa-automated-translation-services-container"> | ||
{% if form.translatorAlias.vars.choices is defined %} | ||
{# that is a select - then multiple providers #} | ||
<label class="ibexa-label form-label"> | ||
{{ 'tab.translations.remote.translation.service'|trans()|desc('Use automatic translation') }} | ||
</label> | ||
{{ form_widget(form.translatorAlias) }} | ||
{% else %} | ||
{# that is a checkbox - then one provider #} | ||
{{ form_widget(form.translatorAlias, { | ||
label: 'tab.translations.remote.translation.service.with'|trans({"%alias%": form.translatorAlias.vars.label })|desc('Use automatic translation with %alias%'), | ||
}) }} | ||
{% endif %} | ||
</div> | ||
{% endif %} |
2 changes: 1 addition & 1 deletion
2
...urces/views/adminui/javascripts.html.twig → ...tomated_translation/javascripts.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
{{ encore_entry_script_tags('ibexa-automated-translation-js', null, 'ibexa') }} | ||
{{ encore_entry_link_tags('ibexa-automated-translation-css', null, 'ibexa') }} | ||
{{ encore_entry_script_tags('ibexa-automated-translation-js', null, 'ibexa') }} |
39 changes: 0 additions & 39 deletions
39
src/bundle/Resources/views/themes/admin/content/modal/add_translation.html.twig
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
src/bundle/Resources/views/themes/admin/content/remote_translate_form_fields.html.twig
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters