-
Notifications
You must be signed in to change notification settings - Fork 33
[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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
国際化 | ||
==================== | ||
|
||
国際化と地域化とは、アプリケーションやコンテンツを特定の地域やユーザーの言語に | ||
対応させることです。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ファイルのコンテンツと同じように確認することができます。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 原文
gettext はこれのことですよね? → https://www.gnu.org/software/gettext/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 最後の
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ありがとうございます!修正しておきます。 |
||
|
||
Symfony 2.6 で XLIFF ファイルの<note>タグのサポートが追加され、翻訳者にとって | ||
使いやすいものになりました。 XLIFFの<note>タグを利用することで、文脈を定義する | ||
ことができ、ついに、文脈に応じた翻訳ができるようになりました。 | ||
|
||
.. tip:: | ||
|
||
Apacheライセンスの `JMSTranslationBundle`_ を使うとWebインターフェース上で | ||
翻訳ファイルの閲覧と編集を行うことができます。このバンドルにはプロジェクト | ||
を読み取り自動でXLIFFファイルを更新する優れた抽出機能があります。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 抽出機能はそれで良いと思います。 |
||
|
||
翻訳ソースファイルの配置 | ||
-------------------------------- | ||
|
||
.. best-practice:: | ||
|
||
翻訳ファイルは ``app/Resources/translations/`` ディレクトリに置きましょう。 | ||
|
||
慣習的に、Symfony開発者達は翻訳ファイルをそれぞれのバンドルの ``Resources/translations/`` | ||
ディレクトリに保存してしてきました。 | ||
|
||
しかし ``app/Resources/`` ディレクトリはアプリケーションリソースのグローバルロケーションとして | ||
扱われており、 翻訳ファイルを ``app/Resources/translations/`` に保存することで他の翻訳ファイルより | ||
優先させることができます。こうすることでサードパーティのバンドルの翻訳を上書きすることができます。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
これ先頭の There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
執筆者が伝えたいニュアンスは分かりますが、つながりが悪いですね。
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
There was a problem hiding this comment.
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 を参考にしました。