Skip to content

Commit

Permalink
Added new 2.2 features
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj authored and weaverryan committed Nov 16, 2013
1 parent 4c7d86a commit 0477890
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
26 changes: 21 additions & 5 deletions components/translation/introduction.rst
Expand Up @@ -27,9 +27,9 @@ catalogues*).
Configuration
~~~~~~~~~~~~~

The constructor of the ``Translator`` class needs two arguments: The locale
and the :class:`Symfony\\Component\\Translation\\MessageSelector` to use when
using pluralization (more about that later)::
The constructor of the ``Translator`` class needs one argument: The locale.

.. code-block:: php
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\MessageSelector;
Expand Down Expand Up @@ -67,15 +67,31 @@ Loader too. The default loaders are:
catalogues from PHP arrays.
* :class:`Symfony\\Component\\Translation\\Loader\\CsvFileLoader` - to load
catalogues from CSV files.
* :class:`Symfony\\Component\\Translation\\Loader\\IcuDatFileLoader` - to load
catalogues form resource bundles.
* :class:`Symfony\\Component\\Translation\\Loader\\IcuResFileLoader` - to load
catalogues form resource bundles.
* :class:`Symfony\\Component\\Translation\\Loader\\IniFileLoader` - to load
catalogues form ini files.
* :class:`Symfony\\Component\\Translation\\Loader\\MoFileLoader` - to load
catalogues form gettext files.
* :class:`Symfony\\Component\\Translation\\Loader\\PhpFileLoader` - to load
catalogues from PHP files.
* :class:`Symfony\\Component\\Translation\\Loader\\PoFileLoader` - to load
catalogues form gettext files.
* :class:`Symfony\\Component\\Translation\\Loader\\QtFileLoader` - to load
catalogues form QT XML files.
* :class:`Symfony\\Component\\Translation\\Loader\\XliffFileLoader` - to load
catalogues from Xliff files.
* :class:`Symfony\\Component\\Translation\\Loader\\YamlFileLoader` - to load
catalogues from Yaml files (requires the :doc:`Yaml component</components/yaml>`).

All loaders, except the ``ArrayLoader``, requires the
:doc:`Config component</components/config/index>`.
.. versionadded:: 2.1
The ``IcuDatFileLoader``, ``IcuResFileLoader``, ``IniFileLoader``,
``MofileLoader``, ``PoFileLoader`` and ``QtFileLoader`` are new in
Symfony 2.1

All file loaders require the :doc:`Config component</components/config/index>`.

At first, you should add one or more loaders to the ``Translator``::

Expand Down
9 changes: 4 additions & 5 deletions components/translation/usage.rst
Expand Up @@ -7,10 +7,9 @@ Using the Translator
Imagine you want to translate the string *"Symfony2 is great"* into French::

use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\MessageSelector;
use Symfony\Component\Translation\Loader\ArrayLoader;

$translator = new Translator('fr_FR', new MessageSelector());
$translator = new Translator('fr_FR');
$translator->addLoader('array', new ArrayLoader());
$translator->addResource('array', array(
'Symfony2 is great!' => 'J'aime Symfony2!',
Expand Down Expand Up @@ -213,10 +212,10 @@ recommended format. These files are parsed by one of the loader classes.
.. code-block:: php
return array(
'symfony2.is.great' => 'Symfony2 is great',
'symfony2.is.amazing' => 'Symfony2 is amazing',
'symfony2.is.great' => 'Symfony2 is great',
'symfony2.is.amazing' => 'Symfony2 is amazing',
'symfony2.has.bundles' => 'Symfony2 has bundles',
'user.login' => 'Login',
'user.login' => 'Login',
);
Pluralization
Expand Down

0 comments on commit 0477890

Please sign in to comment.