Beispiel #1
0
 /**
  * Translate input message into default language defined in language settings for account.
  * This function should be used in case message should be translated to default language (e.g. log messages written to event log)
  *
  * @param string $message
  * @return string
  */
 public static function _sys($message, $args = null)
 {
     if (!is_array($args)) {
         $args = func_get_args();
     }
     $dictionary = Gpf_Lang_Dictionary::getInstance(Gpf_Lang_Dictionary::getDefaultSystemLanguage());
     return self::_replaceArgs($dictionary->get($message), $args);
 }
 /**
  * @throws Gpf_Exception
  */
 private function loadSettingsFromLanguage()
 {
     $lang = Gpf_Lang_Dictionary::getInstance()->getLanguage();
     if ($lang == null) {
         throw new Gpf_Exception('No language loaded');
     }
     $this->thousandsSeparator = $lang->getThousandsSeparator();
     $this->decimalSeparator = $lang->getDecimalSeparator();
     $this->dateFormat = $lang->getDateFormat();
     $this->timeFormat = $lang->getTimeFormat();
 }
 /**
  * Compute default language in following order:
  * 1. try if language parameter is not set in request
  * 2. try if cookie doesn't contain language selection from the past
  * 3. try load language settings from browser preferences
  * 4. load default system language
  *
  * @return string Default language code
  */
 public static function getDefaultLanguage()
 {
     //try if language was not defined by language parameter in request
     if (isset($_REQUEST[self::LANGUAGE_REQUEST_PARAMETER]) && self::isLanguageSupported($_REQUEST[self::LANGUAGE_REQUEST_PARAMETER])) {
         return $_REQUEST[self::LANGUAGE_REQUEST_PARAMETER];
     }
     //try if language was not defined in cookie parameter
     if (isset($_COOKIE[Gpf_Auth_Service::COOKIE_LANGUAGE]) && self::isLanguageSupported($_COOKIE[Gpf_Auth_Service::COOKIE_LANGUAGE])) {
         return $_COOKIE[Gpf_Auth_Service::COOKIE_LANGUAGE];
     }
     //try load language from browser
     if (($acceptLang = Gpf_Lang_Dictionary::getBrowserLanguage()) !== false) {
         return $acceptLang;
     }
     //use default system language
     return self::getDefaultSystemLanguage();
 }
Beispiel #4
0
 protected function loadAuthData(Gpf_Data_Record $data)
 {
     $this->username = $data->get("username");
     $this->accountUserId = $data->get("accountuserid");
     $this->authtoken = $data->get("authtoken");
     $this->accountid = $data->get("accountid");
     $this->roletypeid = $data->get("roletypeid");
     $this->roleid = $data->get('roleid');
     $this->authId = $data->get('authid');
     $this->firstname = $data->get('firstname');
     $this->lastname = $data->get('lastname');
     $this->ip = $data->get('ip');
     $attributes = Gpf_Db_Table_UserAttributes::getInstance();
     $attributes->loadAttributes($this->accountUserId);
     $this->setLanguage($attributes->getAttributeWithDefaultValue(self::LANGUAGE_ATTRIBUTE_NAME, Gpf_Lang_Dictionary::getDefaultLanguage()));
 }
Beispiel #5
0
 /**
  * @param Gpf_Data_IndexedRecordSet $languageRecordSet
  * @return Gpf_Data_IndexedRecordSet
  */
 private function setDefaultLanguage(Gpf_Data_IndexedRecordSet $languageRecordSet)
 {
     $defaultLanguageCode = Gpf_Lang_Dictionary::getInstance()->getLanguage()->getCode();
     foreach ($languageRecordSet as $languageRecord) {
         if ($languageRecord->get(Gpf_Db_Table_Languages::CODE) == $defaultLanguageCode) {
             $languageRecord->set(Gpf_Db_Table_Languages::IS_DEFAULT, Gpf::YES);
         } else {
             $languageRecord->set(Gpf_Db_Table_Languages::IS_DEFAULT, Gpf::NO);
         }
     }
     return $languageRecordSet;
 }
 private static function setDefaultLanguageToAffiliate($accountUserId) {
     $attribute = new Gpf_Db_UserAttribute();
     $attribute->setName(Gpf_Auth_User::LANGUAGE_ATTRIBUTE_NAME);
     $attribute->setAccountUserId($accountUserId);
     try {
         $attribute->loadFromData(array(Gpf_Db_Table_UserAttributes::NAME, Gpf_Db_Table_UserAttributes::ACCOUNT_USER_ID));
         return;
     } catch (Gpf_DbEngine_NoRowException $e) {
         $attribute->set(Gpf_Db_Table_UserAttributes::VALUE, Gpf_Lang_Dictionary::getDefaultLanguage());
         $attribute->save();
     }
 }
Beispiel #7
0
 public function localize($message)
 {
     return Gpf_Lang_Dictionary::getInstance(Gpf_Session::getInstance()->getAuthUser()->getLanguage())->get($message);
 }
 protected function renderDictionaryRequest()
 {
     $dictionary = Gpf_Lang_Dictionary::getInstance();
     Gpf_Rpc_CachedResponse::addEncodedById($dictionary->getEncodedClientMessages(), 'langDictionary');
 }