public function package()
 {
     //Getting the language list
     global $_CALEM_conf;
     $list = $_CALEM_conf['client_lang_list'];
     foreach ($list as $langfile => $mapping) {
         if ($this->logger->isDebugEnabled()) {
             $this->logger->debug("Generating JS file: " . $langfile);
         }
         $data = "//Messages for Calem" . CALEM_LFCR;
         //added an array for php
         $ar = array();
         foreach ($mapping as $class => $files) {
             $data .= "//Message definition for " . $class . CALEM_LFCR;
             $data .= 'function ' . $class . '() {}' . CALEM_LFCR . CALEM_LFCR;
             foreach ($files as $file) {
                 $fullname = _CALEM_DIR_ . 'client/lang/' . $file . '.properties';
                 $data .= MessageToJs::fileToJs($class, $fullname);
                 $ar = MessageToPhp::fileToPhp($fullname, $ar);
             }
         }
         //Store off php info
         $this->savePhp($langfile, $ar);
         //Now store off the data in a plain and gz file
         $this->nextProcess($langfile, $data);
     }
 }
Exemple #2
0
$lang = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : $_CALEM_conf['client_language'];
$sufix = '';
if ($lang) {
    $sufix = "_" . $lang;
}
$msgdir = _CALEM_DIR_ . 'client/lang/';
if (!isset($_CALEM_conf['client_lang_list']['CalemMsg' . $sufix . '.js'])) {
    $logger->error("Invalid language: " . $lang . ", to use default language.");
    $sufix = '';
}
$mapping = $_CALEM_conf['client_lang_list']['CalemMsg' . $sufix . ".js"];
if ($logger->isDebugEnabled()) {
    $logger->debug("fetch messages: lang={$lang}; fileset=" . var_export($mapping, true));
}
$data = "//Messages for Calem unpacked. " . CALEM_LFCR;
foreach ($mapping as $class => $files) {
    $data .= "//Message definition for " . $class . CALEM_LFCR;
    $data .= 'function ' . $class . '() {}' . CALEM_LFCR . CALEM_LFCR;
    foreach ($files as $file) {
        $fullname = _CALEM_DIR_ . 'client/lang/' . $file . '.properties';
        $data .= MessageToJs::fileToJs($class, $fullname);
    }
}
//Done parsing messages, now decide the output mode
//Disable browser side cache
if (!headers_sent()) {
    header('Cache-Control: no-cache');
}
CalemGzip::gzStart();
print $data;
CalemGzip::gzEndFlush(false);