Ken*_*tor 2 php string variables gettext poedit
gettext如何翻译字符串变量?它似乎不想这样做..让我说$ sentence ="Hello World"; 然后我想回声($句子); ...我怎么能这样做,以便我可以翻译Poedit中的$句子里面的内容?我可以使用 - > echo sprintf(("%s test"),$ sentence)这将打印出"Hello World test"浏览器,但它将在Poedit中显示为"%s test",我不会在Poedit中获得Hello World的翻译版本.那么如何在Poedit中使用字符串变量?谢谢!
你不能有字符串变量.你应该这样做
$sentance = _('Hello world');
Run Code Online (Sandbox Code Playgroud)
另一种方法是使用一些解析器之王,它将能够找到你的hello world字符串并最终输出到某处
$fakie = _('Hello World');
Run Code Online (Sandbox Code Playgroud)
此输出应存储在某个文件中,然后由poedit接收并翻译.要显示翻译,您可以使用
$myTranslation = _($sentance);
Run Code Online (Sandbox Code Playgroud)
我们将此转换过程用于javascript文件和智能模板.