<p>Untested, but should be fairly straightforward.</p>

<pre><code>{% if craft.locale == 'de' %}
    {% set template = '_layout_de.html' %}
{% else %}
    {% set template = '_layout.html' %}
{% endif %}
{% extends template %}
</code></pre>

<p>or</p>

<pre><code>{% extends craft.locale == 'de' ? '_layout_de.html' : '_layout.html' %}
</code></pre>

<p>or using a locale folder (thank josh baker)</p>

<pre><code>{% extends craft.locale ~ '/_layout' %}
</code></pre>

CC BY-SA 3.0
2015-07-22T17:40:11.410Z
You might also use string concatenation, which makes adding new layouts easier in future. For example `{% extends craft.locale ~ '/_layout' %}` would point to `/templates/en/_layout`.
Joshua Baker
CC BY-SA 3.0
2015-07-23T16:03:14.387Z
Great addition @JoshBaker
Douglas McDonald
CC BY-SA 3.0
2015-07-27T11:14:59.130Z
When I try that I get a "Multiple extends tags are forbidden" message returned. Something to do with the processing order perhaps where it's evaluating `extends` before the conditional construct?
Ian Young
CC BY-SA 3.0
2015-07-27T15:33:08.663Z
Most likely just doesn't like the multiple extends statements. I modified the example using a single extends and variables. Also, did you try one of the other methods?
Douglas McDonald
CC BY-SA 3.0
2015-07-28T15:37:08.863Z
The error message gave it away. :) In my case your other suggestion wouldn't fit my particular use case as it could be one of several and not just one or the other. I didn't notice Josh's suggestion though but it was the kind of pseudo logic I had in my head without quite knowing how to apply it. I've given it a try though and successfully got it to work along (with a slight tweak for my particular template folder structure: `{% extends "layouts/" ~ craft.locale ~ '/layout-name' %}`. Many thanks for the help and suggestions.
Ian Young
CC BY-SA 3.0
2015-07-22T16:59:34.403Z
2015-07-27T15:31:24.427Z
2015-07-27T15:31:24.427Z
Douglas McDonald
<p>In my particular case I need to be able to switch the layout that the template extends. Is this possible to do using locales?</p>

<localization>
Can locales be used to switch layouts?
# Can locales be used to switch layouts?

(Asked by: username_0 on 2015-07-22)

In my particular case I need to be able to switch the layout that the template extends. Is this possible to do using locales?

**Tags:** localization

---

## 1 answers

### Answer by username_1 on 2015-07-22. Score: 7 | Accepted answer

Untested, but should be fairly straightforward.
{% if craft.locale == 'de' %}
    {% set template = '_layout_de.html' %}
{% else %}
    {% set template = '_layout.html' %}
{% endif %}
{% extends template %}

or
{% extends craft.locale == 'de' ? '_layout_de.html' : '_layout.html' %}

or using a locale folder (thank josh baker)
{% extends craft.locale ~ '/_layout' %}

> **Comments:**
> **username_2**: You might also use string concatenation, which makes adding new layouts easier in future. For example `{% extends craft.locale ~ '/_layout' %}` would point to `/templates/en/_layout`.  
> **username_1**: Great addition @JoshBaker  
> **username_0**: When I try that I get a "Multiple extends tags are forbidden" message returned. Something to do with the processing order perhaps where it's evaluating `extends` before the conditional construct?  
> **username_1**: Most likely just doesn't like the multiple extends statements. I modified the example using a single extends and variables. Also, did you try one of the other methods?  
> **username_0**: The error message gave it away. :) In my case your other suggestion wouldn't fit my particular use case as it could be one of several and not just one or the other. I didn't notice Josh's suggestion though but it was the kind of pseudo logic I had in my head without quite knowing how to apply it. I've given it a try though and successfully got it to work along (with a slight tweak for my particular template folder structure: `{% extends "layouts/" ~ craft.locale ~ '/layout-name' %}`. Many thanks for the help and suggestions.  

---

