# Unable to make conditional checks on content.language

**URL:** <https://community.hubspot.com/t/unable-to-make-conditional-checks-on-content-language/12242>\
**Category:** CMS Development\
**Created:** [January 9, 2019, 9:18am UTC](https://community.hubspot.com/t/unable-to-make-conditional-checks-on-content-language/12242 "2019-01-09T09:18:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SimonH\_Demodia](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/simonh_demodia/32/221659_2.png) [@SimonH\_Demodia](https://community.hubspot.com/u/SimonH_Demodia)\
**Post date:** [January 9, 2019, 9:18am UTC](https://community.hubspot.com/t/unable-to-make-conditional-checks-on-content-language/12242/1 "2019-01-09T09:18:53Z")

</div>

Hi all,

I’m trying to create some dynamic elements on our CMS pages that vary based on the laungage of the page. It seems like I should be able to us _content.language_ to get the language code for the page, but for some reason I can’t seem to get any queries against it to work.

For example, directly printing {{ content.language }} or returns “en”

but if I do:

```auto
{% if content.language == "en" %}
 <p>Your language is English.</p>
{% else %}
 <p>Your language is something else.</p>
{% endif %}

```

I always get back “Your language is something else”. For some reason the IF statement just isn’t matching the language.

Any suggestions what I’m doing wrong?

---

<div class="post-metadata">

**Author:** ![lscanlan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lscanlan/32/66262_2.png) [@lscanlan](https://community.hubspot.com/u/lscanlan)\
**Post date:** [January 11, 2019, 9:07pm UTC](https://community.hubspot.com/t/unable-to-make-conditional-checks-on-content-language/12242/2 "2019-01-11T21:07:20Z")

</div>

Hi SimonH\_Demodia,

Thanks for posting this. I’m having an engineer look at this. I think what’s happening is that the {{ content.language }} variable isn’t getting its type set to str, which is what should be happening. You can print the variable because it exists. And if you run a conditional statement like this:

```auto
{% if content.language == content.language %}
 <p>content.language == content.language</p>
{% endif %}

```

You should see that it evaluates to true and your \<p\> tag gets printed. So it is possible to use it in conditional tests. But if you run a type() test on it with something like:

`<p>type(content.language): {{ type(content.language) }}</p>`

…the type comes back as unknown. Which would explain why it’s not ever equal to “en”, which is a str type. I’ll let you know when I have a better answer for you, but I think this is what’s happening.

---

<div class="post-metadata">

**Author:** ![SimonH\_Demodia](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/simonh_demodia/32/221659_2.png) [@SimonH\_Demodia](https://community.hubspot.com/u/SimonH_Demodia)\
**Post date:** [January 12, 2019, 6:18am UTC](https://community.hubspot.com/t/unable-to-make-conditional-checks-on-content-language/12242/3 "2019-01-12T06:18:17Z")

</div>

Thanks, that looks like exactly what’s happening.

Try this and take a look at the result… {{ content.language|pprint }}

---

<div class="post-metadata">

**Author:** ![lscanlan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lscanlan/32/66262_2.png) [@lscanlan](https://community.hubspot.com/u/lscanlan)\
**Post date:** [February 5, 2019, 2:23am UTC](https://community.hubspot.com/t/unable-to-make-conditional-checks-on-content-language/12242/4 "2019-02-05T02:23:19Z")

</div>

Hi SimonH\_Demodia,

Just wanted to update you on this one. We’ve updated our documentation to reflect the fact that content.language is a dict. You can access the string language value from content.language.languageTag . And you can test for the language variation of your page by doing something like:

```auto
{% if content.language.languageTag == "en" %}
 {# this is the English translate of the page #}
{% endif %}

```

I hope this helps. Let me know if you have any questions about it.

- Leland
