良好的 Java 属性文件编辑器
我从事一个开源 Java 项目,我们有很多包含可本地化消息资源的资源属性文件。这些文件由志愿者翻译成 20 多种语言,而我是一名主要编辑代码的开发人员。
在 Java 中,不同语言环境的资源文件通过命名约定分组在一起。例如,如果默认(通常是英语)资源是“foo.properties”,日语资源是“foo_ja.properties”,法语资源是“foo_fr.properties”等。为了解决这个问题,我们称这个组为“资源组”。
现在,我经常需要重构这些资源文件。此外,我需要该工具来支持属性文件的基础知识。总而言之,我的要求列表类似于:
- 重命名属性键名称,并且我想要一个工具来重命名同一组中所有文件中的所有键,而无需我单独查看它们。
- 将属性从一个资源组移动到另一个资源组,我希望有一个工具可以为该组中的每个资源文件执行此操作。
- 在Java中,资源文件采用ISO-8859-1编码,而不是平台默认编码。
- 我不想在编辑/浏览属性文件时看到 \uXXXX,但我确实希望该工具能够保留它们。
- 我不希望该工具重新排列资源文件中属性的顺序,也不希望弄乱注释。我希望该工具能够保存它们。
- 我希望该工具能够处理资源文件的其他语法细节,例如多行文本。
不幸的是,我没有找到任何符合这些标准的好工具。我主要是 IntelliJ IDEA 用户,但它不执行 #2 和 #3。 Eclipse 内置的属性文件编辑器更糟糕,AFAICT 它不执行 #1、#2、#4。事实上它缺乏跨同一组资源文件的视图。 NetBeans 同样很原始。 NetBeans 也是如此,尽管它是#4。
有谁知道适合该要求的好工具吗?
I work on an open-source Java project, and we have a lot of resource property files that contains localizable message resources. Those files are translated by volunteers to 20+ languages, and I'm a developer who primarily edits code.
In Java, resource files for different locales are grouped together by a naming convention. For example, if the default (normally English) resource is "foo.properties", Japanese resource is in "foo_ja.properties", French one is "foo_fr.properties", etc. For the sake of this question, let's call this group a "resource group."
Now, every so often, I need to refactor those resource files. In addition, I need the tool to support the basics of the property files. All in all, my list of requirements are something like:
- Renaming property key name, and I want a tool to rename all the keys in all the files in the same group, without me individually going through them.
- Move a property from one resource group to another, and I want a tool to do so for each resource file in the group.
- In Java, resource files are in the ISO-8859-1 encoding and not in the platform default encoding.
- I don't want to see \uXXXX when editing/browsing property files, but I do expect the tool to preserve them.
- I don't want the tool to rearrange the order of properties in the resource file, nor mess with the comments. I expect the tool to preserve them.
- I want the tool to handle other syntax details of resource files, such as multiline text.
Unfortunately, I'm not finding any good tool that fits these criteria. I'm primarily an IntelliJ IDEA user, but it doesn't do #2 and #3. Eclipse built-in property file editor is even worse, and AFAICT it doesn't do #1, #2, #4. In fact it lacks the view that cuts across resource files in the same group. NetBeans is similarly primitive. The same goes for NetBeans, although it does #4.
Does anyone know of a good tool that fits the bill?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
我用的是eclipse插件。我认为这个: http://sourceforge.net/projects/eclipse-rbe/
它没问题,允许添加和重命名属性,如果属性未翻译为所有支持的语言则显示警告等。
它的缺点是它总是对 unicode 字符使用“\uXXXX”表示法。因此,您必须使用此插件来读取创建的文件。这使得搜索变得非常困难。我不知道是否可以配置它来创建 UTF-8 编码的包。
I used plugin for eclipse. I think this one: http://sourceforge.net/projects/eclipse-rbe/
It is OK, allows adding and renaming properties, shows warnings if property is not translated to all supported languages etc.
Its disadvantage is that it always uses `\uXXXX' notation for unicode characters. So, you must use this plugin to read created files. It makes search very hard. And I do not know whether it is possible to configure it to create UTF-8 encoded bundles.
看看在线工具 POEditor https://poeditor.com。它基于项目。
Take a look at the online tool POEditor https://poeditor.com. Its project based.
如果您仍在寻找这样的插件,请查看 Multiproperties:参见此处
仅缺少#6 要求。
Check out Multiproperties, if you are still looking for such a plugin:see here
Only #6 requirement is missing.
Properties Editor(Eclipse 插件)确实做到了#4。从来不需要它做任何其他事情。
Properties Editor (Eclipse plugin) does #4 for sure. Never needed it for anything else.
事实证明 IntelliJ 应该能够做到#3(除了它在当前版本中不起作用由于一个错误。)所以我只剩下#2了。
目前(以及针对手头的问题)我决定将 Groovy 脚本放在一起比尝试这些工具更快:
该脚本是一个 hack 并且不理解属性文件语法,因此它不是非常可靠。但 VCS 可以通过让您准确地看到脚本做了什么来弥补这一缺点。
我仍然希望找到一个好的工具,以便从长远来看我的工作效率更高。所以请继续提供答案!
Turns out IntelliJ should be able to do #3 (except it doesn't work in the current releasedue to a bug.) So that leaves me with just #2.
For the time being (and for the problem at hand) I decided that putting together a Groovy script is faster than trying out those tools:
This script is a hack and doesn't understand the property file syntax, so it's not terribly reliable. But VCS can compensate that downside by letting you see exactly what the script did.
I'm still hoping to find a good tool so that I'm more productive in a longer run. So please keep the answers coming!
此时,我猜答案是 Java 中没有符合所列出条件的良好属性文件编辑器。 prbeditor 听起来很有希望,但它已经消失了,IntelliJ IDEA 表面上看起来不错,但遇到了一个严重的错误,然后 Eclipse 插件都有些原始。
At this point, I guess the answer is that there is no good property files editor in Java that matches the listed criteria. prbeditor sounded promising but it's gone, IntelliJ IDEA looks good on paper but is suffering a critical bug, and then the Eclipse plugins are all somewhat primitive.
我已经使用 prbeditor 一段时间了,我认为它可以满足您的要求:
I have been using prbeditor for some time now and I think it can handle the requirements you have:
这是一个旧的工具,但它是一个很好的工具。
JRC-编辑器:http://zaval.org/products/jrc-editor/ 确实如此除了重新排序键(对它们进行排序)之外,这可能不是您想要的。 (也许可以关闭此功能)
虽然重新排序密钥可能不好,但我发现当很多人处理一个资源包时它非常有用。源代码控制工具(例如 SVN)有更好的机会合并排序的资源包。
This is old but is a good tool.
JRC-Editor: http://zaval.org/products/jrc-editor/ it do all you except but re-ordering the keys (sort them) which may not be what you want. (May be this feature can be turned off)
Although it might not be good to re-order the keys, I found it very useful when lots of people work on one resource bundle. Source control tools, like SVN, have a better chance to merge the sorted resource bundles.
查看 j18n http://j18n.nomagicsoftware.com
它可以满足您的需求并引入资源继承,还为所有编辑提供版本控制
check out j18n http://j18n.nomagicsoftware.com
It does what you want and introduces resource inheritance and also provides versioning for all edits