有人可以告诉我这是否是本地化 Python 字符串的正确方法?它工作得很好,但我无法在任何地方找到这是否正是我应该这样做的方式。非常感谢!!!
在我的 Python 脚本中,我采用了以下字符串格式化方法:
print(_('{0} does not exist').format(file_name))
我的 message.pot 文件包含以下内容:
#: some_file.py:65
#, python-format
msgid "{0} does not exist"
msgstr ""
我的翻译文件(messages_fr.po)是这样的:
#: some_file.py:65
#, python-format
msgid "{0} does not exist"
msgstr "{0} n'existe pas"
最佳答案
这正是 L10N 在简单字符串上的执行方式。请注意,消息目录的文件名将取决于 I18N 的具体执行方式。
关于python - 这是一种有效的本地化 Python 字符串格式化技术吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23555067/