Share this page 

Generate the Javadoc "en français"Tag(s): Environment Internationalization


The javadoc utility uses the regular Java mechanism to internationalize its output. The tools.jar in the lib directory contains the resource bundle standard.properties used by Javadoc to generated the labels. To add a new language, you need to create the appropriate resource bundle, in our case for french, we need a file called standard_fr.properties.

The new file must be in the package com.sun.tools.doclets.standard.resources.

Extract from tools.jar, the standard.properties files (keep the directory structure). Copy it under the name standard_fr.properties. Translate it (or you can download my "incomplete" version here).

[standard.properties (extract)]

doclet.Window_Split_Index={0}\: {1}-Index
doclet.Packages=Packages
doclet.SerialData=Serial Data\:
doclet.Since=Since\:
doclet.Warn_inline_taglet=Inline tag {0} should only be used with a {1}.
doclet.ClassUse_Subinterface=Subinterfaces of {0} in {1}
doclet.Frame_Version=Frame version
doclet.Generated_Docs_Untitled=Generated Documentation (Untitled)

[standard_fr.properties (extract)]

doclet.Window_Split_Index={0}\: {1}-Index
doclet.Packages=Paquetages
doclet.SerialData=Donn\u00E9e s\u00E9rialis\u00E9e\:
doclet.Since=Depuis\:
doclet.Warn_inline_taglet=Inline tag {0} should only be used with a {1}.
doclet.ClassUse_Subinterface=Sous-interfaces de {0}  dans {1}
doclet.Frame_Version=Version avec cadres
doclet.Generated_Docs_Untitled=Documentation g\u00E9n\u00E9r\u00E9e

Once everything translated, put your standard_fr.properties into the tools.jar making sure that the file is located in the right package (along standard.properties in com.sun.tools.doclets.standard.resources).

To generate in french, use the -locale switch on the command line

javadoc -locale fr ....
NOTE : Make sure the -locale switch is the first one.

Using Ant,

<javadoc
    locale="fr"
    sourcefiles="c:/client/Client.java"
    destdir="javadoc/Client"
    author="true"
    version="true"
    use="true"
    private="true"
    windowtitle="Client">
    <doctitle><![CDATA[<h1>Client</h1>]]></doctitle>
    <bottom><![CDATA[<i>Copyright &#169; 2003 Real's Howto.</i>]]></bottom>
</javadoc>