翻訳するコンテンツの特定 identifying-content-to-translate

翻訳ルールは、翻訳プロジェクトに含まれる(または翻訳プロジェクトから除外される)ページ、コンポーネントおよびアセットについて、翻訳対象のコンテンツを特定します。 ページまたはアセットの翻訳中に、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

このファイルはすべての翻訳プロジェクトに適用されます。

NOTE
6.4にアップグレードした後、ファイルを/etcから移動することをお勧めします。詳しくは、AEM 6.5での共通リポジトリの再構築を参照してください。

ルールには以下の情報が含まれます。

  • ルールが適用されるノードのパス. ノードの子ノードにもルールが適用されます。
  • 翻訳するコンテンツを格納するノードプロパティの名前。 このプロパティは、特定のリソースタイプに固有のものでも、すべてのリソースタイプに固有のものでもかまいません。

例えば、ページ上のすべての AEM 基盤テキストコンポーネントに作成者が追加するコンテンツを翻訳するルールを作成できます。 このルールでは、/content ノードと foundation/components/text コンポーネントの text プロパティを識別できます。

翻訳ルールの設定用に追加されたコンソールがあります。 UI での定義の内容がファイルに自動的に入力されます。

AEM のコンテンツ翻訳機能の概要については、多言語サイトのコンテンツの翻訳を参照してください。

NOTE
AEM は、ページ上の参照コンテンツの翻訳に関して、リソースタイプと参照属性の 1 対 1 マッピングをサポートしています。

ページ、コンポーネントおよびアセット用のルールの構文 rule-syntax-for-pages-components-and-assets

ルールとは、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>

ページからアセットを抽出するルールの構文 rule-syntax-for-extracting-assets-from-pages

次に示すルールの構文を使用して、コンポーネントに埋め込むアセットまたはコンポーネントから参照するアセットを追加します。

<assetNode resourceType="path to component" assetReferenceAttribute="property that stores asset"/>

assetNode 要素には以下の特徴があります。

  • 1 つの resourceType 属性は、コンポーネントに解決されるパスと等しくなります。
  • 1 つの assetReferenceAttribute 属性は、(埋め込みアセット用の)アセットバイナリを格納するプロパティの名前または参照先のアセットのパスと等しくなります。

次の例では、基盤画像コンポーネントから画像を抽出します。

<assetNode resourceType="foundation/components/image" assetReferenceAttribute="fileReference"/>

ルールの上書き overriding-rules

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>

プロパティのフィルタリング filtering-properties

filter 要素を使用して、特定のプロパティを持つノードをフィルタリングできます。

例えば、次のルールを使用すると、プロパティ textdraft に設定されている場合を除き、true プロパティのすべてのコンテンツが翻訳されます。

<nodelist>
    <node path="/content">
     <filter>
   <node containsProperty="draft" propertyValue="true" />
     </filter>
        <property name="text" />
    </node>
<nodelist>

翻訳ルール UI translation-rules-ui

コンソールを使用して翻訳ルールを設定することもできます。

コンソールにアクセスするには:

  1. ツール一般​に移動します。

    chlimage1-55

  2. 翻訳設定」を選択します。

    chlimage1-56

ここから、コンテキストを追加​できます。 これにより、パスを追加できます。

chlimage1-57

次に、コンテキストを選択して「編集」をクリックする必要があります。 翻訳ルールエディターが開きます。

chlimage1-58

この UI では、4 つの属性(isDeepinherittranslate および updateDestinationLanguage)を変更できます。

isDeep​この属性はノードフィルターに適用され、デフォルトではtrueです。 ノード(またはその上位ノード)に、フィルターで指定されたプロパティ値を持つそのプロパティが含まれているかどうかをチェックします。 false の場合は、現在のノードのみでチェックします。

例えば、ドラフトコンテンツであることを示すために親ノードの draftOnly プロパティが true に設定されている場合でも、子ノードは翻訳ジョブに追加されます。 isDeepは、親ノードがプロパティ draftOnlyをtrueとして持っているかどうかを確認し、それらの子ノードを除外します。

エディターでは、「フィルター」タブで「サブ項目の有無」をチェックまたはチェック解除できます。

chlimage1-59

次に、UI で「サブ項目の有無」をチェック解除した場合の結果の xml の例を示します。

 <filter>
    <node containsProperty="draftOnly" isDeep="false" propertyValue="true"/>
</filter>

inherit​これはプロパティに適用されます。 デフォルトでは、すべてのプロパティは継承されますが、プロパティを子に継承させない場合は、そのプロパティをfalseにマークして、その特定のノードにのみ適用することができます。

UI では、「プロパティ」タブで「継承」をチェックまたはチェック解除できます。

chlimage1-60

translate:translate 属性は、単純にプロパティを翻訳するかどうかを指定するために使用されます。

UI では、「プロパティ」タブで「翻訳」をチェックまたはチェック解除できます。

updateDestinationLanguage​この属性は、jcr:languageなどの言語コード以外のテキストを持つプロパティに使用されます。 ユーザーはテキストを翻訳するのではなく、言語ロケールをソースから宛先に翻訳します。 そのようなプロパティは、翻訳用に送信されません。

UI では、言語コードを値として持つ特定のプロパティについてのみ、「プロパティ」タブで「翻訳」をチェックまたはチェック解除できます。

updateDestinationLanguagetranslate の違いを明確にするために、ルールが 2 つのみのコンテキストの単純な例を次に示します。

chlimage1-61

xml での結果は、以下のようになります。

<property inherit="true" name="text" translate="true" updateDestinationLanguage="false"/>
<property inherit="true" name="jcr:language" translate="false" updateDestinationLanguage="true"/>

ルールファイルの手動編集 editing-the-rules-file-manually

AEMと共にインストールされるtranslation_rules.xml ファイルには、デフォルトの翻訳ルールのセットが含まれています。 翻訳プロジェクトの要件をサポートするように、このファイルを編集できます。 例えば、カスタムコンポーネントのコンテンツが翻訳されるように、ルールを追加できます。

translation_rules.xml ファイルを編集する場合は、バックアップコピーをコンテンツパッケージに保存しておきます。 AEM サービスパックをインストールするか、特定の AEM パッケージを再インストールすると、現在の translation_rules.xml ファイルが元のファイルに置き換えられることがあります。 この状況でルールを復元するには、バックアップコピーを含むパッケージをインストールします。

NOTE
コンテンツパッケージを作成した後は、ファイルを編集するたびにパッケージを再作成してください。

翻訳ルールファイルの例 example-translation-rules-file

<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>
recommendation-more-help
experience-manager-65-help-main-toc