Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion en/appendices/3-0-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ the ``I18n`` class::
Configure::write('Config.language', 'fr_FR');

// Now
I18n::locale('en_US');
I18n::setLocale('en_US');

- The methods below have been moved:

Expand Down
5 changes: 5 additions & 0 deletions en/appendices/3-5-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ The following is a list of methods that are deprecated and replaced with
* ``outputAs()`` (now ``getOutputFormat()`` / ``setOutputFormat()``)
``Cake\Http\ServerRequest``
* ``env()`` (now ``getEnv()`` / ``withEnv()``)
``Cake\I18n\I18n``
* ``locale()``
* ``translator()``
``Cake\ORM\LocatorAwareTrait``
* ``tableLocator()``
``Cake\ORM\Table``
Expand Down Expand Up @@ -152,3 +155,5 @@ New Features
* ``Cake\Datasource\SchemaInterface`` was added.
* ``Cake\Validation\ValidatorAwareInterface`` was added to define the methods
implemented by ``Cake\Validation\ValidatorAwareTrait``.
* ``Cake\Http\Client::addCookie()`` was added to make it easy to add cookies to
a client instance.
2 changes: 1 addition & 1 deletion en/appendices/3-x-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ each version and the migration path between 2.x and 3.x. If you are currently
using 1.x you should first upgrade to 2.x. See the 2.x documentation for the
relevant upgrade guides.

3.4 Migration Guide
3.5 Migration Guide
===================

.. toctree::
Expand Down
14 changes: 14 additions & 0 deletions en/core-libraries/httpclient.rst
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,20 @@ request's ``$options`` parameters::
'cookies' => ['sessionid' => '123abc']
]);


You can add cookie objects to the client after creating it using the ``addCookie()``
method::

use Cake\Http\Cookie\Cookie;

$http = new Client([
'host' => 'cakephp.org'
]);
$http->addCookie(new Cookie('session', 'abc123'));

.. versionadded:: 3.5.0
``addCookie()`` was added in 3.5.0

.. _httpclient-response-objects:

Response Objects
Expand Down
32 changes: 18 additions & 14 deletions en/core-libraries/internationalization-and-localization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ To change the language for translated strings you can call this method::

use Cake\I18n\I18n;

I18n::locale('de_DE');
// Prior to 3.5 use I18n::locale()
I18n::setLocale('de_DE');

This will also change how numbers and dates are formatted when using one of the
localization tools.
Expand Down Expand Up @@ -384,7 +385,7 @@ for a single domain and locale::

use Aura\Intl\Package;

I18n::translator('animals', 'fr_FR', function () {
I18n::setTranslator('animals', function () {
$package = new Package(
'default', // The formatting strategy (ICU)
'default' // The fallback domain
Expand All @@ -397,15 +398,16 @@ for a single domain and locale::
]);

return $package;
});
}, 'fr_FR');

The above code can be added to your **config/bootstrap.php** so that
translations can be found before any translation function is used. The absolute
minimum that is required for creating a translator is that the loader function
should return a ``Aura\Intl\Package`` object. Once the code is in place you can
use the translation functions as usual::

I18n::locale('fr_FR');
// Prior to 3.5 use I18n::locale()
I18n::setLocale('fr_FR');
__d('animals', 'Dog'); // Returns "Chien"

As you see, ``Package`` objects take translation messages as an array. You can
Expand All @@ -417,11 +419,11 @@ For example, you can still use **.po** files, but loaded from another location::
use Cake\I18n\MessagesFileLoader as Loader;

// Load messages from src/Locale/folder/sub_folder/filename.po

I18n::translator(
// Prior to 3.5 use translator()
I18n::setTranslator(
'animals',
'fr_FR',
new Loader('filename', 'folder/sub_folder', 'po')
new Loader('filename', 'folder/sub_folder', 'po'),
'fr_FR'
);

Creating Message Parsers
Expand Down Expand Up @@ -457,18 +459,19 @@ And finally, configure the translation loader for the domain and locale::

use Cake\I18n\MessagesFileLoader as Loader;

I18n::translator(
// Prior to 3.5 use translator()
I18n::setTranslator(
'animals',
'fr_FR',
new Loader('animals', 'fr_FR', 'yaml')
new Loader('animals', 'fr_FR', 'yaml'),
'fr_FR'
);

.. _creating-generic-translators:

Creating Generic Translators
----------------------------

Configuring translators by calling ``I18n::translator()`` for each domain and
Configuring translators by calling ``I18n::setTranslator()`` for each domain and
locale you need to support can be tedious, specially if you need to support more
than a few different locales. To avoid this problem, CakePHP lets you define
generic translator loaders for each domain.
Expand Down Expand Up @@ -551,7 +554,7 @@ interpolating the variables::

It is possible to set the default formatter for all translators created by
CakePHP before they are used for the first time. This does not include manually
created translators using the ``translator()`` and ``config()`` methods::
created translators using the ``setTranslator()`` and ``config()`` methods::

I18n::defaultFormatter('sprintf');

Expand All @@ -569,7 +572,8 @@ the current locale setting and use the right classes::
use Cake\I18n\Time;
use Cake\I18n\Number;

I18n::locale('fr-FR');
// Prior to 3.5 use I18n::locale()
I18n::setLocale('fr-FR');

$date = new Time('2015-04-05 23:00:00');

Expand Down
16 changes: 8 additions & 8 deletions en/orm/behaviors/translate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Now, select a language to be used for retrieving entities by changing
the application language, which will affect all translations::

// In a controller. Change the locale, e.g. to Spanish
I18n::locale('es');
I18n::setLocale('es');
$this->loadModel('Articles');

Then, get an existing entity::
Expand Down Expand Up @@ -172,7 +172,7 @@ translation for entities that are loaded::
use Cake\I18n\I18n;

// Then you can change the language in your action:
I18n::locale('es');
I18n::setLocale('es');
$this->loadModel('Articles');

// All entities in results will contain spanish translation
Expand All @@ -181,7 +181,7 @@ translation for entities that are loaded::
This method works with any finder in your tables. For example, you can
use TranslateBehavior with ``find('list')``::

I18n::locale('es');
I18n::setLocale('es');
$data = $this->Articles->find('list')->toArray();

// Data will contain
Expand Down Expand Up @@ -289,12 +289,12 @@ simply uses the query builder function for the ``contain`` clause to use the
Retrieving one language without using I18n::locale
--------------------------------------------------

calling ``I18n::locale('es');`` changes the default locale for all translated
calling ``I18n::setLocale('es');`` changes the default locale for all translated
finds, there may be times you wish to retrieve translated content without
modifying the application's state. For these scenarios use the behavior
``locale()`` method::
``setLocale()`` method::

I18n::locale('en'); // reset for illustration
I18n::setLocale('en'); // reset for illustration

$this->loadModel('Articles');
$this->Articles->locale('es'); // specific locale
Expand All @@ -306,7 +306,7 @@ Note that this only changes the locale of the Articles table, it would not
affect the langauge of associated data. To affect associated data it's necessary
to call locale on each table for example::

I18n::locale('en'); // reset for illustration
I18n::setLocale('en'); // reset for illustration

$this->loadModel('Articles');
$this->Articles->locale('es');
Expand Down Expand Up @@ -389,7 +389,7 @@ can be retrieved as usual::
The second way to use for saving entities in another language is to set the
default language directly to the table::

I18n::locale('es');
I18n::setLocale('es');
$article->title = 'Mi Primer Artículo';
$this->Articles->save($article);

Expand Down
2 changes: 1 addition & 1 deletion fr/appendices/3-0-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ pouvez utiliser la classe ``I18n``::
Configure::write('Config.language', 'fr_FR');

// Maintenant
I18n::locale('en_US');
I18n::setLocale('en_US');

- Les méthodes ci-dessous ont été déplacées:

Expand Down
26 changes: 13 additions & 13 deletions fr/core-libraries/internationalization-and-localization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ cette méthode::

use Cake\I18n\I18n;

I18n::locale('de_DE');
I18n::setLocale('de_DE');

Cela changera également le formatage des nombres et des dates lorsque vous
utilisez les outils de localisation.
Expand Down Expand Up @@ -403,7 +403,7 @@ un seul domaine et une seule locale::

use Aura\Intl\Package;

I18n::translator('animals', 'fr_FR', function () {
I18n::setTranslator('animals', function () {
$package = new Package(
'default', // The formatting strategy (ICU)
'default' // The fallback domain
Expand All @@ -416,7 +416,7 @@ un seul domaine et une seule locale::
]);

return $package;
});
}, 'fr_FR');

Le code ci-dessus peut être ajouté à votre **config/bootstrap.php** pour
que les traductions soient ajoutées avant qu'une fonction de traduction ne soit
Expand All @@ -425,7 +425,7 @@ fonction loader doit retourner un objet ``Aura\Intl\Package``. Une fois que le
code est en place vous pouvez utiliser les fonctions de traduction comme
d'habitude::

I18n::locale('fr_FR');
I18n::setLocale('fr_FR');
__d('animals', 'Dog'); // Retourne "Chien"

Comme vous pouvez le voir, les objets ``Package`` prennent les messages de
Expand All @@ -441,10 +441,10 @@ depuis un autre endroit::

// Charge les messages depuis src/Locale/folder/sub_folder/filename.po

I18n::translator(
I18n::setTranslator(
'animals',
'fr_FR',
new Loader('filename', 'folder/sub_folder', 'po')
new Loader('filename', 'folder/sub_folder', 'po'),
'fr_FR'
);

Créer des Parsers de Messages
Expand Down Expand Up @@ -480,18 +480,18 @@ Enfin, configurez le loader de traduction pour le domaine et la locale::

use Cake\I18n\MessagesFileLoader as Loader;

I18n::translator(
I18n::setTranslator(
'animals',
'fr_FR',
new Loader('animals', 'fr_FR', 'yaml')
new Loader('animals', 'fr_FR', 'yaml'),
'fr_FR'
);

.. _creating-generic-translators:

Créer des Traducteurs Génériques
--------------------------------

Configurer des traducteurs en appelant ``I18n::translator()`` pour chaque
Configurer des traducteurs en appelant ``I18n::setTranslator()`` pour chaque
domaine et locale que vous devez supporter peut être fastidieux, spécialement
si vous devez supporter plus que quelques locales. Pour éviter ce problème,
CakePHP vous permet de définir des loaders de traduction génériques pour chaque
Expand Down Expand Up @@ -578,7 +578,7 @@ interpoler les variables::
Il est possible de définir le formateur par défaut pour tous les traducteurs
créés par CakePHP avant qu'ils soient utilisés pour la première fois. Cela
n'inclut pas les traducteurs créés manuellement en utilisant les méthodes
``translator()`` et ``config()``::
``setTranslator()`` et ``config()``::

I18n::defaultFormatter('sprintf');

Expand All @@ -596,7 +596,7 @@ la locale et utiliser les bonnes classes::
use Cake\I18n\Time;
use Cake\I18n\Number;

I18n::locale('fr-FR');
I18n::setLocale('fr-FR');

$date = new Time('2015-04-05 23:00:00');

Expand Down
14 changes: 7 additions & 7 deletions fr/orm/behaviors/translate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ behavior à l'objet Table que vous souhaitez rendre traduisible::
Maintenant, sélectionnez une langue à utiliser pour récupérer les entities::

// Dans un controller. Change la locale
I18n::locale('es');
I18n::setLocale('es');
$this->loadModel('Articles');

Ensuite, récupérez une entity existante::
Expand Down Expand Up @@ -176,7 +176,7 @@ la traduction active pour les entities qui sont chargées::
use Cake\I18n\I18n;

// Change la langue dans votre action
I18n::locale('es');
I18n::setLocale('es');
$this->loadModel('Articles');

// Toutes les entities dans les résultats vont contenir la traduction espagnol
Expand All @@ -186,7 +186,7 @@ Cette méthode fonctionne avec n'importe quel finder se trouvant dans vos
tables. Par exemple, vous pouvez utiliser TranslateBehavior avec
``find('list')``::

I18n::locale('es');
I18n::setLocale('es');
$data = $this->Articles->find('list')->toArray();

// Data va contenir
Expand Down Expand Up @@ -298,12 +298,12 @@ l'association.
Récupérer une Langue sans Utiliser I18n::locale
-----------------------------------------------

Appeler ``I18n::locale('es');`` change la locale par défaut pour tous les finds
Appeler ``I18n::setLocale('es');`` change la locale par défaut pour tous les finds
traduits, il peut y avoir des fois où vous souhaitez récupérer du contenu
traduit sans modification de l'état de l'application. Pour ces scenarios,
utilisez la méthode ``locale`` du behavior::

I18n::locale('en'); // réinitialisation pour l'exemple
I18n::setLocale('en'); // réinitialisation pour l'exemple

$this->loadModel('Articles');
$articles->locale('es'); // locale spécifique
Expand All @@ -316,7 +316,7 @@ changera pas la langue des données associées. Pour utiliser cette technique
pour changer les données associées, il est nécessaire d'appeler la locale
pour chaque table par exemple::

I18n::locale('en'); // reset for illustration
I18n::setLocale('en'); // reset for illustration

$this->loadModel('Articles');
$this->Articles->locale('es');
Expand Down Expand Up @@ -401,7 +401,7 @@ sauvegardée et récupérée comme d'habitude::
La deuxième manière de l'utiliser pour sauvegarder les entities dans une autre
langue est de définir par défaut la langue directement à la table::

I18n::locale('es');
I18n::setLocale('es');
$article->title = 'Mi Primer Artículo';
$this->Articles->save($article);

Expand Down
2 changes: 1 addition & 1 deletion ja/appendices/3-0-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ I18n
Configure::write('Config.language', 'fr_FR');

// Now
I18n::locale('en_US');
I18n::setLocale('en_US');

- 以下のメソッドが移動されました:

Expand Down
Loading