Skip to content

[best practice] i18n.rst(Internationalization) を翻訳 #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions best_practices/i18n.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
国際化
====================

国際化と地域化とは、アプリケーションやコンテンツを特定の地域やユーザーの言語に
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「Internationalization and localization」の翻訳は、wikipediaの翻訳を参考にしました。
英語) http://en.wikipedia.org/wiki/Internationalization_and_localization
日本語) http://ja.wikipedia.org/wiki/%E5%9B%BD%E9%9A%9B%E5%8C%96%E3%81%A8%E5%9C%B0%E5%9F%9F%E5%8C%96 を参考にしました。

対応させることです。Symfonyでは国際化機能を利用する前に事前に有効化する必要があります。

.. code-block:: yaml

# app/config/config.yml
framework:
# ...
translator: { fallback: "%locale%" }

# app/config/parameters.yml
parameters:
# ...
locale: en

翻訳ソースのファイルフォーマット
------------------------------

SymfonyのTranslationコンポーネントは多くの翻訳フォーマットをサポートしています。
対応フォーマットには、PHP, Qt, ``.po``, ``.mo``, JSON, CSV, INI, などがあります。

.. best-practice::

翻訳ファイルにはXLIFFフォーマットを使用しましょう。

全ての利用可能なフォーマットの中で、XLIFFとgettextだけがプロの翻訳者が利用する
ツールで幅広く支持されています。 そしてXLIFFはXMLベースのフォーマットであるので、
自分で書いたXLIFFファイルのコンテンツと同じように確認することができます。
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原文

Of all the available translation formats, only XLIFF and gettext have broad
support in the tools used by professional translators. And since it's based
on XML, you can validate XLIFF file contents as you write them.

gettext はこれのことですよね? → https://www.gnu.org/software/gettext/
Translationコンポーネントで対応してるフォーマットというわけではなさそうですがここはこれで大丈夫でしょうか。
あと、validateの翻訳は確認で大丈夫でしょうか?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最後の as you write them の部分は、「翻訳ファイルを書いたら」という感じですね。
validate は XMLスキーマによるバリデーションを指しているので、もう少し言葉を補った方がよい気がします。

XLIFFはXMLベースのフォーマットなので、翻訳したファイルに構文のミスがないか確認することもできます。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます!修正しておきます。


Symfony 2.6 で XLIFF ファイルの<note>タグのサポートが追加され、翻訳者にとって
使いやすいものになりました。 XLIFFの<note>タグを利用することで、文脈を定義する
ことができ、ついに、文脈に応じた翻訳ができるようになりました。

.. tip::

Apacheライセンスの `JMSTranslationBundle`_ を使うとWebインターフェース上で
翻訳ファイルの閲覧と編集を行うことができます。このバンドルにはプロジェクト
を読み取り自動でXLIFFファイルを更新する優れた抽出機能があります。
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Apache-licensed `JMSTranslationBundle`_ offers you a web interface for
viewing and editing these translation files. It also has advanced extractors
that can read your project and automatically update the XLIFF files.

extractorsを抽出機能と訳しましたが大丈夫でしょうか。
この辺り試してみたところ翻訳ファイルの出力はできました。
http://jmsyst.com/bundles/JMSTranslationBundle/master/usage#dumping-translation-messages

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

抽出機能はそれで良いと思います。
(リンク先で「update」動作についての動作も記述されていますし、大丈夫だと思います)


翻訳ソースファイルの配置
--------------------------------

.. best-practice::

翻訳ファイルは ``app/Resources/translations/`` ディレクトリに置きましょう。

慣習的に、Symfony開発者達は翻訳ファイルをそれぞれのバンドルの ``Resources/translations/``
ディレクトリに保存してしてきました。

しかし ``app/Resources/`` ディレクトリはアプリケーションリソースのグローバルロケーションとして
扱われており、 翻訳ファイルを ``app/Resources/translations/`` に保存することで他の翻訳ファイルより
優先させることができます。こうすることでサードパーティのバンドルの翻訳を上書きすることができます。
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But since the ``app/Resources/`` directory is considered the global location
for the application's resources, storing translations in ``app/Resources/translations/``
centralizes them *and* gives them priority over any other translation file.
This lets you override translations defined in third-party bundles.

これ先頭のButは不要でしょうか。
is considered 「は扱われる」と意訳しました。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

先頭のButは不要でしょうか。

執筆者が伝えたいニュアンスは分かりますが、つながりが悪いですね。
だいぶ意訳ですが、次のようにしてみてはどうでしょう。

...ディレクトリに保存してきました。
一方で、Symfony には、アプリケーションリソースのグローバルロケーションとして
``app/Resource`` ディレクトリがあります。
翻訳ファイルを ``app/Resources/translations/`` に保存すれば、
他の翻訳ファイルより優先させることができます。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ありがとうございます!こちらに修正しておきます。


翻訳キー
----------------

.. best-practice::

常に翻訳ではコンテンツの文字列の代わりにキーを使うようにしましょう。

キーを利用すれば、全ての翻訳ファイルを変更することなく元のコンテンツを変更することが
できるので翻訳ファイルの管理が容易になります。

キーはその位置ではなく、目的を表すべきです。例えば、"Username" というフィールド
を持ったフォームがあるとします。その場合によいキーは ``label.username`` です。
決して ``edit_form.label.username`` ではありません

翻訳ファイルのサンプル
------------------------

これまで述べてきた全てのベストプラクティスを適用すると、アプリケーションにおける
英語用の翻訳サンプルは次のようになります。

.. code-block:: xml

<!-- app/Resources/translations/messages.en.xliff -->
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" target-language="en" datatype="plaintext">
<body>
<trans-unit id="1">
<source>title.post_list</source>
<target>Post List</target>
</trans-unit>
</body>
</file>
</xliff>

.. _`JMSTranslationBundle`: https://github.com/schmittjoh/JMSTranslationBundle