Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
PhpMessageSource.php
1 <?php
2 /**
3 /**
4  * Gentics Portal.Node PHP
5  * Author & Copyright (c) by Gentics Software GmbH
6  * sales@gentics.com
7  * http://www.gentics.com
8  * Licenses can be found in the LICENSE.txt file in the root-folder of this installation
9  * You must not use this software without a valid license agreement.
10  *
11  */
12 class PhpMessageSource extends CPhpMessageSource
13 {
14  /**
15  * @var bool Flag. If true try to use dictionary files from custom section
16  */
17  public $customI18n;
18 
19  /**
20  * Determines the message file name based on the given category and language.
21  * If the category name contains a dot, it will be split into the module class name and the category name.
22  * In this case, the message file will be assumed to be located within the 'messages' subdirectory of
23  * the directory containing the module class file.
24  * Otherwise, the message file is assumed to be under the {@link basePath}.
25  *
26  * @param string $category category name
27  * @param string $language language ID
28  *
29  * @return string the message file path
30  */
31  protected function getMessageFile($category, $language)
32  {
33  $file = realpath(parent::getMessageFile($category, $language));
34  if ($this->customI18n) {
35  $customSection = realpath(Yii::getPathOfAlias('site.custom'));
36  $commonSection = realpath(Yii::getPathOfAlias('site.common'));
37  $frontendSection = realpath(Yii::getPathOfAlias('site.frontend'));
38  $customFile = str_replace(array($commonSection, $frontendSection), $customSection, $file);
39  if (file_exists($customFile)) {
40  return $customFile;
41  }
42  }
43 
44  return $file;
45  }
46 
47 }