Yii Framework Forum: Regular expressions for Yii::t - Yii Framework Forum

Jump to content

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

Regular expressions for Yii::t Rate Topic: -----

#1 User is offline   thelfensdrfer 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 37
  • Joined: 06-March 11
  • Location:Germany

Posted 10 February 2012 - 08:46 PM

Hi,

I am trying to implement a small tool in my site so i can search for all Yii::t and write them into the corresponding files in the messages folder. But I have some problems with my expression.

preg_match_all("/Yii[:]{2}t\(['|\"](.+?)['|\"],[\s]+['|\"](.+?)['|\"].*\)/im", $content, $matches, PREG_SET_ORDER);



It finds something like:
Yii::t('User', 'User deleted')


but here are my problems:
  • It does not find Yii::t('User', 'add add"asdasd') I don't know how to exclude the quote which is not around the string. "/Yii[:]{2}t\(['(.+?)'|\"(.+?)\"],[\s]+['(.+?)'|\"(.+?)\"].*\)/im" does not work...
  • It does not find the translations with parameters. For example Yii::t('User', 'add {gbf}', array('{gbf}' => 1)).

I think this would be a quite useful tool, but regular expressions are something i will never learn:(


Thanks

0

#2 User is offline   thelfensdrfer 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 37
  • Joined: 06-March 11
  • Location:Germany

Posted 11 February 2012 - 06:38 AM

Ok probably i had to search for an existing solution instead of creating my own...In this topic were at least two working solutions.

http://www.yiiframew...ing-using-yiit/
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