<?php
use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;
/* @ui2022/translate_widget.html.twig */
class __TwigTemplate_d7e60a44a84a287f52abf827860d08ea extends \Twig\Template
{
private $source;
private $macros = [];
public function __construct(Environment $env)
{
parent::__construct($env);
$this->source = $this->getSourceContext();
$this->parent = false;
$this->blocks = [
];
}
protected function doDisplay(array $context, array $blocks = [])
{
$macros = $this->macros;
$__internal_5a27a8ba21ca79b61932376b2fa922d2 = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
$__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "@ui2022/translate_widget.html.twig"));
$__internal_6f47bbe9983af81f1e7450e9a3e3768f = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
$__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "@ui2022/translate_widget.html.twig"));
// line 1
$context["translationLanguages"] = ((twig_get_attribute($this->env, $this->source, ($context["_args"] ?? null), "languages", [], "any", true, true, false, 1)) ? (_twig_default_filter(twig_get_attribute($this->env, $this->source, ($context["_args"] ?? null), "languages", [], "any", false, false, false, 1), twig_get_attribute($this->env, $this->source, (isset($context["cms"]) || array_key_exists("cms", $context) ? $context["cms"] : (function () { throw new RuntimeError('Variable "cms" does not exist.', 1, $this->source); })()), "translationLanguages", [], "any", false, false, false, 1))) : (twig_get_attribute($this->env, $this->source, (isset($context["cms"]) || array_key_exists("cms", $context) ? $context["cms"] : (function () { throw new RuntimeError('Variable "cms" does not exist.', 1, $this->source); })()), "translationLanguages", [], "any", false, false, false, 1)));
// line 2
$context["userEffectiveLanguage"] = twig_get_attribute($this->env, $this->source, (isset($context["cms"]) || array_key_exists("cms", $context) ? $context["cms"] : (function () { throw new RuntimeError('Variable "cms" does not exist.', 2, $this->source); })()), "userEffectiveLanguage", [], "any", false, false, false, 2);
// line 3
echo "
";
// line 4
if ( !twig_test_empty((isset($context["translationLanguages"]) || array_key_exists("translationLanguages", $context) ? $context["translationLanguages"] : (function () { throw new RuntimeError('Variable "translationLanguages" does not exist.', 4, $this->source); })()))) {
// line 5
echo " ";
$context["defaultLanguage"] = twig_constant("App\\Util\\Locales::ISO6391__ENGLISH");
// line 6
echo " ";
$context["defaultLanguageHumanReadable"] = twig_get_attribute($this->env, $this->source, twig_constant("App\\Util\\Locales::ISO6391_HUMAN_READABLE"), (isset($context["defaultLanguage"]) || array_key_exists("defaultLanguage", $context) ? $context["defaultLanguage"] : (function () { throw new RuntimeError('Variable "defaultLanguage" does not exist.', 6, $this->source); })()), [], "array", false, false, false, 6);
// line 7
echo " ";
$context["translationLanguages"] = twig_array_merge([(isset($context["defaultLanguage"]) || array_key_exists("defaultLanguage", $context) ? $context["defaultLanguage"] : (function () { throw new RuntimeError('Variable "defaultLanguage" does not exist.', 7, $this->source); })()) => (isset($context["defaultLanguageHumanReadable"]) || array_key_exists("defaultLanguageHumanReadable", $context) ? $context["defaultLanguageHumanReadable"] : (function () { throw new RuntimeError('Variable "defaultLanguageHumanReadable" does not exist.', 7, $this->source); })())], (isset($context["translationLanguages"]) || array_key_exists("translationLanguages", $context) ? $context["translationLanguages"] : (function () { throw new RuntimeError('Variable "translationLanguages" does not exist.', 7, $this->source); })()));
// line 8
echo "
";
// line 9
$this->extensions['App\Twig\Extension\DomExtension']->dom_scripts_($context, "head", [0 => "https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"]);
// line 12
echo "
<div class=\"col-auto mp__head-right\">
<div id=\"language-switcher\" class=\"dropdown dropdown-lang notranslate\">
<a class=\"select-lang dropdown-toggle\" href=\"#\" role=\"button\" data-toggle=\"dropdown\"
aria-expanded=\"false\">";
// line 16
echo twig_escape_filter($this->env, twig_get_attribute($this->env, $this->source, (isset($context["translationLanguages"]) || array_key_exists("translationLanguages", $context) ? $context["translationLanguages"] : (function () { throw new RuntimeError('Variable "translationLanguages" does not exist.', 16, $this->source); })()), (isset($context["userEffectiveLanguage"]) || array_key_exists("userEffectiveLanguage", $context) ? $context["userEffectiveLanguage"] : (function () { throw new RuntimeError('Variable "userEffectiveLanguage" does not exist.', 16, $this->source); })()), [], "array", false, false, false, 16), "html", null, true);
echo "</a>
<div class=\"dropdown-menu\" aria-labelledby=\"select-language\">
";
// line 19
$context['_parent'] = $context;
$context['_seq'] = twig_ensure_traversable((isset($context["translationLanguages"]) || array_key_exists("translationLanguages", $context) ? $context["translationLanguages"] : (function () { throw new RuntimeError('Variable "translationLanguages" does not exist.', 19, $this->source); })()));
foreach ($context['_seq'] as $context["lang"] => $context["name"]) {
// line 20
echo " <a class=\"dropdown-item";
if (((isset($context["userEffectiveLanguage"]) || array_key_exists("userEffectiveLanguage", $context) ? $context["userEffectiveLanguage"] : (function () { throw new RuntimeError('Variable "userEffectiveLanguage" does not exist.', 20, $this->source); })()) === $context["lang"])) {
echo " d-none";
}
echo "\"
href=\"#\" data-href=\"";
// line 21
echo twig_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("app.notifications.portal.language.set", ["language" => $context["lang"]]), "html", null, true);
echo "\"
data-lang=\"";
// line 22
echo twig_escape_filter($this->env, $context["lang"], "html", null, true);
echo "\">";
echo twig_escape_filter($this->env, $context["name"], "html", null, true);
echo "</a>
";
}
$_parent = $context['_parent'];
unset($context['_seq'], $context['_iterated'], $context['lang'], $context['name'], $context['_parent'], $context['loop']);
$context = array_intersect_key($context, $_parent) + $_parent;
// line 24
echo " </div>
</div>
</div>
<script type=\"text/javascript\">
(function (window, document, \$, undefined) {
\$(function () {
\$('#language-switcher .dropdown-menu').on('click', 'a.dropdown-item', function (e) {
e.preventDefault();
var lang = \$(this).attr('data-lang');
\$('#language-switcher .select-lang').text(\$(this).text());
\$('#language-switcher .dropdown-menu .dropdown-item').each(function (index, elem) {
\$(elem).toggleClass(
'd-none',
(\$(elem).attr('data-lang') === lang)
);
});
";
// line 44
if (twig_get_attribute($this->env, $this->source, (isset($context["app"]) || array_key_exists("app", $context) ? $context["app"] : (function () { throw new RuntimeError('Variable "app" does not exist.', 44, $this->source); })()), "user", [], "any", false, false, false, 44)) {
// line 45
echo " \$.ajax({
url: \$(this).attr('data-href'),
method: 'GET',
});
";
}
// line 50
echo "
if (lang === '";
// line 51
echo twig_escape_filter($this->env, (isset($context["defaultLanguage"]) || array_key_exists("defaultLanguage", $context) ? $context["defaultLanguage"] : (function () { throw new RuntimeError('Variable "defaultLanguage" does not exist.', 51, $this->source); })()), "html", null, true);
echo "') {
dismissGoogleTranslate();
\$('#language-switcher .select-lang').text('";
// line 53
echo twig_escape_filter($this->env, (isset($context["defaultLanguageHumanReadable"]) || array_key_exists("defaultLanguageHumanReadable", $context) ? $context["defaultLanguageHumanReadable"] : (function () { throw new RuntimeError('Variable "defaultLanguageHumanReadable" does not exist.', 53, $this->source); })()), "html", null, true);
echo "');
} else {
triggerLangChangeEvent(document.querySelector('.goog-te-combo'), 'change', lang);
}
});
});
})(window, document, jQuery);
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: '";
// line 65
echo twig_escape_filter($this->env, (isset($context["defaultLanguage"]) || array_key_exists("defaultLanguage", $context) ? $context["defaultLanguage"] : (function () { throw new RuntimeError('Variable "defaultLanguage" does not exist.', 65, $this->source); })()), "html", null, true);
echo "',
includedLanguages: '";
// line 66
echo twig_escape_filter($this->env, twig_join_filter(twig_get_array_keys_filter((isset($context["translationLanguages"]) || array_key_exists("translationLanguages", $context) ? $context["translationLanguages"] : (function () { throw new RuntimeError('Variable "translationLanguages" does not exist.', 66, $this->source); })())), ","), "html", null, true);
echo "',
layout: google.translate.TranslateElement.InlineLayout.simple,
}, 'google_translate_element');
// set cookie
var lang = '";
// line 72
echo twig_escape_filter($this->env, (isset($context["userEffectiveLanguage"]) || array_key_exists("userEffectiveLanguage", $context) ? $context["userEffectiveLanguage"] : (function () { throw new RuntimeError('Variable "userEffectiveLanguage" does not exist.', 72, $this->source); })()), "html", null, true);
echo "';
var intervalId = setInterval(function(){
if (\$('.goog-te-combo').length > 0){ // Check if element has been found
if (lang !== '";
// line 75
echo twig_escape_filter($this->env, (isset($context["defaultLanguage"]) || array_key_exists("defaultLanguage", $context) ? $context["defaultLanguage"] : (function () { throw new RuntimeError('Variable "defaultLanguage" does not exist.', 75, $this->source); })()), "html", null, true);
echo "' && \$('.goog-te-combo').val() !== lang) {
triggerLangChangeEvent(document.querySelector('.goog-te-combo'), 'change', lang);
}
clearInterval(intervalId);
}
}, 1000);
}
// fire google change event, set cookie
function triggerLangChangeEvent(element, eventName, lang) {
\$('.goog-te-combo').val(lang);
var event;
if (document.createEvent) {
event = document.createEvent('HTMLEvents');
event.initEvent(eventName, true, true);
element.dispatchEvent(event);
} else {
event = document.createEventObject();
event.eventType = eventName;
element.fireEvent('on' + event.eventType, event);
}
}
// back to default language
function dismissGoogleTranslate() {
// find `iframe` element with GoogleTranslate select and buttons
var iframe = document.getElementsByClassName('goog-te-banner-frame')[0]
|| document.getElementById(':1.container');
if (!iframe) return;
// search all buttons from the retrieved iframe
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var restore_el = innerDoc.getElementsByTagName(\"button\");
// fire `click` event on the `restore` button, that `Shows the origin`
for (var i = 0; i < restore_el.length; i++) {
if (restore_el[i].id.indexOf(\"restore\") >= 0) {
restore_el[i].click();
return;
}
}
}
</script>
<div class=\"google-translate d-none\" id=\"google_translate_element\"></div>
<style>
body {
position: static !important;
top: 0 !important;
}
.skiptranslate {
display: none !important;
}
</style>
";
}
$__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof);
$__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof);
}
public function getTemplateName()
{
return "@ui2022/translate_widget.html.twig";
}
public function isTraitable()
{
return false;
}
public function getDebugInfo()
{
return array ( 176 => 75, 170 => 72, 161 => 66, 157 => 65, 142 => 53, 137 => 51, 134 => 50, 127 => 45, 125 => 44, 103 => 24, 93 => 22, 89 => 21, 82 => 20, 78 => 19, 72 => 16, 66 => 12, 64 => 9, 61 => 8, 58 => 7, 55 => 6, 52 => 5, 50 => 4, 47 => 3, 45 => 2, 43 => 1,);
}
public function getSourceContext()
{
return new Source("{% set translationLanguages = _args.languages|default(cms.translationLanguages) %}
{% set userEffectiveLanguage = cms.userEffectiveLanguage %}
{% if translationLanguages is not empty %}
{% set defaultLanguage = constant('App\\\\Util\\\\Locales::ISO6391__ENGLISH') %}
{% set defaultLanguageHumanReadable = (constant('App\\\\Util\\\\Locales::ISO6391_HUMAN_READABLE'))[defaultLanguage] %}
{% set translationLanguages = {(defaultLanguage): defaultLanguageHumanReadable}|merge(translationLanguages) %}
{% do dom_scripts_head([
'https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit',
]) %}
<div class=\"col-auto mp__head-right\">
<div id=\"language-switcher\" class=\"dropdown dropdown-lang notranslate\">
<a class=\"select-lang dropdown-toggle\" href=\"#\" role=\"button\" data-toggle=\"dropdown\"
aria-expanded=\"false\">{{ translationLanguages[userEffectiveLanguage] }}</a>
<div class=\"dropdown-menu\" aria-labelledby=\"select-language\">
{% for lang, name in translationLanguages %}
<a class=\"dropdown-item{% if userEffectiveLanguage is same as(lang) %} d-none{% endif %}\"
href=\"#\" data-href=\"{{ path('app.notifications.portal.language.set', {language: lang}) }}\"
data-lang=\"{{ lang }}\">{{ name }}</a>
{% endfor %}
</div>
</div>
</div>
<script type=\"text/javascript\">
(function (window, document, \$, undefined) {
\$(function () {
\$('#language-switcher .dropdown-menu').on('click', 'a.dropdown-item', function (e) {
e.preventDefault();
var lang = \$(this).attr('data-lang');
\$('#language-switcher .select-lang').text(\$(this).text());
\$('#language-switcher .dropdown-menu .dropdown-item').each(function (index, elem) {
\$(elem).toggleClass(
'd-none',
(\$(elem).attr('data-lang') === lang)
);
});
{% if app.user %}
\$.ajax({
url: \$(this).attr('data-href'),
method: 'GET',
});
{% endif %}
if (lang === '{{ defaultLanguage }}') {
dismissGoogleTranslate();
\$('#language-switcher .select-lang').text('{{ defaultLanguageHumanReadable }}');
} else {
triggerLangChangeEvent(document.querySelector('.goog-te-combo'), 'change', lang);
}
});
});
})(window, document, jQuery);
function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: '{{ defaultLanguage }}',
includedLanguages: '{{ translationLanguages|keys|join(',') }}',
layout: google.translate.TranslateElement.InlineLayout.simple,
}, 'google_translate_element');
// set cookie
var lang = '{{ userEffectiveLanguage }}';
var intervalId = setInterval(function(){
if (\$('.goog-te-combo').length > 0){ // Check if element has been found
if (lang !== '{{ defaultLanguage }}' && \$('.goog-te-combo').val() !== lang) {
triggerLangChangeEvent(document.querySelector('.goog-te-combo'), 'change', lang);
}
clearInterval(intervalId);
}
}, 1000);
}
// fire google change event, set cookie
function triggerLangChangeEvent(element, eventName, lang) {
\$('.goog-te-combo').val(lang);
var event;
if (document.createEvent) {
event = document.createEvent('HTMLEvents');
event.initEvent(eventName, true, true);
element.dispatchEvent(event);
} else {
event = document.createEventObject();
event.eventType = eventName;
element.fireEvent('on' + event.eventType, event);
}
}
// back to default language
function dismissGoogleTranslate() {
// find `iframe` element with GoogleTranslate select and buttons
var iframe = document.getElementsByClassName('goog-te-banner-frame')[0]
|| document.getElementById(':1.container');
if (!iframe) return;
// search all buttons from the retrieved iframe
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var restore_el = innerDoc.getElementsByTagName(\"button\");
// fire `click` event on the `restore` button, that `Shows the origin`
for (var i = 0; i < restore_el.length; i++) {
if (restore_el[i].id.indexOf(\"restore\") >= 0) {
restore_el[i].click();
return;
}
}
}
</script>
<div class=\"google-translate d-none\" id=\"google_translate_element\"></div>
<style>
body {
position: static !important;
top: 0 !important;
}
.skiptranslate {
display: none !important;
}
</style>
{% endif %}
", "@ui2022/translate_widget.html.twig", "/var/www/campussuite/ui2022/translate_widget.html.twig");
}
}