Ejemplo n.º 1
0
 /**
  * Get message from CONSTANT, translate and format it
  * @param string $msgId ID if constant
  * @param array $params parameter for format (use vsprintf)
  * @return string
  */
 public static function getMessage($msgId, $params = array())
 {
     $message = constant($msgId);
     if (isset($message)) {
         $message = I18n::t($message, $msgId, 'system');
         $result = vsprintf($message, $params);
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Constructor of TypeManager, set locale with $localCode parameter
  *
  * @param string $localeCode
  * @return void
  **/
 public function __construct($localeCode = "")
 {
     //try to set correct locale for current language as defined in app.inc section I18n
     $currentLanguage = I18n::getCurrentLangCode();
     $localeCode = $GLOBALS["local"][$currentLanguage];
     setlocale(LC_ALL, $localeCode);
     $this->_localeInfo = localeconv();
     if ($this->_localeInfo['frac_digits'] > 10) {
         $this->_localeInfo = null;
     }
 }
Ejemplo n.º 3
0
 protected function translate()
 {
     $module = $this->getModuleName($this->objectName);
     $trans_string = I18n::t($this->title, $this->getTransKey('Title'), $module, $this->getTransPrefix());
     if ($trans_string) {
         $this->title = $trans_string;
     }
     $trans_string = I18n::t($this->objectDescription, $this->getTransKey('Description'), $module, $this->getTransPrefix());
     if ($trans_string) {
         $this->objectDescription = $trans_string;
     }
 }
Ejemplo n.º 4
0
 /**
  * Get \Zend Template
  * @return \Zend_View zend view template object
  */
 public static function getZendTemplate()
 {
     $view = new \Zend_View();
     if (defined('SMARTY_TPL_PATH')) {
         $view->setScriptPath(SMARTY_TPL_PATH);
     }
     $theme = Resource::getCurrentTheme();
     // load the config file which has the images and css url defined
     $view->app_url = OPENBIZ_APP_URL;
     $view->app_index = OPENBIZ_APP_INDEX_URL;
     $view->js_url = OPENBIZ_JS_URL;
     $view->css_url = OPENBIZ_THEME_URL . "/" . $theme . "/css";
     $view->resource_url = OPENBIZ_RESOURCE_URL;
     $view->theme_js_url = OPENBIZ_THEME_URL . "/" . $theme . "/js";
     $view->theme_url = OPENBIZ_THEME_URL . "/" . $theme;
     $view->image_url = OPENBIZ_THEME_URL . "/" . $theme . "/images";
     $view->lang = strtolower(I18n::getCurrentLangCode());
     return $view;
 }
Ejemplo n.º 5
0
 protected function translateList(&$list, $tag)
 {
     $module = $this->getModuleName($this->selectFrom);
     if (empty($module)) {
         $module = $this->getModuleName($this->formName);
     }
     for ($i = 0; $i < count($list); $i++) {
         $key = 'SELECTION_' . strtoupper($tag) . '_' . $i . '_TEXT';
         $list[$i]['txt'] = I18n::t($list[$i]['txt'], $key, $module, $this->getTransLOVPrefix());
     }
 }
Ejemplo n.º 6
0
 protected function translate()
 {
     $module = substr($this->viewName, 0, intval(strpos($this->viewName, '.')));
     //echo $this->getTransKey('Description');
     $this->objectDescription = I18n::t($this->objectDescription, $this->getTransKey('Description'), $module);
 }
Ejemplo n.º 7
0
 /**
  * Get appended styles
  *
  * @return string
  */
 public function getAppendedStyles($comb = 0)
 {
     $extraStyles = implode("", $this->_extraStyles);
     $extraStyle_array = explode("type=\"text/css\">", $extraStyles);
     if (defined("OPENBIZ_RESOURCE_PHP") && $comb) {
         $css_scripts = OPENBIZ_RESOURCE_PHP . "?f=";
         $matches = array();
         foreach ($extraStyle_array as $style) {
             // extract href part from each line
             if (preg_match('/.+href="([^"]+)".+/', $style, $matches) > 0 && !empty($matches[1])) {
                 if (substr($css_scripts, -2) == 'f=') {
                     $css_scripts .= $matches[1];
                 } else {
                     $css_scripts .= ',' . $matches[1];
                 }
             }
         }
         return "<link rel=\"stylesheet\" href=\"" . $css_scripts . "\" type=\"text/css\"/>";
     }
     $cleanStyle_array = array();
     foreach ($extraStyle_array as $style) {
         if (in_array($style . "type=\"text/css\">", $cleanStyle_array) == FALSE and strlen($style) != 0) {
             $cleanStyle_array[] = $style . "type=\"text/css\">";
         }
     }
     $lang = I18n::getCurrentLangCode();
     $localization_css_file = OPENBIZ_APP_PATH . DIRECTORY_SEPARATOR . "languages" . DIRECTORY_SEPARATOR . $lang . DIRECTORY_SEPARATOR . "localization.css";
     if (is_file($localization_css_file)) {
         $cleanStyle_array[] = "<link rel=\"stylesheet\" href=\"" . OPENBIZ_APP_URL . "/languages/{$lang}/localization.css\" type=\"text/css\">";
     }
     return implode("\n", $cleanStyle_array);
 }
Ejemplo n.º 8
0
 protected function translate()
 {
     $module = substr($this->_formName, 0, intval(strpos($this->_formName, '.')));
     if (!empty($this->contextMenu)) {
         $this->contextMenu = I18n::t($this->contextMenu, $this->getTransKey('ContextMenu'), $module);
     }
 }
Ejemplo n.º 9
0
 public static function getCurrentLangCode()
 {
     if (I18n::$_langCode != null) {
         return I18n::$_langCode;
     }
     $currentLanguage = Openbizx::$app->getSessionContext()->getVar("LANG");
     // default language
     if ($currentLanguage == "") {
         $currentLanguage = Openbizx::$app->getUserPreference("language");
     }
     if ($currentLanguage == "") {
         $currentLanguage = I18n::DEFAULT_LANGUAGE;
     }
     // language from url
     if (isset($_GET['lang'])) {
         $currentLanguage = $_GET['lang'];
         Openbizx::$app->getSessionContext()->setVar("LANG", $currentLanguage);
     }
     // TODO: user pereference has language setting
     Openbizx::$app->getSessionContext()->setVar("LANG", $currentLanguage);
     I18n::$_langCode = $currentLanguage;
     return $currentLanguage;
 }