How to make 'labels' translatable

I want to create language keys for labels, so that they can be displayed into different languages. I've added 2 columns to sys_labels table to include 'title' and 'system_title' .. and have created the language keys and added it to en.xml file. what else should I do?

  • 546
  • More
Replies (3)
    • Now you need to call in all "labels" places the _t() function like

      _t('_label_langauge_key');

      It will show the translated message.

      But this is not a good way that you make changes in system files and tables. You'll meet the troubles with an automatic upgrade as the first aftermath.

      • LeonidS can you write an example of a current php code including 'labels' and how to change it. just use an example from any php file and I will follow your example in the rest.
        I'm using a git repository to track all the changes, and I do check the code before merging changes to avoid any conflicts when upgrading. It will be nice if you can include translatable labels in next UNA version :)

        • The labels list is taken by this method of BxDolLabel class

          public function getLabels($aParams = array())

              {

                  return $this->_oDb->getLabels($aParams);

              }

          So it's better for you to walk this array with the setting every field like 

          $aArray[$i]['value'] = _t($aArray[$i]['title'] );

          We will think about translatable labels too :-)

          Login or Join to comment.