40
44
class Sylar_Format{
42
function __construct(){
43
// nothing to do at the moment
48
function __construct(Sylar_LocaleConfiguration $localeConf=null){
50
if(is_null($localeConf)){
53
* an objet to use as default sylar Locale Config
58
$localeConf = new Sylar_LocaleConfiguration(Sylar_ConfigBox::getDefaultLocaleKey());
61
// try to switch to application locale, if isn't set use sylar locale
62
if(is_null(APP_DEFAULT_LOCALE)){
63
$localeConf->switchToStandardSetting(Sylar_ConfigBox::getDefaultLocaleKey());
65
$localeConf->switchToStandardSetting(APP_DEFAULT_LOCALE);
68
$this->setLocaleConfig($localeConf);
70
// it prepare the language object
71
$this->initializeLanguage();
45
74
function __destruct(){
46
75
// nothing to do at the moment
82
//__________________________________________________________________________
85
public function setLocaleConfig(Sylar_LocaleConfiguration $localeConf){
86
$this->localeConf = $localeConf;
88
public function getLocaleConfig(){
89
return $this->localeConf;
94
* @param Sylar_Language $oLang
96
public function setLangObj(Sylar_Language $oLang){
100
* @return Sylar_Language
102
public function getLangObj(){
112
//__________________________________________________________________________
121
//__________________________________________________________________________
125
* Return the code of locale in witch will be translated the page
129
protected function getLocale(){
130
return $this->getLocaleConfig()->getStandardSettingKey();
135
* Wrapper for provideText
137
* @see Sylar_Language
140
* @param string $sKey
141
* @param array $aReplace
143
protected function translate($sLabel, $aReplaceList=null){
144
return $this->getLangObj()->provideText($sLabel, $aReplaceList);
149
* Wrapper for loadApplicationDictionary
151
* @see Sylar_Language
154
* @param string $sDictName
155
* @param boolean $bFlagAppend
157
protected function loadDictionary($sDictName, $bFlagAppend=true){
158
$this->getLangObj()->loadApplicationDictionary($sDictName, $sDictName);
167
//__________________________________________________________________________
173
* It prepare the object language for the default use in the application
176
* @see Sylar_Language
178
private function initializeLanguage(){
179
// Prepare Language engine
180
$this->setLangObj( new Sylar_Language($this->getLocaleConfig()) );
181
// Set Locale Application repository root
182
if(is_null(APP_LOCALE_ROOT_FS)){
183
throw new ExceptionInSylar('Application dictionary folder not defined.', 10025);
185
$this->getLangObj()->setApplicationLocaleRootFs(APP_LOCALE_ROOT_FS);