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
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
Next Next commit
Add link to usefull online editor
  • Loading branch information
wouterj committed May 11, 2019
commit eed64a82dd4fe70e44634b82203a8b62ae203b32
5 changes: 5 additions & 0 deletions translation/message_format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Messages (i.e. strings) in applications are almost never completely static.
They contain variables or other complex logic like pluralization. In order to
handle this, the Translator component supports the `ICU MessageFormat`_ syntax.

.. tip::

You can test out examples of the ICU MessageFormatter in this `online editor`_.

Using the ICU Message Format
----------------------------

Expand Down Expand Up @@ -433,6 +437,7 @@ The ``number`` formatter allows you to format numbers using Intl's :phpclass:`Nu
// "9 988 776,65 €"
echo $translator->trans('value_of_object', ['value' => 9988776.65]);

.. _`online editor`: http://format-message.github.io/icu-message-format-for-translators/
.. _`ICU MessageFormat`: http://userguide.icu-project.org/formatparse/messages
.. _`switch statement`: https://php.net/control-structures.switch
.. _`Language Plural Rules`: http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html
Copy link

@arjenm arjenm May 4, 2019

Choose a reason for hiding this comment

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

There are even more:

  • 'spellout' which writes a number as text; i.e. '43' becomes 'forty-three'
  • 'oridinal'; 43 becomes 43rd (as stated elsewhere)
  • 'duration'; 43 becomes '43 sec.' (time is appearantly interpreted as seconds of duration)