Views: 9928
Last Modified: 09.10.2019
  • The /lang/ folder is created in the a site template directory:

    /bitrix/templates/<>/lang/
  • The /lang/ folder has the folders with the utilized languages identifiers: /en/, /de/, /fr/, and etc. For example:

    /bitrix/templates/<>/lang/fr/
  • The languages identifiers corresponding to message files are stored within the folders. 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 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