Hello,
I have problems to get translations with MO files.
Config:
...
'sourceLanguage'=>'en_gb',
'language'=>'es_es',
...
'messages'=>array(
'class'=>'CGettextMessageSource',
'catalog'=>'messages',
'cachingDuration'=>'3600',
),
...
I have this MO file in /protected/messages/es_es/messages.mo
Trying to solve the problem I fond that CGettextMoFile reads the file but fail in this if (Line 116):
if(($pos=strpos($id,chr(4)))!==false && substr($id,0,$pos)===$context)
$pos = empty - $context = empty
To solve the problem i change this line to this:
$pos=strpos($id,chr(4));
if(substr($id,0,$pos)===$context)
The problem persist because the first letter of id as deleted.
To solve this problem i changed the line 119:
$id=substr($id,$pos+1);
To this:
$id=substr($id,$pos);
Ok… Now everything is working correctly with MO files.
This MO file was created with Poedit (www.poedit.net) and my operative system is Mac OS X 10.6.6.
It’s a bug? Or my MO file are in a non standard mode?
Best Regards, Ricardo.
Hello,
Same problem with MO/PO files created in Windows…
Any fix to this problem?
Another thing, with PHP in E_ALL and E_STRICT y have the flowing errors in the same file (CGettextMoFile.php):
"Only variables should be passed by reference"
Lines 77
$magic=current($array=unpack(‘c’,$this->readByte($fr,4)));
Line 232
return current($array=unpack($this->useBigEndian ? ‘N’ : ‘V’, $this->readByte($fr,4)));
Best Regards, Ricardo.
[[[ BUMP ]]]
I don’t understand the reasons why MO PO have low priority in this framework.
thommee
(2 Boys)
4
I had the same problems that you… Solution:
Lines 77
$magic=current($array=unpack(‘c’,$this->readByte($fr,4)));
Change to:
$result = $array=unpack(‘c’,$this->readByte($fr,4));
$magic=current($result);
Line 232
return current($array=unpack($this->useBigEndian ? ‘N’ : ‘V’, $this->readByte($fr,4)));
Change to:
$result = $array=unpack($this->useBigEndian ? ‘N’ : ‘V’, $this->readByte($fr,4));
return current($result);
BTW: @Ricardo Pereira: Big thanks for the solution from first post. Now all works fine (with .po and .mo files).
Your solution works great for me