我读了一些关于读取 .po 文件的内容,但仍然有一些问题。有谁知道是否可以像java中读取.properties文件一样直接读取.po文件,还是需要将.po转换为.properties?
我导入了 GettextResource 类并且:
ResourceBundle rb = ResourceBundle.getBundle("stuff.po.I18n");
System.out.println(GettextResource.gettext(rb, "name_test"));
哪里 msgstr "名称_测试" msgstr“test”(来自.po文件)
这确实只返回字符串“name_test”。 我显然不知道我在这里做什么...... 任何想法将不胜感激。谢谢。
最佳答案
来自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.
您是否使用此实用程序将 .po 文件转换为可由 getBundle 读取的资源包?
关于java - 在java中读取.po文件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6576320/