CAppUI::stepAjax("Locales-javascript-cache-none", UI_MSG_OK, $localeName);
        continue;
    }
    $fp = fopen($path, 'r');
    preg_match('#^//(\\d+)#', fgets($fp), $v);
    if ($v[1] < $version['build']) {
        CAppUI::stepAjax("Locales-javascript-cache-ko", UI_MSG_WARNING, $localeName);
        fclose($fp);
        continue;
    }
    if (null == SHM::get("locales-{$localeName}-" . CAppUI::LOCALES_PREFIX)) {
        CAppUI::stepAjax("Locales-shm-none", UI_MSG_OK, $localeName);
        continue;
    }
    // Load overwritten locales if the table exists
    $overwrite = new CTranslationOverwrite();
    if ($overwrite->isInstalled()) {
        $locales = $overwrite->transformLocales($locales);
    }
    $cached_locales = CAppUI::flattenCachedLocales($localeName);
    if ($cached_locales != $locales) {
        CAppUI::stepAjax("Locales-shm-ko", UI_MSG_WARNING, $localeName);
        continue;
    }
    CAppUI::stepAjax("Locales-shm-ok", UI_MSG_OK, $localeName);
}
// Not used yet (because of PHP 5.1)
//if (null == SHM::get("modules")) {
//  CAppUI::stepAjax("Modules-shm-none", UI_MSG_OK);
//}
////////// Configuration model
Example #2
0
 *
 * @package    Mediboard
 * @subpackage System
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkEdit();
$locales = CAppUI::flattenCachedLocales(CAppUI::$lang);
$in_use_locales = $locales;
//load old locales
$locale = CAppUI::pref("LOCALE", "fr");
foreach (CAppUI::getLocaleFilesPaths($locale) as $_path) {
    include_once $_path;
}
$locales = CMbString::filterEmpty($locales);
foreach ($locales as &$_locale) {
    $_locale = CMbString::unslash($_locale);
}
//get the list of translations made
$translation = new CTranslationOverwrite();
$translations_bdd = $translation->loadList();
/** @var CTranslationOverwrite[] $translations_bdd */
foreach ($translations_bdd as $_translation) {
    $_translation->loadOldTranslation($locales);
    $_translation->checkInCache();
}
//smarty
$smarty = new CSmartyDP();
$smarty->assign("translations_bdd", $translations_bdd);
$smarty->display("view_translations.tpl");
Example #3
0
 /**
  * Load locales from cache or build the cache
  *
  * @return void
  */
 public static function loadLocales()
 {
     $lang = CAppUI::pref("LOCALE", "fr");
     self::$lang = $lang;
     $shared_name = "locales-{$lang}";
     $locales_prefixes = SHM::get("{$shared_name}-" . self::LOCALES_PREFIX);
     // Load from shared memory if possible
     if ($locales_prefixes) {
         return;
     }
     $mutex = new CMbFileMutex("locales-build");
     $mutex->acquire(5);
     $locales_prefixes = SHM::get("{$shared_name}-" . self::LOCALES_PREFIX);
     // Load from shared memory if possible
     if ($locales_prefixes) {
         $mutex->release();
         return;
     }
     $locales = array();
     foreach (self::getLocaleFilesPaths($lang) as $_path) {
         include_once $_path;
     }
     $locales = CMbString::filterEmpty($locales);
     foreach ($locales as &$_locale) {
         $_locale = CMbString::unslash($_locale);
     }
     unset($_locale);
     // Load overwritten locales if the table exists
     $overwrite = new CTranslationOverwrite();
     if ($overwrite->isInstalled()) {
         $locales = $overwrite->transformLocales($locales, $lang);
     }
     // Prefix = everything before "." and "-"
     $by_prefix = array();
     $hashes = array();
     foreach ($locales as $_key => $_value) {
         /** @var string $_prefix */
         /** @var string $_rest */
         /** @var string $_prefix_raw */
         list($_prefix, $_rest, $_prefix_raw) = self::splitLocale($_key);
         if (!isset($by_prefix[$_prefix])) {
             $hashes[$_prefix] = $_prefix_raw;
             $by_prefix[$_prefix] = array();
         }
         $by_prefix[$_prefix][$_rest] = $_value;
     }
     foreach ($by_prefix as $_prefix => $_locales) {
         self::$locales[$_prefix] = $_locales;
         self::$locales_loaded[$_prefix] = true;
         SHM::put("{$shared_name}-{$_prefix}", $_locales);
     }
     SHM::put("{$shared_name}-" . self::LOCALES_PREFIX, $hashes);
     $mutex->release();
 }
<?php

/**
 * Edit Translation
 *
 * $Id$
 *
 * @package    Mediboard
 * @subpackage System
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkEdit();
$translation_id = CValue::getOrSession("trad_id");
$language = CValue::getOrSession("language", CAppUI::pref("LOCALE", "fr"));
$languages = CAppUI::getAvailableLanguages();
$translation = new CTranslationOverwrite();
$translation->load($translation_id);
if ($translation->_id) {
    $translation->loadOldTranslation();
}
//smarty
$smarty = new CSmartyDP();
$smarty->assign("translation", $translation);
$smarty->assign("language", $language);
$smarty->assign("languages", $languages);
$smarty->display("inc_edit_translation.tpl");