...

View Full Version : Preg_replace & Gettext Problem



Alexey
09-04-2007, 02:07 AM
Hello,

I could not find any info on this so I will ask here, maybe someone has an experience with this.

Ok, so basically i`m taking a whole chunk of code from the database that is generated once in a while. My website has several languages so i want that translated to all languages.

I concatenated all the strings in the database-stored "chunk of code" via <ff> </ff>.

And then I use something like this:

preg_replace("%\<ff\>([a-zA-Z0-9\.\:(\s)]*)\</ff\>%is",_("$1"),$chunk_of_code);

I replaced _() with my tr() translating function and apparently it gets hit, just cant find the translation i guess.

When I use print _('same text'); it shows up correctly. So i`m guessing there's some issue locating the translations while using preg_replace like that.

I`m not looking for alternatives to storing the data, I`m looking for a solution to this problem if you have any.

Thanks for your time.

iota
09-04-2007, 02:39 PM
You wanna do something like search highlighting function.

If returned result is hello
then the desired output is


<span class="highlight">hello</span>

Google :
http://www.google.com/search?q=php+highlight+search+results&btnG=Search



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum