Development

Changeset 4576

You must first sign up to be able to contribute.

Changeset 4576

Show
Ignore:
Timestamp:
07/11/07 14:46:02 (1 year ago)
Author:
fabien
Message:

refactored i18n

  • added a new sfMessageSource_Aggregate: it aggregates several message sources as one
  • refactored sfI18N class to use the new sfMessageSource_Aggregate class
  • added unit tests for some i18n classes (more to come)
  • moved getCatalogueList() method to sfMessageSource_Database class for SQLite, Creole and MySQL message source
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/addon/creole/i18n/sfMessageSource_Creole.class.php

    r4343 r4576  
    101101   * @return array translation messages. 
    102102   */ 
    103   protected function &loadData($variant) 
     103  public function &loadData($variant) 
    104104  { 
    105105    $sql = 'SELECT t.source, t.target, t.comments '. 
     
    152152   * @return boolean true if the catalogue+variant is in the database, false otherwise. 
    153153   */ 
    154   protected function isValidSource($variant) 
     154  public function isValidSource($variant) 
    155155  { 
    156156    $sql = 'SELECT COUNT(*) FROM catalogue WHERE name = ?'; 
     
    163163 
    164164    return $result; 
    165   } 
    166  
    167   /** 
    168    * Get all the variants of a particular catalogue. 
    169    * 
    170    * @param string catalogue name 
    171    * @return array list of all variants for this catalogue. 
    172    */ 
    173   protected function getCatalogueList($catalogue) 
    174   { 
    175     $variants = explode('_', $this->culture); 
    176  
    177     $catalogues = array($catalogue); 
    178  
    179     $variant = null; 
    180  
    181     for ($i = 0, $max = count($variants); $i < $max; $i++) 
    182     { 
    183       if (strlen($variants[$i]) > 0) 
    184       { 
    185         $variant .= ($variant) ? '_'.$variants[$i] : $variants[$i]; 
    186         $catalogues[] = $catalogue.'.'.$variant; 
    187       } 
    188     } 
    189  
    190     return array_reverse($catalogues); 
    191165  } 
    192166 
  • trunk/lib/i18n/extract/sfI18nExtract.class.php

    r4370 r4576  
    7575  public function saveNewMessages() 
    7676  { 
    77     $messageSource = $this->i18n->getLastMessageSource(); 
     77    $messageSource = $this->i18n->getMessageSource(); 
    7878    foreach ($this->getNewMessages() as $message) 
    7979    { 
     
    9292  public function deleteOldMessages() 
    9393  { 
    94     $messageSource = $this->i18n->getLastMessageSource(); 
     94    $messageSource = $this->i18n->getMessageSource(); 
    9595    foreach ($this->getOldMessages() as $message) 
    9696    { 
     
    147147  protected function loadMessageSources() 
    148148  { 
    149     foreach ($this->i18n->getMessageSources() as $messageSource) 
    150     { 
    151       $messageSource->setCulture($this->culture); 
    152       $messageSource->load(); 
    153     } 
     149    $this->i18n->getMessageSource()->setCulture($this->culture); 
     150    $this->i18n->getMessageSource()->load(); 
    154151  } 
    155152 
     
    160157  { 
    161158    $this->currentMessages = array(); 
    162     foreach ($this->i18n->getMessageSources() as $messageSource
     159    foreach ($this->i18n->getMessageSource()->read() as $catalogue => $translations
    163160    { 
    164       foreach ($messageSource->read() as $catalogue => $translations) 
     161      foreach ($translations as $key => $values) 
    165162      { 
    166         foreach ($translations as $key => $values) 
    167         { 
    168           $this->currentMessages[] = $key; 
    169         } 
     163        $this->currentMessages[] = $key; 
    170164      } 
    171165    } 
  • trunk/lib/i18n/sfI18N.class.php

    r4350 r4576  
    2020{ 
    2121  protected 
    22     $context        = null, 
    23     $culture        = null, 
    24     $messageSources = array()
    25     $messageFormats = array()
     22    $context       = null, 
     23    $culture       = null, 
     24    $messageSource = null
     25    $messageFormat = null
    2626 
    2727  /** 
     
    3333  { 
    3434    $this->context = $context; 
    35  
    36     $this->setMessageSource(sfLoader::getI18NGlobalDirs(), $context->getUser()->getCulture()); 
    3735  } 
    3836 
     
    4038   * Sets the message sources. 
    4139   * 
    42    * @param mixed  An array of i18n directories if message source configuration is XLIFF or gettext, null otherwise 
     40   * @param mixed  An array of i18n directories if message source is XLIFF or gettext, null otherwise 
    4341   * @param string The culture 
    4442   */ 
    4543  public function setMessageSource($dirs, $culture) 
    4644  { 
    47     $this->messageSources = array(); 
    48     $this->messageFormats = array(); 
    49  
    5045    if (is_null($dirs)) 
    5146    { 
    52       $this->messageSources = $this->createMessageSource(); 
     47      $this->messageSource = $this->createMessageSource(); 
    5348    } 
    5449    else 
    5550    { 
    56       foreach ($dirs as $dir) 
    57       { 
    58         $this->messageSources[] = $this->createMessageSource($dir); 
    59       } 
     51      $this->messageSource = sfMessageSource::factory('Aggregate', array_map(array($this, 'createMessageSource'), $dirs)); 
    6052    } 
    6153 
    6254    $this->setCulture($culture); 
     55    $this->messageFormat = null; 
    6356  } 
    6457 
     
    6760   * 
    6861   * @param  mixed           An array of i18n directories to create a XLIFF or gettext message source, null otherwise 
     62   * 
    6963   * @return sfMessageSource A sfMessageSource object 
    7064   */ 
     
    9892 
    9993  /** 
    100    * Returns a new message format for the given message source. 
    101    * 
    102    * @param  sfIMessageSource A sfMessageSource object 
    103    * @return sfMessageFormat  A sfMessageFormat object 
    104    */ 
    105   public function createMessageFormat(sfIMessageSource $source) 
    106   { 
    107     $messageFormat = new sfMessageFormat($source, sfConfig::get('sf_charset')); 
    108  
    109     if (sfConfig::get('sf_debug') && sfConfig::get('sf_i18n_debug')) 
    110     { 
    111       $messageFormat->setUntranslatedPS(array(sfConfig::get('sf_i18n_untranslated_prefix'), sfConfig::get('sf_i18n_untranslated_suffix'))); 
    112     } 
    113  
    114     return $messageFormat; 
    115   } 
    116  
    117   /** 
    11894   * Sets the current culture for i18n format objects. 
    11995   * 
     
    12298  public function setCulture($culture) 
    12399  { 
    124     if ($culture != $this->culture) 
     100    if ($this->messageSource) 
    125101    { 
    126102      $this->culture = $culture; 
    127  
    128       $this->messageFormats = array(); 
    129     } 
    130  
    131     foreach ($this->messageSources as $messageSource) 
    132     { 
    133       $messageSource->setCulture($culture); 
    134     } 
    135   } 
    136  
    137   /** 
    138    * Gets all current message sources. 
    139    * 
    140    * @return array An array of sfMessageSource objects 
    141    */ 
    142   public function getMessageSources() 
    143   { 
    144     return $this->messageSources; 
    145   } 
    146  
    147   /** 
    148    * Gets the message source for the given index. 
    149    * 
    150    * @param  integer         The indice (1 based) 
     103      $this->messageSource->setCulture($culture); 
     104    } 
     105  } 
     106 
     107  /** 
     108   * Gets the message source. 
     109   * 
    151110   * @return sfMessageSource A sfMessageSource object 
    152111   */ 
    153   public function getMessageSource($i = 1) 
    154   { 
    155     if (!isset($this->messageSources[$i - 1])) 
    156     { 
    157       throw new sfException(sprintf('The "$i" message source does not exist.', $i)); 
    158     } 
    159  
    160     return $this->messageSources[$i - 1]; 
    161   } 
    162  
    163   /** 
    164    * Gets the last message source. 
    165    */ 
    166   public function getLastMessageSource() 
    167   { 
    168     return $this->getMessageSource(count($this->messageSources)); 
    169   } 
    170  
    171   /** 
    172    * Gets all current message formats. 
    173    * 
    174    * @return array An array of sfMessageFormat objects 
    175    */ 
    176   public function getMessageFormats() 
    177   { 
    178     for ($i = 0, $count = count($this->messageSources); $i < $count; $i++) 
    179     { 
    180       $this->getMessageFormat($i); 
    181     } 
    182  
    183     return $this->messageFormats; 
    184   } 
    185  
    186   /** 
    187    * Gets the message format for the given index. 
    188    * 
    189    * @param  integer         The indice (1 based) 
     112  public function getMessageSource() 
     113  { 
     114    if (!isset($this->messageSource)) 
     115    { 
     116      $this->setMessageSource(sfLoader::getI18NGlobalDirs(), $this->context->getUser()->getCulture()); 
     117    } 
     118 
     119    return $this->messageSource; 
     120  } 
     121 
     122  /** 
     123   * Gets the message format. 
     124   * 
    190125   * @return sfMessageFormat A sfMessageFormat object 
    191126   */ 
    192   public function getMessageFormat($i = 1) 
    193   { 
    194     if (!isset($this->messageFormats[$i - 1])) 
    195     { 
    196       $this->messageFormats[$i - 1] = $this->createMessageFormat($this->getMessageSource($i)); 
    197     } 
    198  
    199     return $this->messageFormats[$i - 1]; 
    200   } 
    201  
    202   /** 
    203    * Gets the last message format. 
    204    */ 
    205   public function getLastMessageFormat() 
    206   { 
    207     return $this->getMessageFormat(count($this->messageSources)); 
     127  public function getMessageFormat() 
     128  { 
     129    if (!isset($this->messageFormat)) 
     130    { 
     131      $this->messageFormat = new sfMessageFormat($this->getMessageSource(), sfConfig::get('sf_charset')); 
     132 
     133      if (sfConfig::get('sf_debug') && sfConfig::get('sf_i18n_debug')) 
     134      { 
     135        $this->messageFormat->setUntranslatedPS(array(sfConfig::get('sf_i18n_untranslated_prefix'), sfConfig::get('sf_i18n_untranslated_suffix'))); 
     136      } 
     137    } 
     138 
     139    return $this->messageFormat; 
    208140  } 
    209141 
     
    214146   * @param  array  An array of arguments for the translation 
    215147   * @param  string The catalogue name 
     148   * 
    216149   * @return string The translated string 
    217150   */ 
    218151  public function __($string, $args = array(), $catalogue = 'messages') 
    219152  { 
    220     for ($i = 0, $count = count($this->messageSources); $i < $count; $i++) 
    221     { 
    222       if ($retval = $this->getMessageFormat($i + 1)->formatExists($string, $args, $catalogue)) 
    223       { 
    224         return $retval; 
    225       } 
    226     } 
    227  
    228     return $this->getLastMessageFormat()->format($string, $args, $catalogue); 
     153    return $this->getMessageFormat()->format($string, $args, $catalogue); 
    229154  } 
    230155 
     
    234159   * @param  string The ISO code 
    235160   * @param  string The culture 
     161   * 
    236162   * @return string The country name 
    237163   */ 
     
    248174   * 
    249175   * @param  string The culture 
     176   * 
    250177   * @return string The culture name 
    251178   */ 
     
    262189   * @param  string  The formatted date as string 
    263190   * @param  string  The culture 
     191   * 
    264192   * @return integer The timestamp 
    265193   */ 
     
    276204   * @param  string  The formatted date as string 
    277205   * @param  string  The culture 
     206   * 
    278207   * @return array   An array with the day, month and year 
    279208   */ 
  • trunk/lib/i18n/sfMessageFormat.class.php

    r4343 r4576  
    7979   * @var string  
    8080   */ 
    81   public $Catalogue; 
     81  public $catalogue; 
    8282 
    8383  /** 
     
    168168  } 
    169169 
    170   public function formatExists($string, $args = array(), $catalogue = null, $charset = null) 
    171   { 
    172     if (empty($charset)) 
    173     { 
    174       $charset = $this->getCharset(); 
    175     } 
    176  
    177     $s = $this->getFormattedString(sfToolkit::I18N_toUTF8($string, $charset), $args, $catalogue); 
    178  
    179     return sfToolkit::I18N_toEncoding($s, $charset); 
    180   } 
    181  
    182170  /** 
    183171   * Do string translation. 
     
    190178  protected function formatString($string, $args = array(), $catalogue = null) 
    191179  { 
     180    if (empty($catalogue)) 
     181    { 
     182      $catalogue = empty($this->catalogue) ? 'messages' : $this->catalogue; 
     183    } 
     184 
     185    $this->loadCatalogue($catalogue); 
     186 
    192187    if (empty($args)) 
    193188    { 
    194189      $args = array(); 
    195190    } 
    196  
    197     $target = $this->getFormattedString($string, $args, $catalogue); 
    198  
    199     // well we did not find the translation string. 
    200     if (!$target) 
    201     { 
    202       $this->source->append($string); 
    203       $target = $this->postscript[0].$this->replaceArgs($string, $args).$this->postscript[1]; 
    204     } 
    205  
    206     return $target; 
    207   } 
    208  
    209   protected function getFormattedString($string, $args = array(), $catalogue = null) 
    210   { 
    211     if (empty($catalogue)) 
    212     { 
    213       $catalogue = empty($this->catalogue) ? 'messages' : $this->catalogue; 
    214     } 
    215  
    216     if (empty($args)) 
    217     { 
    218       $args = array(); 
    219     } 
    220  
    221     $this->loadCatalogue($catalogue); 
    222191 
    223192    foreach ($this->messages[$catalogue] as $variant) 
     
    245214    } 
    246215 
    247     return null; 
     216    // well we did not find the translation string. 
     217    $this->source->append($string); 
     218 
     219    return $this->postscript[0].$this->replaceArgs($string, $args).$this->postscript[1]; 
    248220  } 
    249221 
  • trunk/lib/i18n/sfMessageSource.class.php

    r4341 r4576  
    101101   * Factory method to instantiate a new sfMessageSource depending on the 
    102102   * source type. The built-in source types are 'XLIFF', 'SQLite', 
    103    * 'MySQL', 'gettext' and Creole. The source parameter is dependent on the 
    104    * source type. For 'gettext' and 'XLIFF', it should point to the directory 
     103   * 'MySQL', 'gettext', 'Creole' and 'Aggregate'. 
     104   * The source parameter is dependent on the source type. 
     105   * For 'gettext' and 'XLIFF', it should point to the directory 
    105106   * where the messages are stored. For database types, e.g. 'SQLite' and 
    106107   * 'MySQL', it should be a PEAR DB style DSN string. 
     
    285286   * @return array of translation messages. 
    286287   */ 
    287   protected function &loadData($variant) 
     288  public function &loadData($variant) 
    288289  { 
    289290    return array(); 
     
    296297   * @return string the resource key 
    297298   */ 
    298   protected function getSource($variant) 
     299  public function getSource($variant) 
    299300  { 
    300301    return $variant; 
     
    307308   * @return boolean true if valid, false otherwise. 
    308309   */ 
    309   protected function isValidSource($source) 
     310  public function isValidSource($source) 
    310311  { 
    311312    return false; 
     
    319320   * @return array list of all variants for this catalogue. 
    320321   */ 
    321   protected function getCatalogueList($catalogue) 
     322  public function getCatalogueList($catalogue) 
    322323  { 
    323324    return array(); 
  • trunk/lib/i18n/sfMessageSource_Database.class.php

    r4343 r4576  
    185185    return $parsed; 
    186186  } 
     187 
     188  /** 
     189   * Gets all the variants of a particular catalogue. 
     190   * 
     191   * @param string catalogue name 
     192   * @return array list of all variants for this catalogue. 
     193   */ 
     194  public function getCatalogueList($catalogue) 
     195  { 
     196    $variants = explode('_', $this->culture); 
     197 
     198    $catalogues = array($catalogue); 
     199 
     200    $variant = null; 
     201 
     202    for ($i = 0, $max = count($variants); $i < $max; $i++) 
     203    { 
     204      if (strlen($variants[$i]) > 0) 
     205      { 
     206        $variant .= $variant ? '_'.$variants[$i] : $variants[$i]; 
     207        $catalogues[] = $catalogue.'.'.$variant; 
     208      } 
     209    } 
     210 
     211    return array_reverse($catalogues); 
     212  } 
    187213} 
  • trunk/lib/i18n/sfMessageSource_File.class.php

    r4342 r4576  
    5454   * @return int last modified in unix-time format. 
    5555   */ 
    56   protected function getLastModified($source) 
     56  public function getLastModified($source) 
    5757  { 
    5858    return is_file($source) ? filemtime($source) : 0; 
     
    6565   * @return string full path to the message file. 
    6666   */ 
    67   protected function getSource($variant) 
     67  public function getSource($variant) 
    6868  { 
    6969    return $this->source.'/'.$variant; 
     
    7676   * @return boolean true if valid, false otherwise. 
    7777   */ 
    78   protected function isValidSource($source) 
     78  public function isValidSource($source) 
    7979  { 
    8080    return is_file($source); 
     
    8787   * @return array list of all variants for this catalogue.  
    8888   */ 
    89   protected function getCatalogueList($catalogue) 
     89  public function getCatalogueList($catalogue) 
    9090  { 
    9191    $variants = explode('_', $this->culture); 
  • trunk/lib/i18n/sfMessageSource_MySQL.class.php

    r4343 r4576  
    211211   * @return array translation messages. 
    212212   */ 
    213   protected function &loadData($variant) 
     213  public function &loadData($variant) 
    214214  { 
    215215    $variant = mysql_real_escape_string($variant, $this->db); 
     
    261261   * @return boolean true if the catalogue+variant is in the database, false otherwise. 
    262262   */  
    263   protected function isValidSource($variant) 
     263  public function isValidSource($variant) 
    264264  { 
    265265    $variant = mysql_real_escape_string ($variant, $this->db); 
     
    272272 
    273273    return $result; 
    274   } 
    275  
    276   /** 
    277    * Gets all the variants of a particular catalogue. 
    278    * 
    279    * @param string catalogue name 
    280    * @return array list of all variants for this catalogue.  
    281    */ 
    282   protected function getCatalogueList($catalogue) 
    283   { 
    284     $variants = explode('_', $this->culture); 
    285  
    286     $catalogues = array($catalogue); 
    287  
    288     $variant = null; 
    289  
    290     for ($i = 0, $max = count($variants); $i < $max; $i++) 
    291     { 
    292       if (strlen($variants[$i]) > 0) 
    293       { 
    294         $variant .= $variant ? '_'.$variants[$i] : $variants[$i]; 
    295         $catalogues[] = $catalogue.'.'.$variant; 
    296       } 
    297     } 
    298  
    299     return array_reverse($catalogues); 
    300274  } 
    301275 
  • trunk/lib/i18n/sfMessageSource_SQLite.class.php

    r4343 r4576  
    3131 *   cat_id INTEGER PRIMARY KEY, 
    3232 *   name VARCHAR NOT NULL, 
    33  *   source_lang VARCHAR
    34  *   target_lang VARCHAR
     33 *   source_lang VARCHAR
     34 *   target_lang VARCHAR
    3535 *   date_created INT, 
    3636 *   date_modified INT, 
     
    111111   * @return array translation messages. 
    112112   */ 
    113   protected function &loadData($variant) 
     113  public function &loadData($variant) 
    114114  { 
    115115    $variant = sqlite_escape_string($variant); 
    116116 
    117     $statement =  
     117    $statement = 
    118118      "SELECT t.id, t.source, t.target, t.comments 
    119119        FROM trans_unit t, catalogue c 
    120120        WHERE c.cat_id =  t.cat_id 
    121           AND c.name = '{$variant}'  
     121          AND c.name = '{$variant}' 
    122122        ORDER BY id ASC"; 
    123123 
     
    168168   * @return boolean true if the catalogue+variant is in the database, false otherwise. 
    169169   */ 
    170   protected function isValidSource($variant) 
     170  public function isValidSource($variant) 
    171171  { 
    172172    $variant = sqlite_escape_string($variant); 
     
    180180 
    181181  /** 
    182    * Gets all the variants of a particular catalogue. 
    183    * 
    184    * @param string catalogue name 
    185    * @return array list of all variants for this catalogue. 
    186    */ 
    187   protected function getCatalogueList($catalogue) 
    188   { 
    189     $variants = explode('_', $this->culture); 
    190  
    191     $catalogues = array($catalogue); 
    192  
    193     $variant = null; 
    194  
    195     for ($i = 0, $max = count($variants); $i < $max; $i++) 
    196     { 
    197       if (strlen($variants[$i]) > 0) 
    198       { 
    199         $variant .= ($variant) ? '_'.$variants[$i] : $variants[$i]; 
    200         $catalogues[] = $catalogue.'.'.$variant; 
    201       } 
    202     } 
    203  
    204     return array_reverse($catalogues); 
    205   } 
    206  
    207   /** 
    208182   * Retrieves catalogue details, array($cat_id, $variant, $count). 
    209183   * 
     
    233207    $cat_id = intval(sqlite_fetch_single($rs)); 
    234208 
    235     //first get the catalogue ID 
     209    // first get the catalogue ID 
    236210    $rs = sqlite_query("SELECT count(msg_id) FROM trans_unit WHERE cat_id = {$cat_id}", $db); 
    237211 
     
    270244   * @return boolean true if saved successfuly, false otherwise. 
    271245   */ 
    272   function save($catalogue='messages') 
     246  function save($catalogue = 'messages') 
    273247  { 
    274248    $messages = $this->untranslated; 
     
    302276    { 
    303277      $message = sqlite_escape_string($message); 
    304       $statement = "INSERT INTO trans_unit (cat_id,id,source,date_added) VALUES ({$cat_id}, {$count},'{$message}',$time)"; 
    305       if (sqlite_query($statement, $db)) 
     278      if (sqlite_query("INSERT INTO trans_unit (cat_id, id, source, date_added) VALUES ({$cat_id}, {$count}, '{$message}', $time)", $db)) 
    306279      { 
    307280        $count++; 
     
    348321    $db = sqlite_open($this->source); 
    349322 
    350     $statement = "UPDATE trans_unit SET target = '{$target}', comments = '{$comments}', date_modified = '{$time}' WHERE cat_id = {$cat_id} AND source = '{$text}'"; 
    351  
    352     $updated = false; 
    353  
    354     if (sqlite_query($statement, $db)) 
    355     { 
    356       $updated = $this->updateCatalogueTime($cat_id, $variant, $db); 
     323    sqlite_query("UPDATE trans_unit SET target = '{$target}', comments = '{$comments}', date_modified = '{$time}' WHERE cat_id = {$cat_id} AND source = '{$text}'", $db); 
     324 
     325    if (sqlite_changes($db)) 
     326    { 
     327      $this->updateCatalogueTime($cat_id, $variant, $db); 
     328      $updated = true; 
     329    } 
     330    else 
     331    { 
     332      $updated = false; 
    357333    } 
    358334 
     
    384360    $text = sqlite_escape_string($message); 
    385361 
    386     $statement = "DELETE FROM trans_unit WHERE cat_id = {$cat_id} AND source = '{$message}'"; 
    387     $deleted = false; 
    388  
    389     if (sqlite_query($statement, $db)) 
    390     { 
    391       $deleted = $this->updateCatalogueTime($cat_id, $variant, $db); 
     362    sqlite_query("DELETE FROM trans_unit WHERE cat_id = {$cat_id} AND source = '{$message}'", $db); 
     363 
     364    if (sqlite_changes($db)) 
     365    { 
     366      $this->updateCatalogueTime($cat_id, $variant, $db); 
     367      $deleted = true; 
     368    } 
     369    else 
     370    { 
     371      $deleted = false; 
    392372    } 
    393373 
     
    410390    while ($row = sqlite_fetch_array($rs, SQLITE_NUM)) 
    411391    { 
    412       $details = explode('.',$row[0]); 
     392      $details = explode('.', $row[0]); 
    413393      if (!isset($details[1])) 
    414394      { 
  • trunk/lib/i18n/sfMessageSource_XLIFF.class.php

    r4342 r4576  
    4848   * @return array of messages. 
    4949   */ 
    50   protected function &loadData($filename) 
    51   { 
    52     //load it. 
    53  
     50  public function &loadData($filename) 
     51  { 
    5452    $XML = simplexml_load_file($filename); 
    5553 
     
    6765      $source = (string) $unit->source; 
    6866      $translations[$source][] = (string) $unit->target; 
    69       $translations[$source][]= (string) $unit['id']; 
    70       $translations[$source][]= (string) $unit->note; 
     67      $translations[$source][] = (string) $unit['id']; 
     68      $translations[$source][] = (string) $unit->note; 
    7169    } 
    7270 
  • trunk/lib/i18n/sfMessageSource_gettext.class.php

    r4342 r4576  
    5151   * @return array of messages. 
    5252   */ 
    53   protected function &loadData($filename) 
     53  public function &loadData($filename) 
    5454  { 
    5555    $mo = TGettext::factory('MO',$filename);