src/Loader.php
public function getTranslator($domain = '')
    {
        if (empty($domain)) {
            $domain = $this->default_domain;
        }

        if (! isset($this->domains[$this->locale])) {
            $this->domains[$this->locale] = [];
        }

        if (! isset($this->domains[$this->locale][$domain])) {
            if (isset($this->paths[$domain])) {
                $base = $this->paths[$domain];
            } else {
                $base = './';
            }

            $locale_names = $this->listLocales($this->locale);

            $filename = '';
            foreach ($locale_names as $locale) {
                $filename = "$base/$locale/LC_MESSAGES/$domain.mo";
                if (file_exists($filename)) {
                    break;
                }
            }

            // We don't care about invalid path, we will get fallback
            // translator here
            $this->domains[$this->locale][$domain] = new Translator($filename);
        }

        return $this->domains[$this->locale][$domain];
    }
public function getTranslator($domain = '')
    {
        if (empty($domain)) {
            $domain = $this->default_domain;
        }

        if (! isset($this->domains[$this->locale])) {
            $this->domains[$this->locale] = [];
        }

        if (! isset($this->domains[$this->locale][$domain])) {
            if (isset($this->paths[$domain])) {
                $base = $this->paths[$domain];
            } else {
                $base = './';
            }

            $locale_names = $this->listLocales($this->locale);

            $filename = '';
            foreach ($locale_names as $locale) {
                $filename = "$base/$locale/LC_MESSAGES/$domain.mo";
                if (file_exists($filename)) {
                    break;
                }
            }

            // We don't care about invalid path, we will get fallback
            // translator here
            $this->domains[$this->locale][$domain] = new Translator($filename);
        }

        return $this->domains[$this->locale][$domain];
    }
public function getTranslator ( $ domain = '' ) { if ( empty ( $ domain ) ) { $ domain = $ this -> default_domain ; } if ( ! isset ( $ this -> domains [ $ this -> locale ] ) ) { $ this -> domains [ $ this -> locale ] = [ ] ; } if ( ! isset ( $ this -> domains [ $ this -> locale ] [ $ domain ] ) ) { if ( isset ( $ this -> paths [ $ domain ] ) ) { $ base = $ this -> paths [ $ domain ] ; } else { $ base = './' ; } $ locale_names = $ this -> listLocales ( $ this -> locale ) ; $ filename = '' ; foreach ( $ locale_names as $ locale ) { $ filename = "$base/$locale/LC_MESSAGES/$domain.mo" ; if ( file_exists ( $ filename ) ) { break ; } } // We don't care about invalid path, we will get fallback // translator here $ this -> domains [ $ this -> locale ] [ $ domain ] = new Translator ( $ filename ) ; } return $ this -> domains [ $ this -> locale ] [ $ domain ] ; }
Returns Translator object for domain or for default domain.

@param string $domain Translation domain

@return Translator
Returns Translator object for domain or for default domain .