Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Preg_replace & Gettext Problem

    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.
    Last edited by Alexey; 09-04-2007 at 02:10 AM.

  • #2
    Registered User
    Join Date
    Oct 2004
    Posts
    592
    Thanks
    0
    Thanked 1 Time in 1 Post
    You wanna do something like search highlighting function.

    If returned result is hello
    then the desired output is

    Code:
    <span class="highlight">hello</span>
    Google :
    http://www.google.com/search?q=php+h...ts&btnG=Search


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •