Translation
===========
There are two main catalogue names in an Admin class:
Adminクラスでは2つの主なカタログ名があります。
* ``SonataAdminBundle`` : this catalogue is used to translate shared messages
accross different admins
* ``messages`` : this catalogue is used to translate the messages for the current
admin
* ``SonataAdminBundle`` : このカタログは異なるAdminにまたがった共有メッセージを翻訳するために使われます
* ``messages`` : このカタログは現在のAdminに対してメッセージを翻訳するために使われます。
Ideally the ``messages`` catalogue should be changed to avoid any issues with
other Admin classes.
理想的には、 ``messages`` カタログは他のAdminクラスによる問題を避けるために変更するべきです。
You have two options to configure the catalogue for the admin class:
Adminクラス向けのカタログを設定するために2つのオプションがあります。
* one by defining a property
* 1つは定義されているプロパティです。
.. code-block:: php
Application\Sonata\PageBundle\Entity\Page
SonataPageBundle
An admin instance always gets the ``translator`` instance, so it can be used to
translate messages within the ``configure*Fields`` method or in templates.
Adminインスタンスはいつも ``translator`` を取得し、そして ``configure*Fields`` メソッドや
テンプレート内でメッセージを翻訳するために使われます。
.. code-block:: jinja
{# the classical call by using the twig trans helper #}
{% trans from 'SonataPageBundle'%}message_create_snapshots{% endtrans %}
{# by using the admin trans method with hardcoded catalogue #}
{{ admin.trans('message_create_snapshots', {}, 'SonataPageBundle') }}
{# by using the admin trans with the configured catalogue #}
{{ admin.trans('message_create_snapshots') }}
The later solution is more flexible as no catalogue parameters are hardcoded.
最新の解決法はより柔軟でカタログパラメーターはハードコーディングされていません。
Translate field labels
----------------------
The Admin bundle comes with a customized form field template. The most notable
changes from the original one is the use of the translation domain provided by
the Admin instance to translate label.
AdminBundle はカスタマイズされたフォームフィールドテンプレートを備えてています。オリジナルの
フォームフィールドからの最も重要な変更は、labelを翻訳するためAdminインスタンスにより提供された
翻訳ドメイン(translation domain)が使われていることです。
By default, the label is the field name. However a label can be defined as
third argument of the ``add`` method:
デフォルトでは、labelはフィールド名です。しかしながら、labelは ``add`` メソッドの第3引数として
定義することができます。
.. code-block:: php
add('isValid', null, array('required' => false, 'label' => 'label.is_valid'));
}
}
There is another option for rapid prototyping or to avoid spending too much time
adding the ``label`` key to all option fields: ``Label Strategies``. By default
labels are generated by using a simple rule ::
素早いプロトタイプ作成をするためや、多くの時間を費やすのを避けるため、 ``Label Strategies``
という全てのオプションフィールドに ``label`` キーを追加するためのオプションがあります。
isValid => Is Valid
.. note::
For early adopter, you can use a specific backward compatible service to
keep your current translation.
早くからの(このbunbleの)採用者は、現在の翻訳を使用しつづけるため固有の後方互換性サービスを使うことができます。
The ``AdminBundle`` comes with different key label generation strategies:
``AdminBundle`` は異なるキーlabel生成戦略を備えています。
* ``sonata.admin.label.strategy.native`` : DEFAULT - Makes the string human
readable readable - ``isValid`` => ``Is Valid``
* ``sonata.admin.label.strategy.form_component`` : The default behavior from the
Form Component - ``isValid`` => ``Isvalid``)
* ``sonata.admin.label.strategy.underscore`` : Adds undescore to the label -
``isValid`` => ``form.label_is_valid``
* ``sonata.admin.label.strategy.noop`` : does not alter the string - ``isValid``
=> ``isValid``
* ``sonata.admin.label.strategy.bc`` : preserves the old label generation from
the early version of ``SonataAdminBundle``
* ``sonata.admin.label.strategy.native`` : DEFAULT - 人間が読みやすい文字列を作成 - ``isValid`` => ``Is Valid``
* ``sonata.admin.label.strategy.form_component`` : フォームコンポーネントによるデフォルト動作 - ``isValid`` => ``Isvalid``)
* ``sonata.admin.label.strategy.underscore`` : labelにアンダースコアを追加 - ``isValid`` => ``form.label_is_valid``
* ``sonata.admin.label.strategy.noop`` : 文字列の変更なし - ``isValid`` => ``isValid``
* ``sonata.admin.label.strategy.bc`` : 以前のバージョンの ``SonataAdminBundle`` による古いlabel生成を維持する
``sonata.admin.label.strategy.underscore`` will be better for i18n applications
and ``sonata.admin.label.strategy.native` will be better for native language
based on the field name. So it is possible to start with the ``native`` strategy
and then when the application needs to be translated using generic keys the
configuration can be switched to the ``sonata.admin.label.strategy.underscore``.
``sonata.admin.label.strategy.underscore`` は国際化アプリケーションに最適であり、 ``sonata.admin.label.strategy.native`` は
フィールド名に基づいたネイティブ言語に最適です(Symfonyで設定してあるデフォルト言語で開発する場合を指してると思われる)。
だから、 ``native`` で(開発を)始めることができ、そしてアプリケーションを翻訳する必要が出てきた時に
``sonata.admin.label.strategy.underscore`` という一般的なキーを使うことで設定を切り替えることができます。
The strategy can be quickly configured when the Admin class is registered into
the Container:
この戦略はAdminクラスをコンテナに登録する時に簡単に設定できます。
.. code-block:: xml
AcmeBundle\ProjectBundle\Entity\ProjectFeed
.. note::
In all cases the label will be used by the ``Translator``. The strategy is
just a quick way to generate translatable keys. It all depends on the
project's requirements.
全てのケースにおいて、labelは ``Translator`` によって使われます。この戦略はプロジェクトの
要求に沿った翻訳キーを生成するのに良いやりかたです。
.. note::
When the strategy method is called, a context (form, filter, list, show) and
a type (link, label, etc ...) arguments are passed.
strategyメソッドが呼ばれる際、(form, filter, list, show)といったコンテキストや(link, label, etc ...) といったタイプの引数は飛ばされます。