Spec-Zone.ru › Angular

Работа с файлами переводов

После подготовки компонента к переводу используйте команду extract-i18n Angular CLI, чтобы извлечь отмеченный текст компонента в файл на исходном языке.

К отмеченному тексту относятся текст, отмеченный с помощью i18n, атрибуты, отмеченные с помощью i18n-attribute, и текст, помеченный с помощью $localize, как описано в разделе Подготовка компонента к переводу.

Выполните следующие действия, чтобы создать и обновить файлы переводов для своего проекта.

  1. Извлеките файл на исходном языке.
    1. При необходимости измените расположение, формат и имя файла.
  2. Скопируйте файл на исходном языке, чтобы создать файл перевода для каждого языка.
  3. Переведите каждый файл перевода.
  4. Переводите формы множественного числа и альтернативные выражения отдельно.
    1. Переведите формы множественного числа.
    2. Переведите альтернативные выражения.
    3. Переведите вложенные выражения.

Извлечение файла на исходном языке

Чтобы извлечь файл на исходном языке, выполните следующие действия.

  1. Откройте окно терминала.
  2. Перейдите в корневой каталог проекта.
  3. Выполните следующую команду CLI.
ng extract-i18n

Команда extract-i18n создает файл на исходном языке с именем messages.xlf в корневом каталоге проекта. Дополнительные сведения о формате XML Localization Interchange File Format (XLIFF, версия 1.2) см. в статье XLIFF.

Используйте следующие параметры команды extract-i18n, чтобы изменить расположение, формат и имя файла на исходном языке.

Параметр команды Описание
--format Задает формат выходного файла
--out-file Задает имя выходного файла
--output-path Задает путь к выходному каталогу

Изменение расположения файла на исходном языке

Чтобы создать файл в каталоге src/locale, укажите путь вывода в качестве параметра.

Пример extract-i18n --output-path

В следующем примере путь вывода задается в качестве параметра.

ng extract-i18n --output-path src/locale

Изменение формата файла на исходном языке

Команда extract-i18n создает файлы в следующих форматах перевода.

Формат перевода Описание Расширение файла
ARB Пакет ресурсов приложения .arb
JSON Нотация объектов JavaScript .json
XLIFF 1.2 Формат XML Localization Interchange File Format, версия 1.2 .xlf
XLIFF 2 Формат XML Localization Interchange File Format, версия 2 .xlf
XMB Пакет сообщений XML .xmb (.xtb)

Явно укажите формат перевода с помощью параметра команды --format.

ПОЛЕЗНО: Формат XMB создает файлы на исходном языке .xmb, но использует файлы переводов .xtb.

Пример extract-i18n --format

В следующем примере показано несколько форматов перевода.

ng extract-i18n --format=xlf
ng extract-i18n --format=xlf2
ng extract-i18n --format=xmb
ng extract-i18n --format=json
ng extract-i18n --format=arb

Изменение имени файла на исходном языке

Чтобы изменить имя файла на исходном языке, созданного инструментом извлечения, используйте параметр команды --out-file.

Пример extract-i18n --out-file

В следующем примере показано, как задать имя выходного файла.

ng extract-i18n --out-file source.xlf

Создание файла перевода для каждого языка

Чтобы создать файл перевода для локали или языка, выполните следующие действия.

  1. Извлеките файл на исходном языке.

  2. Создайте копию файла на исходном языке, чтобы получить файл перевода для каждого языка.

  3. Переименуйте файл перевода, добавив обозначение локали.

    messages.xlf --> messages.{locale}.xlf
  4. Создайте в корневом каталоге проекта новый каталог с именем locale.

    src/locale
  5. Переместите файл перевода в новый каталог.

  6. Отправьте файл перевода переводчику.

  7. Повторите описанные выше действия для каждого языка, который хотите добавить в приложение.

Пример extract-i18n для французского языка

Например, чтобы создать файл перевода на французский язык, выполните следующие действия.

  1. Выполните команду extract-i18n.
  2. Создайте копию файла на исходном языке messages.xlf.
  3. Переименуйте копию в messages.fr.xlf для перевода на французский язык (fr).
  4. Переместите файл перевода fr в каталог src/locale.
  5. Отправьте файл перевода fr переводчику.

Перевод каждого файла перевода

Если вы не владеете языком в совершенстве или у вас нет времени на редактирование переводов, скорее всего, вам потребуется выполнить следующие действия.

  1. Отправьте каждый файл перевода переводчику.
  2. Переводчик использует редактор файлов XLIFF, чтобы выполнить следующие действия.
    1. Создать перевод.
    2. Отредактировать перевод.

Пример процесса перевода на французский язык

Чтобы ознакомиться с процессом, изучите файл messages.fr.xlf в примере приложения Angular для интернационализации. В примере приложения Angular для интернационализации есть французский перевод, который можно отредактировать без специального редактора XLIFF и знания французского языка.

Ниже описан процесс перевода на французский язык.

  1. Откройте messages.fr.xlf и найдите первый элемент <trans-unit>. Это единица перевода, также известная как текстовый узел, который представляет перевод тега приветствия <h1>, ранее отмеченного атрибутом i18n.

    <!-- The `messages.fr.xlf` after translation for documentation purposes -->
    <!-- #docregion -->
    <?xml version="1.0" encoding="UTF-8" ?>
    <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
      <file source-language="en" datatype="plaintext" original="ng2.template">
        <body>
          <!-- #docregion translated-hello-before -->
          <trans-unit id="introductionHeader" datatype="html">
            <source>Hello i18n!</source>
            <note priority="1" from="description">An introduction header for this sample</note>
            <note priority="1" from="meaning">User welcome</note>
          </trans-unit>
          <!-- #enddocregion translated-hello-before -->
          <!-- #docregion translated-hello -->
          <!-- #docregion custom-id -->
          <trans-unit id="introductionHeader" datatype="html">
          <!-- #enddocregion custom-id -->
            <source>Hello i18n!</source>
            <target>Bonjour i18n !</target>
            <note priority="1" from="description">An introduction header for this sample</note>
            <note priority="1" from="meaning">User welcome</note>
          </trans-unit>
          <!-- #enddocregion translated-hello -->
          <!-- #docregion translated-other-nodes -->
          <!-- #docregion generated-id -->
          <trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
          <!-- #enddocregion generated-id -->
            <source>I don&apos;t output any element</source>
            <target>Je n'affiche aucun élément</target>
          </trans-unit>
          <trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
            <source>Angular logo</source>
            <target>Logo d'Angular</target>
          </trans-unit>
          <!-- #enddocregion translated-other-nodes -->
          <!-- #docregion translated-plural -->
          <trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
            <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
            <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes} }</target>
          </trans-unit>
          <!-- #enddocregion translated-plural -->
          <!-- #docregion translated-select -->
          <!-- #docregion translate-select-1 -->
          <trans-unit id="f99f34ac9bd4606345071bd813858dec29f3b7d1" datatype="html">
            <source>The author is <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></source>
            <target>L'auteur est <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></target>
          </trans-unit>
          <!-- #enddocregion translate-select-1 -->
          <!-- #docregion translate-select-2 -->
          <trans-unit id="eff74b75ab7364b6fa888f1cbfae901aaaf02295" datatype="html">
            <source>{VAR_SELECT, select, male {male} female {female} other {other} }</source>
            <target>{VAR_SELECT, select, male {un homme} female {une femme} other {autre} }</target>
          </trans-unit>
          <!-- #enddocregion translate-select-2 -->
          <!-- #enddocregion translated-select -->
          <!-- #docregion translate-nested -->
          <!-- #docregion translate-nested-1 -->
          <trans-unit id="972cb0cf3e442f7b1c00d7dab168ac08d6bdf20c" datatype="html">
            <source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
            <target>Mis à jour: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></target>
          </trans-unit>
          <!-- #enddocregion translate-nested-1 -->
          <!-- #docregion translate-nested-2 -->
          <trans-unit id="7151c2e67748b726f0864fc443861d45df21d706" datatype="html">
            <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, male {male} female {female} other {other} }} }</source>
            <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes par {VAR_SELECT, select, male {un homme} female {une femme} other {autre} }} }</target>
          </trans-unit>
          <!-- #enddocregion translate-nested-2 -->
          <!-- #enddocregion translate-nested -->
          <!-- #docregion i18n-duplicate-custom-id -->
          <trans-unit id="myId" datatype="html">
            <source>Hello</source>
            <target state="new">Bonjour</target>
          </trans-unit>
          <!-- #enddocregion i18n-duplicate-custom-id -->
        </body>
      </file>
    </xliff>
    
    

    id="introductionHeader" — это пользовательский идентификатор, но без префикса @@, необходимого в исходном HTML.

  2. Продублируйте элемент <source>... </source> в текстовом узле, переименуйте его в target, а затем замените содержимое французским текстом.

    <!-- The `messages.fr.xlf` after translation for documentation purposes -->
    <!-- #docregion -->
    <?xml version="1.0" encoding="UTF-8" ?>
    <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
      <file source-language="en" datatype="plaintext" original="ng2.template">
        <body>
          <!-- #docregion translated-hello-before -->
          <trans-unit id="introductionHeader" datatype="html">
            <source>Hello i18n!</source>
            <note priority="1" from="description">An introduction header for this sample</note>
            <note priority="1" from="meaning">User welcome</note>
          </trans-unit>
          <!-- #enddocregion translated-hello-before -->
          <!-- #docregion translated-hello -->
          <!-- #docregion custom-id -->
          <trans-unit id="introductionHeader" datatype="html">
          <!-- #enddocregion custom-id -->
            <source>Hello i18n!</source>
            <target>Bonjour i18n !</target>
            <note priority="1" from="description">An introduction header for this sample</note>
            <note priority="1" from="meaning">User welcome</note>
          </trans-unit>
          <!-- #enddocregion translated-hello -->
          <!-- #docregion translated-other-nodes -->
          <!-- #docregion generated-id -->
          <trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
          <!-- #enddocregion generated-id -->
            <source>I don&apos;t output any element</source>
            <target>Je n'affiche aucun élément</target>
          </trans-unit>
          <trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
            <source>Angular logo</source>
            <target>Logo d'Angular</target>
          </trans-unit>
          <!-- #enddocregion translated-other-nodes -->
          <!-- #docregion translated-plural -->
          <trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
            <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
            <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes} }</target>
          </trans-unit>
          <!-- #enddocregion translated-plural -->
          <!-- #docregion translated-select -->
          <!-- #docregion translate-select-1 -->
          <trans-unit id="f99f34ac9bd4606345071bd813858dec29f3b7d1" datatype="html">
            <source>The author is <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></source>
            <target>L'auteur est <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></target>
          </trans-unit>
          <!-- #enddocregion translate-select-1 -->
          <!-- #docregion translate-select-2 -->
          <trans-unit id="eff74b75ab7364b6fa888f1cbfae901aaaf02295" datatype="html">
            <source>{VAR_SELECT, select, male {male} female {female} other {other} }</source>
            <target>{VAR_SELECT, select, male {un homme} female {une femme} other {autre} }</target>
          </trans-unit>
          <!-- #enddocregion translate-select-2 -->
          <!-- #enddocregion translated-select -->
          <!-- #docregion translate-nested -->
          <!-- #docregion translate-nested-1 -->
          <trans-unit id="972cb0cf3e442f7b1c00d7dab168ac08d6bdf20c" datatype="html">
            <source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
            <target>Mis à jour: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></target>
          </trans-unit>
          <!-- #enddocregion translate-nested-1 -->
          <!-- #docregion translate-nested-2 -->
          <trans-unit id="7151c2e67748b726f0864fc443861d45df21d706" datatype="html">
            <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, male {male} female {female} other {other} }} }</source>
            <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes par {VAR_SELECT, select, male {un homme} female {une femme} other {autre} }} }</target>
          </trans-unit>
          <!-- #enddocregion translate-nested-2 -->
          <!-- #enddocregion translate-nested -->
          <!-- #docregion i18n-duplicate-custom-id -->
          <trans-unit id="myId" datatype="html">
            <source>Hello</source>
            <target state="new">Bonjour</target>
          </trans-unit>
          <!-- #enddocregion i18n-duplicate-custom-id -->
        </body>
      </file>
    </xliff>
    
    

    При более сложном переводе сведения и контекст в элементах описания и значения помогут выбрать подходящие слова для перевода.

  3. Переведите остальные текстовые узлы. В следующем примере показано, как выполнять перевод.

    <!-- The `messages.fr.xlf` after translation for documentation purposes -->
    <!-- #docregion -->
    <?xml version="1.0" encoding="UTF-8" ?>
    <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
      <file source-language="en" datatype="plaintext" original="ng2.template">
        <body>
          <!-- #docregion translated-hello-before -->
          <trans-unit id="introductionHeader" datatype="html">
            <source>Hello i18n!</source>
            <note priority="1" from="description">An introduction header for this sample</note>
            <note priority="1" from="meaning">User welcome</note>
          </trans-unit>
          <!-- #enddocregion translated-hello-before -->
          <!-- #docregion translated-hello -->
          <!-- #docregion custom-id -->
          <trans-unit id="introductionHeader" datatype="html">
          <!-- #enddocregion custom-id -->
            <source>Hello i18n!</source>
            <target>Bonjour i18n !</target>
            <note priority="1" from="description">An introduction header for this sample</note>
            <note priority="1" from="meaning">User welcome</note>
          </trans-unit>
          <!-- #enddocregion translated-hello -->
          <!-- #docregion translated-other-nodes -->
          <!-- #docregion generated-id -->
          <trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
          <!-- #enddocregion generated-id -->
            <source>I don&apos;t output any element</source>
            <target>Je n'affiche aucun élément</target>
          </trans-unit>
          <trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
            <source>Angular logo</source>
            <target>Logo d'Angular</target>
          </trans-unit>
          <!-- #enddocregion translated-other-nodes -->
          <!-- #docregion translated-plural -->
          <trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
            <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
            <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes} }</target>
          </trans-unit>
          <!-- #enddocregion translated-plural -->
          <!-- #docregion translated-select -->
          <!-- #docregion translate-select-1 -->
          <trans-unit id="f99f34ac9bd4606345071bd813858dec29f3b7d1" datatype="html">
            <source>The author is <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></source>
            <target>L'auteur est <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></target>
          </trans-unit>
          <!-- #enddocregion translate-select-1 -->
          <!-- #docregion translate-select-2 -->
          <trans-unit id="eff74b75ab7364b6fa888f1cbfae901aaaf02295" datatype="html">
            <source>{VAR_SELECT, select, male {male} female {female} other {other} }</source>
            <target>{VAR_SELECT, select, male {un homme} female {une femme} other {autre} }</target>
          </trans-unit>
          <!-- #enddocregion translate-select-2 -->
          <!-- #enddocregion translated-select -->
          <!-- #docregion translate-nested -->
          <!-- #docregion translate-nested-1 -->
          <trans-unit id="972cb0cf3e442f7b1c00d7dab168ac08d6bdf20c" datatype="html">
            <source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
            <target>Mis à jour: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></target>
          </trans-unit>
          <!-- #enddocregion translate-nested-1 -->
          <!-- #docregion translate-nested-2 -->
          <trans-unit id="7151c2e67748b726f0864fc443861d45df21d706" datatype="html">
            <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, male {male} female {female} other {other} }} }</source>
            <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes par {VAR_SELECT, select, male {un homme} female {une femme} other {autre} }} }</target>
          </trans-unit>
          <!-- #enddocregion translate-nested-2 -->
          <!-- #enddocregion translate-nested -->
          <!-- #docregion i18n-duplicate-custom-id -->
          <trans-unit id="myId" datatype="html">
            <source>Hello</source>
            <target state="new">Bonjour</target>
          </trans-unit>
          <!-- #enddocregion i18n-duplicate-custom-id -->
        </body>
      </file>
    </xliff>
    
    

ВАЖНО: Не изменяйте идентификаторы единиц перевода. Каждый атрибут id создается Angular и зависит от содержимого текста компонента и назначенного значения.

Если вы измените текст или значение, атрибут id изменится. Подробнее об управлении обновлениями текста и идентификаторами см. в разделе Пользовательские идентификаторы.

Перевод форм множественного числа

Добавляйте или удаляйте формы множественного числа по мере необходимости для каждого языка.

ПОЛЕЗНО: Правила образования форм множественного числа для языков см. в разделе Правила CLDR для форм множественного числа.

Пример форм множественного числа для минут

Чтобы перевести plural, переведите значения сопоставления формата ICU.

  • just now
  • one minute ago
  • <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago

В следующем примере показано, как выполнять перевод.

<!-- The `messages.fr.xlf` after translation for documentation purposes -->
<!-- #docregion -->
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file source-language="en" datatype="plaintext" original="ng2.template">
    <body>
      <!-- #docregion translated-hello-before -->
      <trans-unit id="introductionHeader" datatype="html">
        <source>Hello i18n!</source>
        <note priority="1" from="description">An introduction header for this sample</note>
        <note priority="1" from="meaning">User welcome</note>
      </trans-unit>
      <!-- #enddocregion translated-hello-before -->
      <!-- #docregion translated-hello -->
      <!-- #docregion custom-id -->
      <trans-unit id="introductionHeader" datatype="html">
      <!-- #enddocregion custom-id -->
        <source>Hello i18n!</source>
        <target>Bonjour i18n !</target>
        <note priority="1" from="description">An introduction header for this sample</note>
        <note priority="1" from="meaning">User welcome</note>
      </trans-unit>
      <!-- #enddocregion translated-hello -->
      <!-- #docregion translated-other-nodes -->
      <!-- #docregion generated-id -->
      <trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
      <!-- #enddocregion generated-id -->
        <source>I don&apos;t output any element</source>
        <target>Je n'affiche aucun élément</target>
      </trans-unit>
      <trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
        <source>Angular logo</source>
        <target>Logo d'Angular</target>
      </trans-unit>
      <!-- #enddocregion translated-other-nodes -->
      <!-- #docregion translated-plural -->
      <trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
        <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
        <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes} }</target>
      </trans-unit>
      <!-- #enddocregion translated-plural -->
      <!-- #docregion translated-select -->
      <!-- #docregion translate-select-1 -->
      <trans-unit id="f99f34ac9bd4606345071bd813858dec29f3b7d1" datatype="html">
        <source>The author is <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></source>
        <target>L'auteur est <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></target>
      </trans-unit>
      <!-- #enddocregion translate-select-1 -->
      <!-- #docregion translate-select-2 -->
      <trans-unit id="eff74b75ab7364b6fa888f1cbfae901aaaf02295" datatype="html">
        <source>{VAR_SELECT, select, male {male} female {female} other {other} }</source>
        <target>{VAR_SELECT, select, male {un homme} female {une femme} other {autre} }</target>
      </trans-unit>
      <!-- #enddocregion translate-select-2 -->
      <!-- #enddocregion translated-select -->
      <!-- #docregion translate-nested -->
      <!-- #docregion translate-nested-1 -->
      <trans-unit id="972cb0cf3e442f7b1c00d7dab168ac08d6bdf20c" datatype="html">
        <source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
        <target>Mis à jour: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></target>
      </trans-unit>
      <!-- #enddocregion translate-nested-1 -->
      <!-- #docregion translate-nested-2 -->
      <trans-unit id="7151c2e67748b726f0864fc443861d45df21d706" datatype="html">
        <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, male {male} female {female} other {other} }} }</source>
        <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes par {VAR_SELECT, select, male {un homme} female {une femme} other {autre} }} }</target>
      </trans-unit>
      <!-- #enddocregion translate-nested-2 -->
      <!-- #enddocregion translate-nested -->
      <!-- #docregion i18n-duplicate-custom-id -->
      <trans-unit id="myId" datatype="html">
        <source>Hello</source>
        <target state="new">Bonjour</target>
      </trans-unit>
      <!-- #enddocregion i18n-duplicate-custom-id -->
    </body>
  </file>
</xliff>

Перевод альтернативных выражений

Angular также извлекает альтернативные выражения ICU select как отдельные единицы перевода.

Пример выбора по полу

В следующем примере показано выражение ICU select в шаблоне компонента.

<span i18n>The author is {gender, select, male {male} female {female} other {other}}</span>

В этом примере Angular извлекает выражение в виде двух единиц перевода. Первая содержит текст вне конструкции select и использует заполнитель для select (<x id="ICU">):

<!-- The `messages.fr.xlf` after translation for documentation purposes -->
<!-- #docregion -->
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file source-language="en" datatype="plaintext" original="ng2.template">
    <body>
      <!-- #docregion translated-hello-before -->
      <trans-unit id="introductionHeader" datatype="html">
        <source>Hello i18n!</source>
        <note priority="1" from="description">An introduction header for this sample</note>
        <note priority="1" from="meaning">User welcome</note>
      </trans-unit>
      <!-- #enddocregion translated-hello-before -->
      <!-- #docregion translated-hello -->
      <!-- #docregion custom-id -->
      <trans-unit id="introductionHeader" datatype="html">
      <!-- #enddocregion custom-id -->
        <source>Hello i18n!</source>
        <target>Bonjour i18n !</target>
        <note priority="1" from="description">An introduction header for this sample</note>
        <note priority="1" from="meaning">User welcome</note>
      </trans-unit>
      <!-- #enddocregion translated-hello -->
      <!-- #docregion translated-other-nodes -->
      <!-- #docregion generated-id -->
      <trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
      <!-- #enddocregion generated-id -->
        <source>I don&apos;t output any element</source>
        <target>Je n'affiche aucun élément</target>
      </trans-unit>
      <trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
        <source>Angular logo</source>
        <target>Logo d'Angular</target>
      </trans-unit>
      <!-- #enddocregion translated-other-nodes -->
      <!-- #docregion translated-plural -->
      <trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
        <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
        <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes} }</target>
      </trans-unit>
      <!-- #enddocregion translated-plural -->
      <!-- #docregion translated-select -->
      <!-- #docregion translate-select-1 -->
      <trans-unit id="f99f34ac9bd4606345071bd813858dec29f3b7d1" datatype="html">
        <source>The author is <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></source>
        <target>L'auteur est <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></target>
      </trans-unit>
      <!-- #enddocregion translate-select-1 -->
      <!-- #docregion translate-select-2 -->
      <trans-unit id="eff74b75ab7364b6fa888f1cbfae901aaaf02295" datatype="html">
        <source>{VAR_SELECT, select, male {male} female {female} other {other} }</source>
        <target>{VAR_SELECT, select, male {un homme} female {une femme} other {autre} }</target>
      </trans-unit>
      <!-- #enddocregion translate-select-2 -->
      <!-- #enddocregion translated-select -->
      <!-- #docregion translate-nested -->
      <!-- #docregion translate-nested-1 -->
      <trans-unit id="972cb0cf3e442f7b1c00d7dab168ac08d6bdf20c" datatype="html">
        <source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
        <target>Mis à jour: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></target>
      </trans-unit>
      <!-- #enddocregion translate-nested-1 -->
      <!-- #docregion translate-nested-2 -->
      <trans-unit id="7151c2e67748b726f0864fc443861d45df21d706" datatype="html">
        <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, male {male} female {female} other {other} }} }</source>
        <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes par {VAR_SELECT, select, male {un homme} female {une femme} other {autre} }} }</target>
      </trans-unit>
      <!-- #enddocregion translate-nested-2 -->
      <!-- #enddocregion translate-nested -->
      <!-- #docregion i18n-duplicate-custom-id -->
      <trans-unit id="myId" datatype="html">
        <source>Hello</source>
        <target state="new">Bonjour</target>
      </trans-unit>
      <!-- #enddocregion i18n-duplicate-custom-id -->
    </body>
  </file>
</xliff>

ВАЖНО: При переводе текста переместите заполнитель, если это необходимо, но не удаляйте его. Если удалить заполнитель, выражение ICU будет удалено из переведенного приложения.

В следующем примере показана вторая единица перевода, содержащая конструкцию select.

<!-- The `messages.fr.xlf` after translation for documentation purposes -->
<!-- #docregion -->
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file source-language="en" datatype="plaintext" original="ng2.template">
    <body>
      <!-- #docregion translated-hello-before -->
      <trans-unit id="introductionHeader" datatype="html">
        <source>Hello i18n!</source>
        <note priority="1" from="description">An introduction header for this sample</note>
        <note priority="1" from="meaning">User welcome</note>
      </trans-unit>
      <!-- #enddocregion translated-hello-before -->
      <!-- #docregion translated-hello -->
      <!-- #docregion custom-id -->
      <trans-unit id="introductionHeader" datatype="html">
      <!-- #enddocregion custom-id -->
        <source>Hello i18n!</source>
        <target>Bonjour i18n !</target>
        <note priority="1" from="description">An introduction header for this sample</note>
        <note priority="1" from="meaning">User welcome</note>
      </trans-unit>
      <!-- #enddocregion translated-hello -->
      <!-- #docregion translated-other-nodes -->
      <!-- #docregion generated-id -->
      <trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
      <!-- #enddocregion generated-id -->
        <source>I don&apos;t output any element</source>
        <target>Je n'affiche aucun élément</target>
      </trans-unit>
      <trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
        <source>Angular logo</source>
        <target>Logo d'Angular</target>
      </trans-unit>
      <!-- #enddocregion translated-other-nodes -->
      <!-- #docregion translated-plural -->
      <trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
        <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
        <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes} }</target>
      </trans-unit>
      <!-- #enddocregion translated-plural -->
      <!-- #docregion translated-select -->
      <!-- #docregion translate-select-1 -->
      <trans-unit id="f99f34ac9bd4606345071bd813858dec29f3b7d1" datatype="html">
        <source>The author is <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></source>
        <target>L'auteur est <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></target>
      </trans-unit>
      <!-- #enddocregion translate-select-1 -->
      <!-- #docregion translate-select-2 -->
      <trans-unit id="eff74b75ab7364b6fa888f1cbfae901aaaf02295" datatype="html">
        <source>{VAR_SELECT, select, male {male} female {female} other {other} }</source>
        <target>{VAR_SELECT, select, male {un homme} female {une femme} other {autre} }</target>
      </trans-unit>
      <!-- #enddocregion translate-select-2 -->
      <!-- #enddocregion translated-select -->
      <!-- #docregion translate-nested -->
      <!-- #docregion translate-nested-1 -->
      <trans-unit id="972cb0cf3e442f7b1c00d7dab168ac08d6bdf20c" datatype="html">
        <source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
        <target>Mis à jour: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></target>
      </trans-unit>
      <!-- #enddocregion translate-nested-1 -->
      <!-- #docregion translate-nested-2 -->
      <trans-unit id="7151c2e67748b726f0864fc443861d45df21d706" datatype="html">
        <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, male {male} female {female} other {other} }} }</source>
        <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes par {VAR_SELECT, select, male {un homme} female {une femme} other {autre} }} }</target>
      </trans-unit>
      <!-- #enddocregion translate-nested-2 -->
      <!-- #enddocregion translate-nested -->
      <!-- #docregion i18n-duplicate-custom-id -->
      <trans-unit id="myId" datatype="html">
        <source>Hello</source>
        <target state="new">Bonjour</target>
      </trans-unit>
      <!-- #enddocregion i18n-duplicate-custom-id -->
    </body>
  </file>
</xliff>

В следующем примере показаны обе единицы перевода после завершения перевода.

<!-- The `messages.fr.xlf` after translation for documentation purposes -->
<!-- #docregion -->
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file source-language="en" datatype="plaintext" original="ng2.template">
    <body>
      <!-- #docregion translated-hello-before -->
      <trans-unit id="introductionHeader" datatype="html">
        <source>Hello i18n!</source>
        <note priority="1" from="description">An introduction header for this sample</note>
        <note priority="1" from="meaning">User welcome</note>
      </trans-unit>
      <!-- #enddocregion translated-hello-before -->
      <!-- #docregion translated-hello -->
      <!-- #docregion custom-id -->
      <trans-unit id="introductionHeader" datatype="html">
      <!-- #enddocregion custom-id -->
        <source>Hello i18n!</source>
        <target>Bonjour i18n !</target>
        <note priority="1" from="description">An introduction header for this sample</note>
        <note priority="1" from="meaning">User welcome</note>
      </trans-unit>
      <!-- #enddocregion translated-hello -->
      <!-- #docregion translated-other-nodes -->
      <!-- #docregion generated-id -->
      <trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
      <!-- #enddocregion generated-id -->
        <source>I don&apos;t output any element</source>
        <target>Je n'affiche aucun élément</target>
      </trans-unit>
      <trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
        <source>Angular logo</source>
        <target>Logo d'Angular</target>
      </trans-unit>
      <!-- #enddocregion translated-other-nodes -->
      <!-- #docregion translated-plural -->
      <trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
        <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
        <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes} }</target>
      </trans-unit>
      <!-- #enddocregion translated-plural -->
      <!-- #docregion translated-select -->
      <!-- #docregion translate-select-1 -->
      <trans-unit id="f99f34ac9bd4606345071bd813858dec29f3b7d1" datatype="html">
        <source>The author is <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></source>
        <target>L'auteur est <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></target>
      </trans-unit>
      <!-- #enddocregion translate-select-1 -->
      <!-- #docregion translate-select-2 -->
      <trans-unit id="eff74b75ab7364b6fa888f1cbfae901aaaf02295" datatype="html">
        <source>{VAR_SELECT, select, male {male} female {female} other {other} }</source>
        <target>{VAR_SELECT, select, male {un homme} female {une femme} other {autre} }</target>
      </trans-unit>
      <!-- #enddocregion translate-select-2 -->
      <!-- #enddocregion translated-select -->
      <!-- #docregion translate-nested -->
      <!-- #docregion translate-nested-1 -->
      <trans-unit id="972cb0cf3e442f7b1c00d7dab168ac08d6bdf20c" datatype="html">
        <source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
        <target>Mis à jour: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></target>
      </trans-unit>
      <!-- #enddocregion translate-nested-1 -->
      <!-- #docregion translate-nested-2 -->
      <trans-unit id="7151c2e67748b726f0864fc443861d45df21d706" datatype="html">
        <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, male {male} female {female} other {other} }} }</source>
        <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes par {VAR_SELECT, select, male {un homme} female {une femme} other {autre} }} }</target>
      </trans-unit>
      <!-- #enddocregion translate-nested-2 -->
      <!-- #enddocregion translate-nested -->
      <!-- #docregion i18n-duplicate-custom-id -->
      <trans-unit id="myId" datatype="html">
        <source>Hello</source>
        <target state="new">Bonjour</target>
      </trans-unit>
      <!-- #enddocregion i18n-duplicate-custom-id -->
    </body>
  </file>
</xliff>

Перевод вложенных выражений

Angular обрабатывает вложенное выражение так же, как альтернативное. Angular извлекает выражение в виде двух единиц перевода.

Пример вложенной формы множественного числа

В следующем примере показана первая единица перевода, содержащая текст вне вложенного выражения.

<!-- The `messages.fr.xlf` after translation for documentation purposes -->
<!-- #docregion -->
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file source-language="en" datatype="plaintext" original="ng2.template">
    <body>
      <!-- #docregion translated-hello-before -->
      <trans-unit id="introductionHeader" datatype="html">
        <source>Hello i18n!</source>
        <note priority="1" from="description">An introduction header for this sample</note>
        <note priority="1" from="meaning">User welcome</note>
      </trans-unit>
      <!-- #enddocregion translated-hello-before -->
      <!-- #docregion translated-hello -->
      <!-- #docregion custom-id -->
      <trans-unit id="introductionHeader" datatype="html">
      <!-- #enddocregion custom-id -->
        <source>Hello i18n!</source>
        <target>Bonjour i18n !</target>
        <note priority="1" from="description">An introduction header for this sample</note>
        <note priority="1" from="meaning">User welcome</note>
      </trans-unit>
      <!-- #enddocregion translated-hello -->
      <!-- #docregion translated-other-nodes -->
      <!-- #docregion generated-id -->
      <trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
      <!-- #enddocregion generated-id -->
        <source>I don&apos;t output any element</source>
        <target>Je n'affiche aucun élément</target>
      </trans-unit>
      <trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
        <source>Angular logo</source>
        <target>Logo d'Angular</target>
      </trans-unit>
      <!-- #enddocregion translated-other-nodes -->
      <!-- #docregion translated-plural -->
      <trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
        <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
        <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes} }</target>
      </trans-unit>
      <!-- #enddocregion translated-plural -->
      <!-- #docregion translated-select -->
      <!-- #docregion translate-select-1 -->
      <trans-unit id="f99f34ac9bd4606345071bd813858dec29f3b7d1" datatype="html">
        <source>The author is <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></source>
        <target>L'auteur est <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></target>
      </trans-unit>
      <!-- #enddocregion translate-select-1 -->
      <!-- #docregion translate-select-2 -->
      <trans-unit id="eff74b75ab7364b6fa888f1cbfae901aaaf02295" datatype="html">
        <source>{VAR_SELECT, select, male {male} female {female} other {other} }</source>
        <target>{VAR_SELECT, select, male {un homme} female {une femme} other {autre} }</target>
      </trans-unit>
      <!-- #enddocregion translate-select-2 -->
      <!-- #enddocregion translated-select -->
      <!-- #docregion translate-nested -->
      <!-- #docregion translate-nested-1 -->
      <trans-unit id="972cb0cf3e442f7b1c00d7dab168ac08d6bdf20c" datatype="html">
        <source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
        <target>Mis à jour: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></target>
      </trans-unit>
      <!-- #enddocregion translate-nested-1 -->
      <!-- #docregion translate-nested-2 -->
      <trans-unit id="7151c2e67748b726f0864fc443861d45df21d706" datatype="html">
        <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, male {male} female {female} other {other} }} }</source>
        <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes par {VAR_SELECT, select, male {un homme} female {une femme} other {autre} }} }</target>
      </trans-unit>
      <!-- #enddocregion translate-nested-2 -->
      <!-- #enddocregion translate-nested -->
      <!-- #docregion i18n-duplicate-custom-id -->
      <trans-unit id="myId" datatype="html">
        <source>Hello</source>
        <target state="new">Bonjour</target>
      </trans-unit>
      <!-- #enddocregion i18n-duplicate-custom-id -->
    </body>
  </file>
</xliff>

В следующем примере показана вторая единица перевода, содержащая полное вложенное выражение.

<!-- The `messages.fr.xlf` after translation for documentation purposes -->
<!-- #docregion -->
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file source-language="en" datatype="plaintext" original="ng2.template">
    <body>
      <!-- #docregion translated-hello-before -->
      <trans-unit id="introductionHeader" datatype="html">
        <source>Hello i18n!</source>
        <note priority="1" from="description">An introduction header for this sample</note>
        <note priority="1" from="meaning">User welcome</note>
      </trans-unit>
      <!-- #enddocregion translated-hello-before -->
      <!-- #docregion translated-hello -->
      <!-- #docregion custom-id -->
      <trans-unit id="introductionHeader" datatype="html">
      <!-- #enddocregion custom-id -->
        <source>Hello i18n!</source>
        <target>Bonjour i18n !</target>
        <note priority="1" from="description">An introduction header for this sample</note>
        <note priority="1" from="meaning">User welcome</note>
      </trans-unit>
      <!-- #enddocregion translated-hello -->
      <!-- #docregion translated-other-nodes -->
      <!-- #docregion generated-id -->
      <trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
      <!-- #enddocregion generated-id -->
        <source>I don&apos;t output any element</source>
        <target>Je n'affiche aucun élément</target>
      </trans-unit>
      <trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
        <source>Angular logo</source>
        <target>Logo d'Angular</target>
      </trans-unit>
      <!-- #enddocregion translated-other-nodes -->
      <!-- #docregion translated-plural -->
      <trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
        <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
        <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes} }</target>
      </trans-unit>
      <!-- #enddocregion translated-plural -->
      <!-- #docregion translated-select -->
      <!-- #docregion translate-select-1 -->
      <trans-unit id="f99f34ac9bd4606345071bd813858dec29f3b7d1" datatype="html">
        <source>The author is <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></source>
        <target>L'auteur est <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></target>
      </trans-unit>
      <!-- #enddocregion translate-select-1 -->
      <!-- #docregion translate-select-2 -->
      <trans-unit id="eff74b75ab7364b6fa888f1cbfae901aaaf02295" datatype="html">
        <source>{VAR_SELECT, select, male {male} female {female} other {other} }</source>
        <target>{VAR_SELECT, select, male {un homme} female {une femme} other {autre} }</target>
      </trans-unit>
      <!-- #enddocregion translate-select-2 -->
      <!-- #enddocregion translated-select -->
      <!-- #docregion translate-nested -->
      <!-- #docregion translate-nested-1 -->
      <trans-unit id="972cb0cf3e442f7b1c00d7dab168ac08d6bdf20c" datatype="html">
        <source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
        <target>Mis à jour: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></target>
      </trans-unit>
      <!-- #enddocregion translate-nested-1 -->
      <!-- #docregion translate-nested-2 -->
      <trans-unit id="7151c2e67748b726f0864fc443861d45df21d706" datatype="html">
        <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, male {male} female {female} other {other} }} }</source>
        <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes par {VAR_SELECT, select, male {un homme} female {une femme} other {autre} }} }</target>
      </trans-unit>
      <!-- #enddocregion translate-nested-2 -->
      <!-- #enddocregion translate-nested -->
      <!-- #docregion i18n-duplicate-custom-id -->
      <trans-unit id="myId" datatype="html">
        <source>Hello</source>
        <target state="new">Bonjour</target>
      </trans-unit>
      <!-- #enddocregion i18n-duplicate-custom-id -->
    </body>
  </file>
</xliff>

В следующем примере показаны обе единицы перевода после перевода.

<!-- The `messages.fr.xlf` after translation for documentation purposes -->
<!-- #docregion -->
<?xml version="1.0" encoding="UTF-8" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
  <file source-language="en" datatype="plaintext" original="ng2.template">
    <body>
      <!-- #docregion translated-hello-before -->
      <trans-unit id="introductionHeader" datatype="html">
        <source>Hello i18n!</source>
        <note priority="1" from="description">An introduction header for this sample</note>
        <note priority="1" from="meaning">User welcome</note>
      </trans-unit>
      <!-- #enddocregion translated-hello-before -->
      <!-- #docregion translated-hello -->
      <!-- #docregion custom-id -->
      <trans-unit id="introductionHeader" datatype="html">
      <!-- #enddocregion custom-id -->
        <source>Hello i18n!</source>
        <target>Bonjour i18n !</target>
        <note priority="1" from="description">An introduction header for this sample</note>
        <note priority="1" from="meaning">User welcome</note>
      </trans-unit>
      <!-- #enddocregion translated-hello -->
      <!-- #docregion translated-other-nodes -->
      <!-- #docregion generated-id -->
      <trans-unit id="ba0cc104d3d69bf669f97b8d96a4c5d8d9559aa3" datatype="html">
      <!-- #enddocregion generated-id -->
        <source>I don&apos;t output any element</source>
        <target>Je n'affiche aucun élément</target>
      </trans-unit>
      <trans-unit id="701174153757adf13e7c24a248c8a873ac9f5193" datatype="html">
        <source>Angular logo</source>
        <target>Logo d'Angular</target>
      </trans-unit>
      <!-- #enddocregion translated-other-nodes -->
      <!-- #docregion translated-plural -->
      <trans-unit id="5a134dee893586d02bffc9611056b9cadf9abfad" datatype="html">
        <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago} }</source>
        <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes} }</target>
      </trans-unit>
      <!-- #enddocregion translated-plural -->
      <!-- #docregion translated-select -->
      <!-- #docregion translate-select-1 -->
      <trans-unit id="f99f34ac9bd4606345071bd813858dec29f3b7d1" datatype="html">
        <source>The author is <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></source>
        <target>L'auteur est <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></target>
      </trans-unit>
      <!-- #enddocregion translate-select-1 -->
      <!-- #docregion translate-select-2 -->
      <trans-unit id="eff74b75ab7364b6fa888f1cbfae901aaaf02295" datatype="html">
        <source>{VAR_SELECT, select, male {male} female {female} other {other} }</source>
        <target>{VAR_SELECT, select, male {un homme} female {une femme} other {autre} }</target>
      </trans-unit>
      <!-- #enddocregion translate-select-2 -->
      <!-- #enddocregion translated-select -->
      <!-- #docregion translate-nested -->
      <!-- #docregion translate-nested-1 -->
      <trans-unit id="972cb0cf3e442f7b1c00d7dab168ac08d6bdf20c" datatype="html">
        <source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
        <target>Mis à jour: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></target>
      </trans-unit>
      <!-- #enddocregion translate-nested-1 -->
      <!-- #docregion translate-nested-2 -->
      <trans-unit id="7151c2e67748b726f0864fc443861d45df21d706" datatype="html">
        <source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, male {male} female {female} other {other} }} }</source>
        <target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes par {VAR_SELECT, select, male {un homme} female {une femme} other {autre} }} }</target>
      </trans-unit>
      <!-- #enddocregion translate-nested-2 -->
      <!-- #enddocregion translate-nested -->
      <!-- #docregion i18n-duplicate-custom-id -->
      <trans-unit id="myId" datatype="html">
        <source>Hello</source>
        <target state="new">Bonjour</target>
      </trans-unit>
      <!-- #enddocregion i18n-duplicate-custom-id -->
    </body>
  </file>
</xliff>

Что дальше

Объединение переводов с приложением

Super-powered by Google ©2010–2025.
Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0.
https://angular.dev/guide/i18n/translation-files

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API