Skip to content

Commit

Permalink
Improving doc blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jul 30, 2014
1 parent bbd3670 commit 0041767
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/I18n/I18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ public static function translator($name = 'default', $locale = null, callable $l
* });
* }}}
*
* @param string $locale The name of translator to create a loader for
* @param callable $looader A callable object that should return a Package
* @param string $locale The name of the translator to create a loader for
* @param callable $loader A callable object that should return a Package
* instance to be used for assembling a new translator.
* @return void
*/
Expand Down
26 changes: 25 additions & 1 deletion src/I18n/TranslatorRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ class TranslatorRegistry extends TranslatorLocator {
protected $_loader;

/**
* {@inheritDoc}
* Gets a translator from the registry by package for a locale.
*
* @param string $name The translator package to retrieve.
* @param string $locale The locale to use; if empty, uses the default
* locale.
* @return \Aura\Intl\TranslatorInterface A translator object.
*/
public function get($name, $locale = null) {
if ($locale === null) {
Expand All @@ -59,10 +64,29 @@ public function get($name, $locale = null) {
return $this->registry[$name][$locale];
}

/**
* Registers a loader function for a package name that will be used as a fallback
* in case no package with that name can be found.
*
* Loader callbacks will get as first argument the package name and the locale as
* the second argument.
*
* @param string $name The name of the translator package to register a loader for
* @param callable $loader A callable object that should return a Package
* @return \Aura\Intl\TranslatorInterface A translator object.
*/
public function registerLoader($name, callable $loader) {
$this->_loaders[$name] = $loader;
}

/**
* Registers a new package by passing the register loaded function for the
* package name.
*
* @param string $name The name of the translator package
* @param string $locale The locale that should be built the package for
* @return \Aura\Intl\TranslatorInterface A translator object.
*/
protected function _getFromLoader($name, $locale) {
$this->packages->set($name, $locale, function() use ($name, $locale) {
return $this->_loaders[$name]($name, $locale);
Expand Down

0 comments on commit 0041767

Please sign in to comment.