Search code examples
javaapiscalagettextpo

Is there a Java library for parsing gettext PO files?


Does anyone know of a Java library that will let me parse .PO files? I simply want to create a Map of IDs and Values so I can load them into a database.


Solution

  • According to Java gettext utilities Manual you may convert PO file to a ResourceBundle class using msgfmt --java2 program and read it using java.util.ResourceBundle or gnu.gettext.GettextResource - I suppose it to be a most efficient way. Gettext-commons do exactly the same including intermediate process creation to call msgfmt because it is positioned as following:

    Gettext Commons is Java library that makes use of GNU gettext utilities.

    If you still want exactly a Java library then the only way I see is to write your own library for parsing this format i.e. rewrite msgfmt source code from C to Java language. But I'm not sure it will be faster than create process + run C program.