# Translations - getting the language used

**URL:** <https://community.silverfin.com/t/translations-getting-the-language-used/1089>\
**Category:** Templates\
**Tags:** translations, locale\
**Created:** [August 7, 2018, 8:30am UTC](https://community.silverfin.com/t/translations-getting-the-language-used/1089 "2018-08-07T08:30:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bart\_Verhaeghe](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Bart\_Verhaeghe](https://community.silverfin.com/u/Bart_Verhaeghe)\
**Post date:** [August 7, 2018, 8:30am UTC](https://community.silverfin.com/t/translations-getting-the-language-used/1089/1 "2018-08-07T08:30:46Z")

</div>

Hi, is the language used at a given moment in a template, stored in a variable? If yes, what’s the name of this variable?

The reason here is that I’d like to use this variable to build an if/case structure to put whole paragraphs in a capture tag (as translating each piece of text in French and English is rather impractical but also a lot of work).

Thanks!

---

<div class="post-metadata">

**Author:** ![SamVanEenoo](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/samvaneenoo/32/134_2.png) [@SamVanEenoo](https://community.silverfin.com/u/SamVanEenoo)\
**Post date:** [August 7, 2018, 9:29am UTC](https://community.silverfin.com/t/translations-getting-the-language-used/1089/2 "2018-08-07T09:29:45Z")

</div>

Hi @Bart

Yes there is.  
You can use

> {{ locale }}

for this.

Kind regards  
Sam

---

<div class="post-metadata">

**Author:** ![Bart\_Verhaeghe](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Bart\_Verhaeghe](https://community.silverfin.com/u/Bart_Verhaeghe)\
**Post date:** [August 7, 2018, 11:11am UTC](https://community.silverfin.com/t/translations-getting-the-language-used/1089/3 "2018-08-07T11:11:32Z")

</div>

Ok thank you Sam, this is a huge help … Would you mind looking at my other question as well (with regard to the translations?

Thanks!

---

<div class="post-metadata">

**Author:** ![Bart\_Verhaeghe](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Bart\_Verhaeghe](https://community.silverfin.com/u/Bart_Verhaeghe)\
**Post date:** [August 9, 2018, 2:45pm UTC](https://community.silverfin.com/t/translations-getting-the-language-used/1089/4 "2018-08-09T14:45:51Z")

</div>

Hi Sam, how can you use this variable ‘locale’ in conditions. For example, I put the language on ‘English’ and put in the following logic:

```
{% assign str_LanguageUsed = locale %}

{% if str_LanguageUsed == 'en' %}hello{% else %}hallo{% endif %}

```

But the result is ‘hallo’, not ‘hello’ … what gives? Thanks!

---

<div class="post-metadata">

**Author:** ![SamVanEenoo](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/samvaneenoo/32/134_2.png) [@SamVanEenoo](https://community.silverfin.com/u/SamVanEenoo)\
**Post date:** [August 9, 2018, 5:38pm UTC](https://community.silverfin.com/t/translations-getting-the-language-used/1089/5 "2018-08-09T17:38:50Z")

</div>

The problem and weird thing is, that locale is also a function.  
You can fix your problem by changing

> `{% assign str_LanguageUsed = locale %}`

to

> `{% capture str_LanguageUsed %}{{locale}}{% endcapture %}`

However, I think there’s even a better way to do is and that is by doing the following:

> ```
> {% t="hello" en:"hello" nl:"hallo" fr:"bonjour" %}
> {% assign language %}{{locale}}{% endlocale %}
> {% locale language %}{% t"hello" %}{% endlocale %}
> 
> ```

Kind regards  
Sam

---

<div class="post-metadata">

**Author:** ![Bart\_Verhaeghe](https://avatars.discourse-cdn.com/v4/letter/b/c4cdca/32.png) [@Bart\_Verhaeghe](https://community.silverfin.com/u/Bart_Verhaeghe)\
**Post date:** [August 10, 2018, 6:23am UTC](https://community.silverfin.com/t/translations-getting-the-language-used/1089/6 "2018-08-10T06:23:12Z")

</div>

OK great! Thanks Sam
