<p>Yes. You can see all of the arguments the <code>|t</code> filter supports by looking at the docs for <a href="https://craftcms.com/classreference//Craft#t-detail">Craft::t()</a>, the function that <code>|t</code> maps to. Its <code>$language</code> argument defines the target language translation to use. So in your case you could do this:</p>

<pre><code>{{ "Leer esta página en Español"|t(language="es") }}
</code></pre>

CC BY-SA 3.0
2017-10-16T05:51:27.460Z
Is there a way to use this as a fallback in case the current locale string is empty? 

I have a lot of incomplete translation locales and would like to fallback to the english version (100% translated) whenever a locale string is empty.

Currently it's displaying the "key" value, which in my case is `snake_cased`
simonswiss
CC BY-SA 3.0
2017-10-17T10:53:20.587Z
@simonswiss You could write a macro that sets the result of the `|t` filter to a variable, and then compares the variable with the original string. If equal, run it through `|t` once more, this time translating to English. Or you could just use the English strings as the keys, like Craft and Yii do, rather than some `snake_cased` version.
Brandon Kelly
CC BY-SA 3.0
2016-03-07T13:17:24.203Z
2016-03-07T13:17:24.203Z
Brandon Kelly
<p>So I've built a language switcher as per <a href="https://craftcms.stackexchange.com/questions/44/how-can-i-build-a-language-switcher">this answer</a>.</p>

<p>I want the text for each link to be in the native language, for example I want the link to the English locale to say "Read this page in English" and the link to Spanish locale to say "Leer esta página en Español" etc.</p>

<p>However using the |t filter uses the locale that you're currently on, so if I'm on Spanish it says "Leer esta página en English".</p>

<p>Is there a way to pass in a parameter or something to say, for example, |t(Spanish).</p>

<p>Thanks!</p>

<localization><language>
Can I choose a language for the translate filter?
# Can I choose a language for the translate filter?

(Asked by: username_0 on 2016-03-07)

So I've built a language switcher as per [this answer](https://craftcms.stackexchange.com/questions/44/how-can-i-build-a-language-switcher).

I want the text for each link to be in the native language, for example I want the link to the English locale to say "Read this page in English" and the link to Spanish locale to say "Leer esta página en Español" etc.

However using the |t filter uses the locale that you're currently on, so if I'm on Spanish it says "Leer esta página en English".

Is there a way to pass in a parameter or something to say, for example, |t(Spanish).

Thanks!

**Tags:** localization, language

---

## 1 answers

### Answer by username_1 on 2016-03-07. Score: 10 | Accepted answer

Yes. You can see all of the arguments the |t filter supports by looking at the docs for Craft::t(), the function that |t maps to. Its $language argument defines the target language translation to use. So in your case you could do this:
{{ "Leer esta página en Español"|t(language="es") }}

> **Comments:**
> **username_2**: Is there a way to use this as a fallback in case the current locale string is empty?   I have a lot of incomplete translation locales and would like to fallback to the english version (100% translated) whenever a locale string is empty.  Currently it's displaying the "key" value, which in my case is `snake_cased`  
> **username_1**: @simonswiss You could write a macro that sets the result of the `|t` filter to a variable, and then compares the variable with the original string. If equal, run it through `|t` once more, this time translating to English. Or you could just use the English strings as the keys, like Craft and Yii do, rather than some `snake_cased` version.  

---

