Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate a translated javadoc with javadoc.exe? (not the content, but the structure)

I'm working on a pt_BR project that provides a final user API to extends functionalities.

I need to generate the javadoc of this classes (in Java), but, when using javadoc.exe the static texts, not the content, of the output document is in English.

So, I want to generate the documentation in pt_BR.

I tried to use like this:

javadoc -locale pt_BR -sourcepath scr -d c:\TEMP

But it didn't work.

Note: Just to be clear, I'm not intent to translate the content (that is already in pt_BR) but the static texts (the navigation bar, titles, etc).

How can I do that?

like image 831
Jose Renato Avatar asked Aug 22 '12 13:08

Jose Renato


2 Answers

We had to do that on a project of ours. This is what we did:

First, we decompiled the following classes from Java's tools.jar file:

  • com\sun\tools\doclets\formats\html\resources\standard.class
  • com\sun\tools\doclets\internal\toolkit\resources\doclets.class

Those two classes act like .properties files: their only method returns an array of keys-values pairs of strings.

Most of those strings are the ones that appear on the HTML files created by Javadoc, such as the navigation bar, section headers and help page.

After translating the files, we renamed them, adding _pt_BR to their names.

We also changed the name of their classes, also adding _pt_BR.

Finally, we compiled the files and put them into tools.jar, on their correct packages.

After that, the HTML output from Javadoc was presented in Portuguese.

like image 131
Mario Marinato Avatar answered Nov 15 '22 14:11

Mario Marinato


You will have to find the properties files in your jdk and translate them. I think they are located at tools.jar. I only found the JDK 1.3 Doclet sources on the net. They might give you a hint on the needed property files.

like image 1
Bernd Ebertz Avatar answered Nov 15 '22 15:11

Bernd Ebertz