Multi-language Template Variables

From TNG_Wiki
Jump to navigation Jump to search

If your site supports multiple languages, then when you create template variables there are other considerations that must be taken into account.

In order for template variables to support more than your default language, the variables must be added to the $needtrans array in the admin_templateconfig.php module.

See the multilingual sites considerations below

Multilingual sites

TNG version: 9.0

In order to add a multi-language variable to a TNG V9 Template, you need to do the following:

  1. modify the $needtrans array in admin_templateconfig.php to add the tag name without the template identifier to the $needtrans array
  2. create a $admtext variable in your language cust_text.php for the same label tag added to the $needtrans array
  3. add the new template variable to the templateconfig.php file
  4. modify the index.php and topmenu.php files to use the new template variable

For example, if you wanted to change the Search and Title image files in Template 4 to use a different graphic image for each language you would need to

  1. add titleimg and searchimg to the $needtrans array as shown below to line 165 of admin_templateconfig.php
    $needtrans   =   array('headline','maintitle','welcome','hisside','herside','headtitle1','headtitle2','headtitle3','momside','dadside','mainpara','featurepara',
    'searchpara','fhpara','mwpara','respara','headtitle','headsubtitle','latestnews','featuretitle1','featuretitle2','featuretitle3','featuretitle4',
    'featurepara1','featurepara2','featurepara3','featurepara4','photocaption','newstext','titleimg','searchimg');
  2. add $admtext['searchimg'] to your cust_text.php for each language you use. The $admtext['titleimg'] is already provided by TNG
  3. add $tmp['t4_searchimg'] to your templateconfig.php file
    $tmp['t4_searchimg'] = "img/search4.gif";
  4. when you update your Template Settings for Template 4 and choose the Create copy in: pull down for the language selection, TNG will add
    $tmp['t4_searchimg_English-UTF8'] = "img/search4-en.gif";
    $tmp['t4_searchimg_French-UTF8'] = "img/search4-fr.gif";
  5. you then need to modify the Template 4 index.php file to use the new language switching capability for the graphic title and search image
    • line 14 of the index.php which displays the search4.gif file must be changed to use the new t4_searchimg variable as follows
      <a  href="searchform.php"><img src="<?php echo  $cms['tngpath'] .  $templatepath; ?><?php echo  getTemplateMessage('t4_searchimg');  ?>" alt="<?php echo  $text['mnusearchfornames']; ?>"  class="searchimg"  /></a>
    • line 91 of the index.php which displays the search4.gif file must be changed to use the new t4_searchimg variable as follows
      <img src="<?php echo  $cms['tngpath'] .  $templatepath; ?><?php echo  $tmp['t4_titleimg']; ?>" alt=""  class="banner" width="468"  height="100" />
  6. you then need to modify the Template 4 topmenu.php file to use the new language switching capability for the graphic title and search image
    • line 11 of the topmenu.php which displays the search4.gif file must be changed to use the new t4_searchimg variable as follows
      <a  href="searchform.php"><img src="<?php echo   $cms['tngpath'] .  $templatepath; ?><?php echo   getTemplateMessage('t4_searchimg');  ?>" alt="<?php echo   $text['mnusearchfornames']; ?>"  class="searchimg"   /></a>
    • line 80 of the topmenu.php which displays the search4.gif file must be changed to use the new t4_searchimg variable as follows
      <img src="<?php echo  $cms['tngpath'] .   $templatepath; ?><?php echo  $tmp['t4_titleimg']; ?>" alt=""   class="banner" width="468"  height="100" />

Note that if you want to use URL links in a Template Settings variable, then it must be defined in the $textarea

Related Links

Understanding Template Settings - TNG V9

Multi-language Template Variables