Views: 4730
Last Modified: 10.10.2012
  • In a site template directory is created the /lang/ folder:

    /bitrix/templates/<>/lang/
  • In the /lang/ folder are placed folders with the utilized languages identifiers: /en/, /de/, /ru/, and etc. For example:

    /bitrix/templates/<>/lang/ru/
  • In the folders with languages identifiers are stored corresponding message files. These files are characterized by the following properties:
    • the message file name is equal to the file name where this message file is called. For example, if a message file is call is implemented in the template header (file header.php) then this message file must have name header.php.
    • message list in the file is stored the following way:

      <?
      $MESS ['COMPANY_NAME'] = "Company Name";
      $MESS ['MAIN_PAGE'] = "Home page";
      $MESS ['PRINT'] = "Print version";
      $MESS ['AUTH_LOGIN'] = "Authorization";
      $MESS ['RATES_HEADER'] = "Currency rates";
      $MESS ['SEARCH'] = "Site search";
      $MESS ['SUBSCR'] = "Subscription";
      ?>
  • At the beginning of file, where the message file call is implemented, the following function is added:

    <?
    IncludeTemplateLangFile(__FILE__);
    ?>
    The IncludeTemplateLangFile(__FILE__) connects a message file for the current language.
  • All text in template is replaced with the function calling the corresponding messages:

    <font class="search"><?echo GetMessage("SEARCH");?></font>
    The code (ID) of calling message is used as the GetMessage() parameter. The function verifies if the connected message file contains necessary message. If the necessary message exists then it is shown to page visitors.


Courses developed by Bitrix24