How can I use PHP's gettext in conjunction with python's gettext?
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.
精彩评论