gettext中的php字符串变量
gettext如何转换字符串变量?似乎并不想这样做..可以说我有$ sentence ="Hello World";然后我要回显($ sentence); ...我该怎么做才能在Poedit中翻译$ sentence里面的内容?我可以使用-> echo sprintf((%s test"),$ sentence),这将打印"Hello World"测试"在浏览器中,但它将在Poedit中显示为%s test",而我不会在Poedit中获得Hello World的翻译版本.那么如何在Poedit中使用字符串变量呢?谢谢!
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!
您只可以没有字符串变量.您应该这样做
You just must not have string variables. You should do e.g.
$sentance = _('Hello world');
另一种方法是使用一些解析器之王,它将能够找到您好世界的字符串,并最终在某个地方输出
The other way is to use some king of parser, which will be able to find your hello world strings and finally output somewhere
$fakie = _('Hello World');
此输出应存储在某个文件中,然后由poedit拾取并翻译.要显示翻译,您可以使用
This output should be stored in some file, which will then be pickedup by poedit and translated. For showing the translation you can than use
$myTranslation = _($sentance);
我们将此转换过程用于javascript文件和smarty模板.
We used this conversion process for javascript files and smarty templates.