Skip to content

Commit

Permalink
feature #3386 [Translation] added method to expose collected message …
Browse files Browse the repository at this point in the history
…(Grygir)

This PR was merged into the master branch.

Discussion
----------

[Translation] added method to expose collected message

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes (symfony/symfony#9859)
| Applies to    | all (or 2.4+)
| Fixed tickets |

Commits
-------

f701f73 [Translation] added method to expose collected message
  • Loading branch information
weaverryan committed Nov 4, 2014
2 parents 9ed31c8 + f701f73 commit 4b98d48
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions components/translation/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,25 @@ use for translation::

.. _`L10n`: http://en.wikipedia.org/wiki/Internationalization_and_localization
.. _`ISO 31-11`: http://en.wikipedia.org/wiki/Interval_(mathematics)#Notations_for_intervals

Retrieving the Message Catalogue
--------------------------------

In case you want to use the same translation catalogue outside your application
(e.g. use translation on a client side), it's possible to fetch raw translation messages.
You just need to specify required locale::

$messages = $translator->getMessages('fr_FR');

``$messages`` will have the following structure::

array(
'messages' => array(
'Hello world' => 'Bonjour tout le monde',
),
'validators' => array(
'Value should not be empty' => 'Valeur ne doit pas être vide',
'Value is too long' => 'Valeur est trop long',
),
);

0 comments on commit 4b98d48

Please sign in to comment.