I am building a bilingual site with Drupal 10 and I am using views to show content items listings. In my views I am using field: Custom text to format the teasers of each item the way I want.

I have translated all the fields of my content types and my issue is how to show in the custom text each field's label.

Here is how my view's configuration looks like: enter image description here

Here is an example of such a custom text:

<div class="col-sm-12 teaser-wrapper">
    <div class="teaser-image">{{ field_image }}</div>
    <div class="teaser-header">{{ title }}</div>
    <div class="teaser-text">{{ body }}</div>
    <div class="row teaser-field">
        <div class="col-xs-12 col-sm-12 teaser-field">
                <span class="lbl">Location: </span>
                <span class="val">{{ field_region }}</span>
        <div class="col-xs-12 col-sm-12 teaser-field">
                <span class="lbl">Path Length: </span>
                <span class="val">{{ field_path_length }}</span>
        <div class="col-xs-12 col-sm-12 teaser-field">
                <span class="lbl">Activities: </span>
                <span class="val">{{ field_nature_activities }}</span>

As you can see at the moment I am just using hardcoded values for the labels.

How can I print their translated values?

  • Have you tried <span class="lbl">{{ 'Location'|t }}: </span>?
    – leymannx
    Commented Oct 5, 2023 at 10:44
  • No, but what exactly 'Location' is supposed to be? I have tried with using custom field's label (which is translated) without luck.
    – thanili
    Commented Oct 5, 2023 at 11:13
  • I don't understand why this question has been downvoted. Some of us are new to Drupal; so do you expect from us to be able in a couple of months to have deep knowledge on all of it's aspects and different concepts? Does my question show lack of effort or is not clear? I have searched the web for an answer and read dozens of posts and documents relevant with Drupal views before posting. Why do "you" penalize people for asking when their aim is just to acquire knowledge? Have "you" born with the knowledge or is it a privilege that you need to pay in order to get?
    – thanili
    Commented Oct 5, 2023 at 13:38

1 Answer 1


You can use

<span class="lbl">{% trans %}Location{% endtrans %}: </span>
  • Thanks, but what exactly 'Location' is supposed to be? Original's custom field label? A custom label that I can create somehow and then translate?
    – thanili
    Commented Oct 5, 2023 at 11:12
  • Yes, a custom label from your question code. You can translate it
    – Vanish
    Commented Oct 5, 2023 at 12:08
  • Thanks, I will try it
    – thanili
    Commented Oct 5, 2023 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.