예제 #1
0
파일: Php.php 프로젝트: elkuku/g11n
 /**
  * Retrieve the storage content.
  *
  * @param   string  $lang       E.g. de-DE, es-ES etc.
  * @param   string  $extension  E.g. joomla, com_weblinks, com_easycreator etc.
  * @param   string  $domain     Must be 'admin' or 'site'.
  *
  * @throws G11nException
  * @return \ElKuKu\G11n\Support\Store
  */
 public function retrieve($lang, $extension, $domain = '')
 {
     $path = $this->getPath($lang, $extension, $domain) . $this->ext;
     $langPath = '---';
     // File has not being cached
     if (!file_exists($path)) {
         // Try to store
         $langPath = $this->store($lang, $extension, $domain);
         // Failed ?
         if (!file_exists($path)) {
             throw new G11nException('Unable to retrieve the strings');
         }
     }
     /*
      * Include the "cache" file containing the language strings.
      * This file should contain the arrays:
      * # $info[]
      * # $strings[]
      * # $stringsPlural[]
      * # $jsStrings[]
      * # $stringsJsPlural[]
      */
     include $path;
     $store = new Store();
     $store->set('langPath', $langPath);
     $store->set('cachePath', $path);
     if (isset($info['pluralForms'])) {
         $store->set('pluralForms', $info['pluralForms']);
     }
     if (!empty($strings)) {
         $store->set('strings', $strings);
     }
     if (!empty($stringsPlural)) {
         $store->set('stringsPlural', $stringsPlural);
     }
     if (!empty($stringsJs)) {
         $store->set('stringsJs', $stringsJs);
     }
     if (!empty($stringsJsPlural)) {
         $store->set('stringsJsPlural', $stringsJsPlural);
     }
     return $store;
 }
예제 #2
0
파일: StoreTest.php 프로젝트: elkuku/g11n
 /**
  * Test method.
  *
  * @expectedException  \UnexpectedValueException
  *
  * @return void
  */
 public function testFailure2()
 {
     $this->object->set('{undefined}', '');
 }