Sourcefabric Manuals

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

Newscoop 4.3 Cookbook

Language

The language object is set at the beginning of the main template, based on the request URL. This object can be changed using the set_language function. The language object has the following properties:

  • name: language name
  • number: language identifier in the Newscoop database (integer value)
  • english_name: language name in English
  • code: language international code
  • defined: boolean value (true/false) - true if the language was set in the current environment; false otherwise

If you want to verify whether the current environment language is the same as the initial language, compare it to the default_language object. For example:

{{ if $gimme->language == $gimme->default_language }}
...
{{ /if }}

If you want to display parts of your templates in a different language according to the language selected by the user, you can use something similar to the following code. This snippet was used for a bilingual publication.

{{ if $gimme->language->code == "en" }}
 archive
  {{ else }}
   [trans]archive
{{ /if }}

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

You should refresh this page.