OmegaTでJavaソース(javadoc)を翻訳するときの設定(訳文ファイルを生成したときに改行コードが消える問題の対策)
1.OmegaTを起動し、メニューより、設定→ファイルフィルターを選択します。
4.原文ファイル名の構成例に「*.java」を入力し、確定ボタンをクリックします。
ソース(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; } }
改行が消えてしまっています。
ちなみにのちなみにですが、訳文の行末に.(ピリオド)を入れると、
正しく改行されますが、日本語でピリオドはおかしいですよね。
JavaだけじゃなくてJavaScriptにも使える
ext-docとか、jsdocとか、
javadocっぽい記法を使ったドキュメンテーションツールについても、
同じようにできるはずです。
(拡張子は*.javaじゃなくて、*.jsにする必要はありますが)
というわけで
使ってるオープンソースに日本語APIドキュメントがない。。
という場合は、OmegaTを使って、ドキュメンテーションコメントを翻訳できますよ。
というお話でした。