在Java中读取.po文件时出错 [英] error reading .po file in java

查看:143
本文介绍了在Java中读取.po文件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了一些有关从.po文件中读取内容的信息,但我仍然有一些疑问.有人知道您是否可以像读取Java中的.properties文件一样直接读取.po文件吗?还是需要将其从.po转换为.properties?

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?

我导入了类GettextResource和:

I imported the class GettextResource and :

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

哪里 msgstr名称测试" msgstr测试"(来自.po文件)

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

这确实只返回字符串"name_test". 我显然不知道我在这里做什么. 任何想法将不胜感激.谢谢.

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.

推荐答案

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

将GNU gettext消息目录编译为Java ResourceBundle 类,可以使用msgfmt程序.

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

您是否已使用此实用程序将.po文件转换为可由getBundle读取的资源包?

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

这篇关于在Java中读取.po文件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆