Sourcefabric Manuals

 English |  Español |  Français |  Italiano |  Português |  Русский |  Shqip

Template library

Different templates for different languages

Sometimes you might want to adjust the structure of your template accoring to the language the user has selected. A simple example: serving different advertisment for different languages. Even if you are using a third party banner management software, you might find that it does not cater for all languages you deliver to, e.g. Google Adsense does not deliver to Georgian languages. With Newscoop, you can make a switch depending on the language and call a template that delivers something else.

Another example might be that you are using an embed of facebook for the English pages, but vkontakte.ru for the Russian pages.

This is the most straight forward way of handling this:

{{ if $gimme->language->english_name == "English" }}whatever English thing you want{{ /if }}
{{ if $gimme->language->english_name == "Spanish" }}the Spanish thing you want{{ /if }}
[...]

This example will simply print the string, of course. Replace it with whatever you want, like {{ include ... }} and so forth.

You can also make the decision based on the language code in the system. This does not make any difference. The following example would work for a bilingual site and checks for Arabic first, else will load the other language:

{{ if $gimme->language->code == 'ar' }}
[...]
{{ else }}
[...]
{{ /if }}

There has been error in communication with Booktype server. Not sure right now where is the problem.

You should refresh this page.