Reputation: 3617
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:
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?
Upvotes: 34
Views: 15020
Reputation: 31
Check out Multiproperties, if you are still looking for such a plugin:see here
Only #6 requirement is missing.
Upvotes: 3
Reputation: 1744
I have been using prbeditor for some time now and I think it can handle the requirements you have:
Upvotes: 2
Reputation: 45583
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.
Upvotes: 1
Reputation: 486
Take a look at the online tool POEditor https://poeditor.com. Its project based.
Upvotes: 3
Reputation: 9
check out j18n http://j18n.nomagicsoftware.com It does what you want and introduces resource inheritance and also provides versioning for all edits
Upvotes: 0
Reputation: 3617
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.
Upvotes: 2
Reputation: 3617
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:
#!/usr/bin/env groovy
// base name of the resource group to move a property from
File base = new File(args[0])
// key name of the property to move
String from = args[1]
// base name of the resource group to move the property to
File dst = new File(args[2])
// name of the new property after move
String to = args[3]
/*
TODO:
support multi-line
insert the text in a better place, in the sort order
*/
base.parentFile.eachFileMatch(~"${base.name}(_.*)?\\.properties") { f ->
def l = f.name.substring(base.name.length())
println "${f}"
def tmp = new File(f.path+".tmp")
// delete this property from the source, and remember it
def dropped = null;
tmp.withWriter("iso-8859-1") { w ->
f.filterLine(w,"iso-8859-1") { line ->
if (line.startsWith(from)) {
dropped = line;
return false;
} else {
return true;
}
}
}
tmp.renameTo(f)
if (dropped==null) return; // nothing to copy to
// append
f = new File(dst.path+l)
tmp = new File(f.path+".tmp")
println "-> ${f}"
existing = f.bytes
needsLF = (existing[existing.length-1]!='\n')
f.withWriterAppend("iso-8859-1") { w ->
if (needsLF) w.write('\n')
w.write(to+dropped.substring(from.length()))
w.write('\n')
}
}
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!
Upvotes: 2
Reputation: 841
Properties Editor (Eclipse plugin) does #4 for sure. Never needed it for anything else.
Upvotes: 2
Reputation: 115378
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.
Upvotes: 5