Skip to content

Commit

Permalink
Fixing the I18n class and adding updating doc blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
burzum committed May 14, 2017
1 parent e7b94db commit 81d8b74
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/I18n/I18n.php
Expand Up @@ -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;
}
Expand All @@ -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');
* ```
*
Expand All @@ -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'
* );
* ```
*
Expand Down Expand Up @@ -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.
Expand All @@ -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.
*
Expand Down

0 comments on commit 81d8b74

Please sign in to comment.