<p>You can put the <code>t</code> filter <em>inside</em> the <code>default</code> filter, this way it only applies to the default value:</p>
<pre class="lang-twig prettyprint-override"><code>{{ craft.entries.section('mypage').one().title|default(&quot;My page&quot;|t) }}
</code></pre>

CC BY-SA 4.0
2022-04-20T10:42:20.383Z
2022-04-20T10:42:20.383Z
MoritzLost
<p>Moritz's answer should be correct. For readability I'd like to propose something like that:</p>
<pre><code>{% set mypage = craft.entries.section('mypage').one() %}
{% set title = mypage ? mypage.title : &quot;default title&quot;|t %}


{{ title }}
</code></pre>

CC BY-SA 4.0
2022-04-20T12:19:50.763Z
2022-04-20T12:19:50.763Z
Max Strebel
<p>Is it possible to write this as a one-liner?</p>
<pre><code>{% if craft.entries.section('mypage').one() != null %}
  {{ craft.entries.section('mypage').one().title }} {# If title is provided - use, but don't translate #}
{% else %}
  {{ &quot;My page&quot;|t }} {# Default value should be translated #}
{% endif %}
</code></pre>
<p>This is my solution so far, however this will translate both the default and the provided title. Is it possible to group these filters somehow to not translate the title?</p>
<pre><code>{{ craft.entries.section('mypage').one().title|default(&quot;My page&quot;)|t }}
</code></pre>

<templating><filter>
Translate only the default twig value (Nesting twig filters)
# Translate only the default twig value (Nesting twig filters)

(Asked by: username_0 on 2022-04-20)

Is it possible to write this as a one-liner?
{% if craft.entries.section('mypage').one() != null %}
  {{ craft.entries.section('mypage').one().title }} {# If title is provided - use, but don't translate #}
{% else %}
  {{ "My page"|t }} {# Default value should be translated #}
{% endif %}

This is my solution so far, however this will translate both the default and the provided title. Is it possible to group these filters somehow to not translate the title?
{{ craft.entries.section('mypage').one().title|default("My page")|t }}

**Tags:** templating, filter

---

## 2 answers

### Answer by username_1 on 2022-04-20. Score: 2 | Accepted answer

You can put the t filter inside the default filter, this way it only applies to the default value:
{{ craft.entries.section('mypage').one().title|default("My page"|t) }}


---

### Answer by username_2 on 2022-04-20. Score: 1

Moritz's answer should be correct. For readability I'd like to propose something like that:
{% set mypage = craft.entries.section('mypage').one() %}
{% set title = mypage ? mypage.title : "default title"|t %}


{{ title }}


---

