开发者

How can I use PHP's gettext in conjunction with python's gettext?

开发者 https://www.devze.com 2022-12-11 11:41 出处:网络
I have an app that I\'m migrating portions of to Django, but Python and PHP have a different string format,e.g., \"Hello %1s\" in PHP vs. \"Hello {0}\" or \"Hello {name开发者_开发技巧}\" in Python.

I have an app that I'm migrating portions of to Django, but Python and PHP have a different string format, e.g., "Hello %1s" in PHP vs. "Hello {0}" or "Hello {name开发者_开发技巧}" in Python.

We'll be maintaining both apps for a while, but is there a way to use the Python format in PHP or vice versa?


Would something like this php PECL extension help you?

http://pecl.php.net/package/python

Regards.


PHP's gettext doesn't expand/substitute %s - this is done by output functions (e.g. printf). It also appears to be the case in Python.

Most importantly, in Python you can use %s to represent strings, see http://docs.python.org/library/stdtypes.html#string-formatting

So you should be able to use %s-style strings in both.

0

精彩评论

暂无评论...
验证码 换一张
取 消