Language specific templates

We recently had a customer ask us how to make language specific template layouts, specifically he wanted in some languages to output strings in one order ( {A}{B}{C} ) and in other languages in a different order ( {C}{B}{C} ).

To help our user achieve this, we added a new common variable to the Jomres customised version of patTemplate.php which adds "common_lang" to all templates.

Ordinarily, this could be used in templates to output the current language to the page's output by adding {COMMON_LANG}, however that's not the intention here. Instead we can use this variable to make decisions on what template code to display.

Let's look at the list_properties.html template as an example.

Normally the summary of each property is wrapped inside a patTemplate declaration like <patTemplate:tmpl name="property_details" unusedvars="strip">. This is the default, however if we instead change that line to <patTemplate:tmpl name="property_details" type="condition" conditionvar="common_lang"> we can then have sub- conditions inside that block for different languages, like so :

<patTemplate:tmpl name="property_details" type="condition" conditionvar="common_lang">
<patTemplate:sub condition="en-GB">
<div class="jomres_property_list_propertywrapper" id="{UID}">
<div class="panel {BUDGET_BORDER_CLASS} {FEATURED_LISTINGS_CLASS}">

<snip>

<div class="modal fade" id="module_{RANDOM_IDENTIFIER}_popup">
</div><!-- /.modal -->
</patTemplate:sub>

<patTemplate:sub condition="jp-JP">
<div class="jomres_property_list_propertywrapper" id="{UID}">
<div class="panel {BUDGET_BORDER_CLASS} {FEATURED_LISTINGS_CLASS}">

<snip>

<div class="modal fade" id="module_{RANDOM_IDENTIFIER}_popup">
</div><!-- /.modal -->
</patTemplate:sub>

</patTemplate:tmpl>

The disadvantage of this, and the reason why we wouldn't add it to the default Jomres templates is that you would need one block for each language you use on the site. So, if you support just two languages, like English and Japanese then it wouldn't have too much overhead maintenance-wise, but if you produce content in 5 european languages where you don't need different layouts then it would be much harder to maintain, for next to no gain.

Anyway, we hope that this helps those users who want language specific layouts.

Jomres Manual