翻訳プロジェクトに追加する、または翻訳プロジェクトから除外するページ、コンポーネントおよびアセットの翻訳対象コンテンツは翻訳ルールによって特定されます。ページやアセットを翻訳する場合は、AEM がそのコンテンツを抽出して、翻訳サービスに送信できるようにします。
ページとアセットは、JCR リポジトリー内のノードとして表されます。抽出されるコンテンツはノードの 1 つ以上のプロパティ値です。翻訳ルールは、抽出するコンテンツを含むプロパティを識別します。
翻訳ルールは XML 形式で表現され、次の場所に格納されています。
/libs/settings/translation/rules/translation_rules.xml
/apps/settings/translation/rules/translation_rules.xml
/conf/global/settings/translation/rules/translation_rules.xml
このファイルはすべての翻訳プロジェクトに適用されます。
6.4 にアップグレードした後、/etc からファイルを移動することをお勧めします。 詳しくは、AEM 6.5 における共通リポジトリの再構築を参照してください。
ルールには以下の情報が含まれます。
例えば、ページ上のすべての AEM 基盤テキストコンポーネントに作成者が追加するコンテンツを翻訳するルールを作成できます。このルールでは、/content
ノードと foundation/components/text
コンポーネントの text
プロパティを識別できます。
翻訳ルールの設定用に追加されたコンソールがあります。UI での定義の内容がファイルに自動的に入力されます。
AEM のコンテンツ翻訳機能の概要については、多言語サイトのコンテンツの翻訳を参照してください。
AEM は、ページ上の参照コンテンツの翻訳に関して、リソースタイプと参照属性の 1 対 1 マッピングをサポートしています。
ルールとは、1 個以上の node
子要素と 0 個以上の property
子要素を含む node
要素です。
<node path="content path">
<property name="property name" [translate="false"]/>
<node resourceType="component path" >
<property name="property name" [translate="false"]/>
</node>
</node>
これらの各 node
要素には以下の特徴があります。
path
属性には、ルールが適用されるブランチのルートノードのパスが格納されます。
property
子要素は、すべてのリソースタイプについて、翻訳するノードプロパティを特定します。
name
属性には、プロパティ名が格納されます。translate
属性は false
になります。デフォルト値は true
です。この属性は、以前のルールを上書きする場合に役立ちます。node
子要素は、特定のリソースタイプについて、翻訳するノードプロパティを特定します。
resourceType
属性には、リソースタイプを実装するコンポーネントに解決されるパスが格納されます。property
子要素は、翻訳するノードプロパティを特定します。このノードは、ノードルールの property
子要素と同じ方法で使用します。以下のルール例を適用すると、/content
ノード下のすべてのページについて、すべての text
プロパティのコンテンツが翻訳されます。このルールは、基盤テキストコンポーネントや基盤画像コンポーネントなど、text
プロパティでコンテンツを格納しているすべてのコンポーネントに対して有効です。
<node path="/content">
<property name="text"/>
</node>
次の例では、すべての text
プロパティのコンテンツを翻訳し、基盤画像コンポーネントのその他のプロパティも翻訳します。その他のコンポーネントに同じ名前のプロパティが含まれている場合、それらのプロパティにはルールが適用されません。
<node path="/content">
<property name="text"/>
<node resourceType="foundation/components/textimage">
<property name="image/alt"/>
<property name="image/jcr:description"/>
<property name="image/jcr:title"/>
</node>
</node>
次に示すルールの構文を使用して、コンポーネントに埋め込むアセットまたはコンポーネントから参照するアセットを追加します。
<assetNode resourceType="path to component" assetReferenceAttribute="property that stores asset"/>
各 assetNode
要素には以下の特徴があります。
resourceType
属性は、コンポーネントに解決されるパスと等しくなります。。assetReferenceAttribute
属性は、(埋め込みアセット用の)アセットバイナリを格納するプロパティの名前または参照先のアセットのパスと等しくなります。次の例では、基盤画像コンポーネントから画像を抽出します。
<assetNode resourceType="foundation/components/image" assetReferenceAttribute="fileReference"/>
translation_rules.xml ファイルは、複数の node
子要素を持つ nodelist
要素で構成されます。AEM は、このノードリストを上から下に読み取ります。複数のルールが同じノードをターゲットにする場合は、ファイル内で下方にあるルールが使用されます。例えば、以下のルールを適用すると、ページの /content/mysite/en
ブランチを除く、text
プロパティのすべてのコンテンツが翻訳されます。
<nodelist>
<node path="/content">
<property name="text" />
</node>
<node path="/content/mysite/en">
<property name="text" translate="false" />
</node>
<nodelist>
filter
要素を使用して、特定のプロパティを持つノードをフィルタリングできます。
例えば、次のルールを使用すると、プロパティ text
が draft
に設定されている場合を除き、true
プロパティのすべてのコンテンツが翻訳されます。
<nodelist>
<node path="/content">
<filter>
<node containsProperty="draft" propertyValue="true" />
</filter>
<property name="text" />
</node>
<nodelist>
コンソールを使用して翻訳ルールを設定することもできます。
コンソールにアクセスするには:
ツール/一般に移動します。
「翻訳設定」を選択します。
ここから、コンテキストを追加できます。これにより、パスを追加できます。
次に、コンテキストを選択して「編集」をクリックする必要があります。翻訳ルールエディターが開きます。
この UI では、4 つの属性(isDeep
、inherit
、translate
および updateDestinationLanguage
)を変更できます。
isDeep:この属性はノードフィルターで適用できます。デフォルトでは true です。ノード(またはその上位ノード)に、フィルターで指定されたプロパティ値を持つそのプロパティが含まれているかどうかをチェックします。false の場合は、現在のノードのみでチェックします。
例えば、親ノードの draftOnly
プロパティが true に設定され、ドラフトコンテンツであることを示している場合でも、子ノードは翻訳ジョブに追加されます。ここで、isDeep
が機能し、親ノードの draftOnly
プロパティが true であるかどうかをチェックして、それらの子ノードを除外します。
エディターでは、「フィルター」タブで「サブ項目の有無」をチェックまたはチェック解除できます。
次に、UI で「サブ項目の有無」をチェック解除した場合の結果の xml の例を示します。
<filter>
<node containsProperty="draftOnly" isDeep="false" propertyValue="true"/>
</filter>
inherit:プロパティに対して適用できます。デフォルトでは、すべてのプロパティが継承されますが、あるプロパティを子に継承しないようにする場合は、そのプロパティを false に設定して、その特定のノードでのみ適用できます。
UI では、「プロパティ」タブで「継承」をチェックまたはチェック解除できます。
translate:translate 属性は、単純にプロパティを翻訳するかどうかを指定するために使用されます。
UI では、「プロパティ」タブで「翻訳」をチェックまたはチェック解除できます。
updateDestinationLanguage この属性は、テキストを持たないが言語コード(例:jcr:language)を持つプロパティに使用されます。 ユーザーはテキストを翻訳していませんが、ソースから宛先への言語ロケールを設定します。そのようなプロパティは、翻訳用に送信されません。
UI では、言語コードを値として持つ特定のプロパティについてのみ、「プロパティ」タブで「翻訳」をチェックまたはチェック解除できます。
updateDestinationLanguage
と translate
の違いを明確にするために、ルールが 2 つのみのコンテキストの単純な例を次に示します。
xml での結果は、次のようになります。
<property inherit="true" name="text" translate="true" updateDestinationLanguage="false"/>
<property inherit="true" name="jcr:language" translate="false" updateDestinationLanguage="true"/>
AEM と共にインストールされる translation_rules.xml ファイルには、デフォルトの翻訳ルールセットが格納されています。翻訳プロジェクトの要件をサポートするようにこのファイルを編集できます。例えば、カスタムコンポーネントのコンテンツが翻訳されるようなルールを追加できます。
translation_rules.xml ファイルを編集する場合、バックアップコピーをコンテンツパッケージに保持します。 AEMサービスパックをインストールするか、特定のAEMパッケージを再インストールすると、現在の translation_rules.xml ファイルが元のファイルに置き換えられます。 この状況でルールを復元するには、バックアップコピーを含むパッケージをインストールします。
コンテンツパッケージを作成した後は、ファイルを編集するたびにパッケージを再ビルドしてください。
<nodelist>
<!-- translation rules for Geometrixx Demo site (example) -->
<node path="/content/geometrixx">
<!-- list all node properties that should be translated -->
<property name="jcr:title" /> <!-- translation workflows running on content saved in /content/geometrixx, will extract jcr:title values independent of the component. -->
<property name="jcr:description" />
<node resourceType ="foundation/components/image"> <!-- translation workflows running on content saved in /content/geometrixx, will extract alternateText values only for Image component. -->
<property name="alternateText"/>
</node>
<node resourceType ="geometrixx/components/title">
<property name="richText"/>
<property name="jcr:title" translate="false"/> <!-- translation workflows running on content saved in /content/geometrixx, will not extract jcr:title for Title component, but instead use richText. -->
</node>
<node pathContains="/cq:annotations">
<property name="text" translate="false"/> <!-- translation workflows running on content saved in /content/geometrixx, will not extract text if part of cq:annotations node. -->
</node>
</node>
<!-- translation rules for Geometrixx Outdoors site (example) -->
<node path="/content/geometrixx-outdoors">
<node resourceType ="foundation/components/image">
<property name="alternateText"/>
<property name="jcr:title" />
</node>
<node resourceType ="geometrixx-outdoors/components/title">
<property name="richText"/>
</node>
</node>
<!-- translation rules for ASSETS (example) -->
<node path="/content/dam">
<!-- configure list of metadata properties here -->
<property name="dc:title" />
<property name="dc:description" />
</node>
<!-- translation rules for extracting ASSETS from SITES content, configure all components that embed or reference assets -->
<assetNode resourceType="foundation/components/image" assetReferenceAttribute="fileReference"/>
<assetNode resourceType="foundation/components/video" assetReferenceAttribute="asset"/>
<assetNode resourceType="foundation/components/download" assetReferenceAttribute="fileReference"/>
<assetNode resourceType="foundation/components/mobileimage" assetReferenceAttribute="fileReference"/>
<assetNode resourceType="wcm/foundation/components/image" assetReferenceAttribute="fileReference"/>
</nodelist>