Yii Framework Forum: MO Files Problems - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

MO Files Problems It's a bug? Or my MO file are in a non standard mode? Rate Topic: -----

#1 User is offline   Ricardo Pereira 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 03-February 11

Posted 03 February 2011 - 05:29 AM

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.

Attached File(s)


0

#2 User is offline   Ricardo Pereira 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 03-February 11

Posted 07 February 2011 - 11:55 AM

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.
0

#3 User is offline   Ricardo Pereira 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 03-February 11

Posted 16 March 2011 - 04:55 AM

[[[ BUMP ]]]

I don't understand the reasons why MO PO have low priority in this framework.
0

#4 User is offline   Thommee 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 24-June 12
  • Location:PoznaƄ, Poland

Posted 24 June 2012 - 10:44 AM

View PostRicardo Pereira, on 07 February 2011 - 11:55 AM, said:

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.



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).
0

#5 User is offline   mohamadaliakbari 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 14-July 11

Posted 23 October 2012 - 11:01 AM

Your solution works great for me ;)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users