Skip to content

[Translation] Document ICU MessageFormat #11523

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

Merged
merged 6 commits into from
Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Yet another great review!
  • Loading branch information
wouterj committed May 28, 2019
commit d2736bc48c02a9b8cfe5b3e5cf5509fafad478cc
2 changes: 1 addition & 1 deletion translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ using the ``trans()`` method:
resources defined for the ``locale`` (e.g. ``fr_FR``). Messages from the
:ref:`fallback locale <translation-fallback>` are also loaded and
added to the catalog if they don't already exist. The end result is a large
"dictionary" of translations. This catalog is cached in production, to
"dictionary" of translations. This catalog is cached in production to
minimize performance impact.

* If the message is located in the catalog, the translation is returned. If
Expand Down
38 changes: 19 additions & 19 deletions translation/message_format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Using the ICU Message Format
----------------------------

In order to use the ICU Message Format, the :ref:`message domain
<using-message-domains>` has to be suffixed with ``intl-icu``:
<using-message-domains>` has to be suffixed with ``+intl-icu``:

====================== ===============================
Normal file name ICU Message Format filename
Expand All @@ -45,12 +45,12 @@ The basic usage of the MessageFormat allows you to use placeholders (called

.. code-block:: yaml

# translations/messages.en.yaml
# translations/messages+intl-icu.en.yaml
say_hello: 'Hello {name}!'

.. code-block:: xml

<!-- translations/messages.en.xlf -->
<!-- translations/messages+intl-icu.en.xlf -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In trabslation/debug.rst we are using .xliff as extension:

.. configuration-block::

    .. code-block:: xml

        <!-- translations/messages.fr.xliff -->
        <?xml version="1.0"?>
        <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
            <file source-language="en" datatype="plaintext" original="file.ext">
                <body>
                    <trans-unit id="1">
                        <source>Symfony is great</source>
                        <target>J'aime Symfony</target>
                    </trans-unit>
                </body>
            </file>
        </xliff>

But in general we a re using .xlf, which one should we communicate in the docs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think xlf is the recommended one. We're using it in the Symfony Demo too: https://github.com/symfony/demo/tree/master/translations

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change the other occurrences then in a separate PR

<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
Expand All @@ -65,7 +65,7 @@ The basic usage of the MessageFormat allows you to use placeholders (called

.. code-block:: php

// translations/messages.en.php
// translations/messages+intl-icu.en.php
return [
'say_hello' => "Hello {name}!",
];
Expand All @@ -91,7 +91,7 @@ typical usage of this is gender:

.. code-block:: yaml

# translations/messages.en.yaml
# translations/messages+intl-icu.en.yaml
invitation_title: >
{organizer_gender, select,
female {{organizer_name} has invited you for her party!}
Expand All @@ -101,7 +101,7 @@ typical usage of this is gender:

.. code-block:: xml

<!-- translations/messages.en.xlf -->
<!-- translations/messages+intl-icu.en.xlf -->
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
Expand All @@ -116,7 +116,7 @@ typical usage of this is gender:

.. code-block:: php

// translations/messages.en.php
// translations/messages+intl-icu.en.php
return [
'invitation_title' => '{organizer_gender, select,
female {{organizer_name} has invited you for her party!}
Expand Down Expand Up @@ -172,7 +172,7 @@ handle pluralization in your messages (e.g. ``There are 3 apples`` vs

.. code-block:: yaml

# translations/messages.en.yaml
# translations/messages+intl-icu.en.yaml
num_of_apples: >
{apples, plural,
=0 {There are no apples}
Expand All @@ -182,7 +182,7 @@ handle pluralization in your messages (e.g. ``There are 3 apples`` vs

.. code-block:: xml

<!-- translations/messages.en.xlf -->
<!-- translations/messages+intl-icu.en.xlf -->
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
Expand All @@ -197,7 +197,7 @@ handle pluralization in your messages (e.g. ``There are 3 apples`` vs

.. code-block:: php

// translations/messages.en.php
// translations/messages+intl-icu.en.php
return [
'num_of_apples' => '{apples, plural,
=0 {There are no apples}
Expand Down Expand Up @@ -277,7 +277,7 @@ Similar to ``plural``, ``selectordinal`` allows you to use numbers as ordinal sc

.. code-block:: yaml

# translations/messages.en.yaml
# translations/messages+intl-icu.en.yaml
finish_place: >
You finished {place, selectordinal,
one {#st}
Expand All @@ -292,7 +292,7 @@ Similar to ``plural``, ``selectordinal`` allows you to use numbers as ordinal sc

.. code-block:: xml

<!-- translations/messages.en.xlf -->
<!-- translations/messages+intl-icu.en.xlf -->
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
Expand All @@ -314,7 +314,7 @@ Similar to ``plural``, ``selectordinal`` allows you to use numbers as ordinal sc

.. code-block:: php

// translations/messages.en.php
// translations/messages+intl-icu.en.php
return [
'finish_place' => 'You finished {place, selectordinal,
one {#st}
Expand Down Expand Up @@ -351,12 +351,12 @@ using the :phpclass:`IntlDateFormatter`:

.. code-block:: yaml

# translations/messages.en.yaml
# translations/messages+intl-icu.en.yaml
published_at: 'Published at {publication_date, date} - {publication_date, time, short}'

.. code-block:: xml

<!-- translations/messages.en.xlf -->
<!-- translations/messages+intl-icu.en.xlf -->
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
Expand All @@ -371,7 +371,7 @@ using the :phpclass:`IntlDateFormatter`:

.. code-block:: php

// translations/messages.en.php
// translations/messages+intl-icu.en.php
return [
'published_at' => 'Published at {publication_date, date} - {publication_date, time, short}',
];
Expand All @@ -393,13 +393,13 @@ The ``number`` formatter allows you to format numbers using Intl's :phpclass:`Nu

.. code-block:: yaml

# translations/messages.en.yaml
# translations/messages+intl-icu.en.yaml
progress: '{progress, number, percent} of the work is done'
value_of_object: 'This artifact is worth {value, number, currency}'

.. code-block:: xml

<!-- translations/messages.en.xlf -->
<!-- translations/messages+intl-icu.en.xlf -->
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
Expand All @@ -419,7 +419,7 @@ The ``number`` formatter allows you to format numbers using Intl's :phpclass:`Nu

.. code-block:: php

// translations/messages.en.php
// translations/messages+intl-icu.en.php
return [
'progress' => '{progress, number, percent} of the work is done',
'value_of_object' => 'This artifact is worth {value, number, currency}',
Expand Down