First,
hello to Yii comunity!
Many thanks to the developers. Yii framework is fantastic. That said,
I’d kindly ask for some help:
I have managed to setup language switching and I use "en", "sr_yu", "sr"
in yii framework/messages folder there are sr_yu and sr_sr folders.
it’s confusing. I keep source language set to “00” and have model Attributes translated to english, serbian latin and serbian cyrillic.
sr_yu should be latin (and that works perfectly)
but sr_sr doesn’t work when referenced as “sr_sr” … it works with just “sr”
BUT … funny thing is that YII transations don’t work this way. for example, “Home” on breadcrumbs (english)
translates to "Početna" as sr_yu (Serbian Latin) but when I switch to serbian cyrillic (sr) - my webapp transaltions work fine (translate to cyrillic) but "home" breadcrumb stays untranslated. So I changed "sr" to "sr_sr"
but then Yii refuses to ackgnowledge such locale exists with error:
here is the error:
Локализација није препозната (unrecognized locale) "sr_sr".
D:\wamp\www\yii\framework\i18n\CLocale.php(105)
093 * to obtain an instance of the specified locale.
094 * @param string $id the locale ID (e.g. en_US)
095 * @throws CException if given locale id is not recognized
096 */
097 protected function __construct($id)
098 {
099 $this->_id=self::getCanonicalID($id);
100 $dataPath=self::$dataPath===null ? dirname(__FILE__).DIRECTORY_SEPARATOR.'data' : self::$dataPath;
101 $dataFile=$dataPath.DIRECTORY_SEPARATOR.$this->_id.'.php';
102 if(is_file($dataFile))
103 $this->_data=require($dataFile);
104 else
105 throw new CException(Yii::t('yii','Unrecognized locale "{locale}".',array('{locale}'=>$id)));
106 }
107
108 /**
109 * Converts a locale ID to its canonical form.
110 * In canonical form, a locale ID consists of only underscores and lower-case letters.
111 * @param string $id the locale ID to be converted
112 * @return string the locale ID in canonical form
113 */
114 public static function getCanonicalID($id)
115 {
116 return strtolower(str_replace('-','_',$id));
117 }
Stack Trace
#0
+
D:\wamp\www\yii\framework\i18n\CLocale.php(64): CLocale->__construct("sr_sr")
#1
+
D:\wamp\www\yii\framework\base\CApplication.php(391): CLocale::getInstance("sr_sr")
#2
–
D:\wamp\www\yii\framework\YiiBase.php(591): CApplication->getLocale(null)
The error is minor and easily solvable I’m sure but I don’t want to touch yii framwork sources in order to fix it. I’m a beginner and I know that is bad practice.
Please advise or explain how is Serbian language exactly differenciated (sr_yu - latin sr_sr - cyrillic … what is "sr" ?)
my configuration:
‘languages’=>array(‘en’=>‘English’, ‘sr_yu’=>‘Srpski latinica’, ‘sr’ => ‘Српски ћирилица’),
‘sourceLanguage’=>‘00’,
‘language’=>‘en’,
I also stumbled upon config.php in yii/framework/messages folder.
‘languages’=>array(‘fi’,‘zh_cn’,‘zh_tw’,‘ca’,‘de’,‘el’,‘es’,‘sv’,‘he’,‘nl’,‘pt’,‘pt_br’,‘ru’,‘it’,‘fr’,‘ja’,‘pl’,‘hu’,‘ro’,‘id’,‘vi’,‘bg’,‘lv’,‘sk’,‘uk’,‘ko_kr’,‘kk’,‘cs’),
as you can see, there is no sr_sr but also no sr_yu … (and sr_yu afaik works fine).
what gives ?
Regards,
Igor Gnip