Add this function inside your theme file. Example for theme named scriptun.
// /themes/scriptun/scriptun.theme
function scriptun_preprocess_field(&$variables) {
$variables['language_id'] = \Drupal::languageManager()->getCurrentLanguage()->getId();
}
Variable with language id will be available for all fields and any theme suggestion used.
{# /themes/scriptun/templates/field/field.html.twig #}
This is language id: {{ language_id }}
{% if (language_id == 'en') %}
This text is visible only for english
{% endif %}
Add new comment