From 81d8b74d93e9e8b0c7b5c6a2ab88cf529616389e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Mon, 15 May 2017 01:13:31 +0200 Subject: [PATCH] Fixing the I18n class and adding updating doc blocks --- src/I18n/I18n.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/I18n/I18n.php b/src/I18n/I18n.php index e735e2421b6..98a2350be78 100644 --- a/src/I18n/I18n.php +++ b/src/I18n/I18n.php @@ -126,7 +126,7 @@ public static function translators() public static function translator($name = 'default', $locale = null, callable $loader = null) { if ($loader !== null) { - static::setTranslator($name, $locale, $loader); + static::setTranslator($name, $loader, $locale); return null; } @@ -135,21 +135,23 @@ public static function translator($name = 'default', $locale = null, callable $l } /** + * Sets a translator. + * * Configures future translators, this is achieved by passing a callable * as the last argument of this function. * * ### Example: * * ``` - * I18n::translator('default', 'fr_FR', function () { + * I18n::setTranslator('default', function () { * $package = new \Aura\Intl\Package(); * $package->setMessages([ * 'Cake' => 'Gâteau' * ]); * return $package; - * }); + * }, 'fr_FR'); * - * $translator = I18n::translator('default', 'fr_FR'); + * $translator = I18n::getTranslator('default', 'fr_FR'); * echo $translator->translate('Cake'); * ``` * @@ -158,10 +160,10 @@ public static function translator($name = 'default', $locale = null, callable $l * the `src/Locale/custom` folder, you would do: * * ``` - * I18n::translator( + * I18n::setTranslator( * 'default', - * 'fr_FR', * new MessagesFileLoader('my_translations', 'custom', 'po'); + * 'fr_FR' * ); * ``` * @@ -324,6 +326,8 @@ public static function defaultLocale() } /** + * Returns the default locale. + * * This returns the default locale before any modifications, i.e. * the value as stored in the `intl.default_locale` PHP setting before * any manipulation by this class. @@ -341,8 +345,9 @@ public static function getDefaultLocale() /** * Sets the name of the default messages formatter to use for future - * translator instances. By default the `default` and `sprintf` formatters - * are available. + * translator instances. + * + * By default the `default` and `sprintf` formatters are available. * * If called with no arguments, it will return the currently configured value. *