error reading .po file in java

南笙酒味 提交于 2019-12-11 08:06:39

问题


i read a bit about reading from .po files and i still have some questions. Does anyone know if you can directly read from a .po file just like reading from a .properties file in java, or does it need to be transformed from .po to .properties?

I imported the class GettextResource and :

ResourceBundle rb = ResourceBundle.getBundle("stuff.po.I18n");
System.out.println(GettextResource.gettext(rb, "name_test"));

Where msgid "name_test" msgstr "test" (from .po file)

This does return only the string "name_test". I clearly have no clue what i am doing here... any thoughts will be much appreciated. thanks.


回答1:


From http://www.gnu.org/software/gettext/manual/javadoc2/gnu/gettext/GettextResource.html

To compile GNU gettext message catalogs into Java ResourceBundle classes, the msgfmt program can be used.

Have you used this utility to convert your .po file to a resource bundle that can be read by getBundle?



来源:https://stackoverflow.com/questions/6576320/error-reading-po-file-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!