Get language from template -(UDT, small hack)

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
vilkis

Get language from template -(UDT, small hack)

Post by vilkis »

Hi,
I use standard CMSMS for my multilingual sites. Here is my way to set a language for modules in template:

a) Make a hack in file lib/classes/module_support/modlang.inc.php  at line 53 (or near) (CMSMS 1.5.2)

replace line

Code: Select all

if ($modinstance->curlang == '' && isset($gCms->current_language))
with this

Code: Select all

if (isset($gCms->current_language))
b) create UDT named kalba:

Code: Select all

global $gCms;
global $smarty;

if( isset($params['kalba']) && $params['kalba'] != '' )
{
$gCms->current_language=$params['kalba'];
$smarty->assign('lang',$params['kalba']);
}

and place a code in page templates for e.g. lithuanian pages -  {kalba kalba='lt_LT'} , for russian pages - {kalba kalba='ru_RU'} and so on.

c) In templates of modules e.g  SelfRegistration, you can use the following syntax:

Code: Select all

{if $lang eq lt_LT}
Text in lithuanian
{elseif $lang eq ru_RU}
Text in russian
{else}
Text in english
{/if}

More info on this topic is coming

Vilkis
Post Reply

Return to “Tips and Tricks”