ITコンサルの日常

ITコンサル会社に勤務する普通のITエンジニアの日常です。

OmegaTでJavaソース(javadoc)を翻訳するときの設定(訳文ファイルを生成したときに改行コードが消える問題の対策)

1.OmegaTを起動し、メニューより、設定→ファイルフィルターを選択します。

2.テキストファイルを選択し、編集ボタンをクリックします。

3.追加ボタンをクリックします。

4.原文ファイル名の構成例に「*.java」を入力し、確定ボタンをクリックします。

5.確定ボタンをクリックします。

6.テキストファイルを選択し、設定ボタンをクリックします。

7.原文を分節化する位置に「改行」を選択し、確定ボタンをクリックします。

8.確定ボタンをクリックします。

設定は以上です。


試しに翻訳してみます。

ソース(Javadocのドキュメントより拝借したソース)

/**
 * Returns an Image object that can then be painted on the screen. 
 * The url argument must specify an absolute  
                          
{@link URL}. The name
 * argument is a specifier that is relative to the url argument. 
 * <p>
 * This method always returns immediately, whether or not the 
 * image exists. When this applet attempts to draw the image on
 * the screen, the data will be loaded. The graphics primitives 
 * that draw the image will incrementally paint on the screen. 
 *
 *  
                          
@param  url  an absolute URL giving the base location of the image
 *  
                          
@param  name the location of the image, relative to the url argument
 *  
                          
@return      the image at the specified URL
 *  
                          
@see         Image
 */
 public Image getImage(URL url, String name) {
        try {
            return getImage(new URL(url, name));
        } catch (MalformedURLException e) {
            return null;
        }
 }

普通に翻訳してみる


出力結果

/**
 * スクリーンに描画可能なImageオブジェクトを返却します。 
 * The url argument must specify an absolute  
                          
{@link URL}. The name
 * argument is a specifier that is relative to the url argument. 
 * <p>
 * This method always returns immediately, whether or not the 
 * image exists. When this applet attempts to draw the image on
 * the screen, the data will be loaded. The graphics primitives 
 * that draw the image will incrementally paint on the screen. 
 *
 *  
                          
@param  url  an absolute URL giving the base location of the image
 *  
                          
@param  name the location of the image, relative to the url argument
 *  
                          
@return      the image at the specified URL
 *  
                          
@see         Image
 */
 public Image getImage(URL url, String name) {
        try {
            return getImage(new URL(url, name));
        } catch (MalformedURLException e) {
            return null;
        }
 }

ちなみに7の設定を行わなかった場合

/**
 * スクリーンに描画可能なImageオブジェクトを返却します。 * The url argument must specify an absolute  
                          
{@link URL}. The name
 * argument is a specifier that is relative to the url argument. 
 * <p>
 * This method always returns immediately, whether or not the 
 * image exists. When this applet attempts to draw the image on
 * the screen, the data will be loaded. The graphics primitives 
 * that draw the image will incrementally paint on the screen. 
 *
 *  
                          
@param  url  an absolute URL giving the base location of the image
 *  
                          
@param  name the location of the image, relative to the url argument
 *  
                          
@return      the image at the specified URL
 *  
                          
@see         Image
 */
 public Image getImage(URL url, String name) {
        try {
            return getImage(new URL(url, name));
        } catch (MalformedURLException e) {
            return null;
        }
 }

改行が消えてしまっています。
ちなみにのちなみにですが、訳文の行末に.(ピリオド)を入れると、
正しく改行されますが、日本語でピリオドはおかしいですよね。

Javadocって国際化サポートしてないの?

適当にググった感じサポートしてないっぽい。
OmegaTの活躍の余地がありそうですね。

JavaだけじゃなくてJavaScriptにも使える

ext-docとか、jsdocとか、
javadocっぽい記法を使ったドキュメンテーションツールについても、
同じようにできるはずです。
(拡張子は*.javaじゃなくて、*.jsにする必要はありますが)

というわけで

使ってるオープンソースに日本語APIドキュメントがない。。
という場合は、OmegaTを使って、ドキュメンテーションコメントを翻訳できますよ。
というお話でした。