/** * Gets a translator from the registry by package for a locale. * * @param string $name The translator package to retrieve. * @param string|null $locale The locale to use; if empty, uses the default * locale. * @return \Aura\Intl\TranslatorInterface A translator object. * @throws \Aura\Intl\Exception If no translator with that name could be found * for the given locale. */ public function get($name, $locale = null) { if (!$name) { return null; } if ($locale === null) { $locale = $this->getLocale(); } if (isset($this->registry[$name][$locale])) { return $this->registry[$name][$locale]; } if (!$this->_cacher) { return $this->registry[$name][$locale] = $this->_getTranslator($name, $locale); } $key = "translations.{$name}.{$locale}"; $translator = $this->_cacher->read($key); if (!$translator) { $translator = $this->_getTranslator($name, $locale); $this->_cacher->write($key, $translator); } return $this->registry[$name][$locale] = $translator; }