Note that there are some explanatory texts on larger screens.

plurals
  1. POphp string variables in gettext (forgot one case scenario)
    primarykey
    data
    text
    <p>I've posted a question yesterday but I just realized that the answer doesn't seem to be working for a certain situation. The post was <a href="https://stackoverflow.com/questions/1349159/php-string-variables-in-gettext/1349209#1349209">php string variables in gettext</a> and here is what I asked about: </p> <blockquote> <p>Hello,</p> <p>How does gettext translate string variables? It doesn't seem to want to do it.. lets say I have $sentence = "Hello World"; and then I want to echo ($sentence); ... how can I do that so that I can translate what's inside $sentence in Poedit?I can use -> echo sprintf(("%s test"), $sentence) and this will print "Hello World test" in the browser but it will appear as "%s test" in Poedit and I won't get the translated version of Hello World inside of Poedit. So how can I use string variables inside Poedit? Thanks!</p> </blockquote> <p>This has been solved. </p> <p>The problem occurs if I want to grab data from an XML file and translate it.</p> <p>I want to be able to do the following:</p> <pre><code>$foo = $xmlData -&gt; titleText; </code></pre> <p>and then</p> <pre><code>echo _($foo); </code></pre> <p>or something like </p> <pre><code>$finalVar = _($foo); </code></pre> <p>If I look at the php file in the browser I can see the content of $foo on the page but Poedit doesn't pick up the string inside $foo so I can translate it.</p> <p>(I believe this problem will also occur when translating info within js files)</p> <p>Thank you for your help,</p> <p>Simon</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload