Return a new instance of this provider for locale $locale.

@param string $locale
@param string|array $fallbacks (optional)

@return Multilingual
338915
public function forLocale($locale, $fallbacks=null)
    {
        $fork = $this->replicate()->setLocale($locale);

        if ($fallbacks) {
            return $fork->setFallbacks($fallbacks);
        }

        if ($this->localeFallbacks) {
            return $fork->setFallbacks($this->localeFallbacks);
        }

        return $fork;
    }
1069185
private function getFallbackLocale($locale = null)
    {
        if ($locale && $this->isLocaleCountryBased($locale)) {
            if ($fallback = $this->getLanguageFromCountryBasedLocale($locale)) {
                return $fallback;
            }
        }

        return config('translatable.fallback_locale');
    }
663103
public function getNewTranslation($locale)
    {
        $modelName = $this->getTranslationModelName();
        $translation = new $modelName();
        $translation->setAttribute($this->getLocaleKey(), $locale);
        $this->translations->add($translation);

        return $translation;
    }
205388
public function setLocale($locale)
    {
        $this->locale = $locale;
        if ($this->coreFormatter instanceof Multilingual) {
            $this->coreFormatter->setLocale($locale);
        }
        if ($this->textProvider instanceof Multilingual) {
            $this->textProvider->setLocale($locale);
        }
        return $this;
    }
369208
public function switchLocale($locale)
    {
        if (in_array($locale, $this->config['locales'])) {
            app('session')->put('administrator_locale', $locale);
        }

        return redirect()->back();
    }
869147
public static function get_closest_translation($locale)
    {
        // Check if exact match
        $pool = self::getSources()->getKnownLocales();
        if (isset($pool[$locale])) {
            return $locale;
        }

        // Fallback to best locale for common language
        $localesData = static::getData();
        $lang = $localesData->langFromLocale($locale);
        $candidate = $localesData->localeFromLang($lang);
        if (isset($pool[$candidate])) {
            return $candidate;
        }
        return null;
    }
566969
public static function with_locale($locale, $callback)
    {
        $oldLocale = self::$current_locale;
        static::set_locale($locale);
        try {
            return $callback();
        } finally {
            static::set_locale($oldLocale);
        }
    }
463561
public static function setLocale($locale)
    {
        static::getDefaultLocale();
        Locale::setDefault($locale);
        if (isset(static::$_collection)) {
            static::translators()->setLocale($locale);
        }
    }
491821
public function get($key, array $replace = [], $locale = null, $fallback = true)
    {
        // If we have a CMS-prefixed version, use it.
        if ( ! $this->isCmsPrefixed($key)) {
            $prefixedKey = $this->applyCmsPrefix($key);

            if (parent::has($prefixedKey, $locale, $fallback)) {
                $key = $prefixedKey;
            }
        }

        return parent::get($key, $replace, $locale, $fallback);
    }
455395
protected function getTranslation(string $locale): ?Model
    {
        if (isset($this->translationCache[$locale])) {
            return $this->translationCache[$locale];
        }

        if (!$this->exists) {
            return null;
        }

        $translation = $this->translations
            ->where('locale', $locale)
            ->first();

        if ($translation) {
            $this->translationCache[$locale] = $translation;
        }

        return $translation;
    }
1336512
protected function getTranslation($id, $domain, $locale, $fallbacks) {
		// Is initialize of the catalog need ?
		if (! isset($this->initializedCatalogs[$locale][$domain])) {
			$this->initCatalogs($locale, $domain);
		}
		
		// Is failure occurred ?
		if (! isset($this->catalogs[$locale][$domain][$id])) {
			if (empty($fallbacks)) {
				return;
			}
			
			$fallbackLocale = array_shift($fallbacks);
			
			return $this->getTranslation($id, $domain, $fallbackLocale, $fallbacks);
		}
		
		return $this->catalogs[$locale][$domain][$id];
	}
144083
public function locale($locale = null)
    {
        // Set the locale if a valid local is passed
        if ($locale
            && ($locales = Config::get('decoy.site.locales'))
            && is_array($locales)
            && isset($locales[$locale])) {
            return Session::put('locale', $locale);
        }

        // Return the current locale or default to first one.  Store it in a local var
        // so that multiple calls don't have to do any complicated work.  We're assuming
        // the locale won't change within a single request.
        if (!$this->locale) {
            $this->locale = Session::get('locale', $this->defaultLocale());
        }

        return $this->locale;
    }
463269
public function get(string $key, string $locale = null)
    {
        list($country) = $this->parseKey($key);

        $locale = $locale ?? $this->fallbackLocale;

        $this->load($locale);

        if ($this->has($locale, $country)) {
            return $this->loaded[$locale][$country];
        }

        return $key;
    }
851493
public function getOrCreateTranslationForLocale($locale)
    {
        foreach ($this->getTranslations() as $propelTranslation) {
            if ($propelTranslation->getLocale() == $locale) {
                return $propelTranslation;
            }
        }

        $propelTranslation = new PropelTranslation();
        $propelTranslation->setLocale($locale);
        $this->addTranslation($propelTranslation);

        return $propelTranslation;
    }
705328
public function uri($locale = null)
    {
        $locale = $locale ?: config('app.locale');
        $uri = $this->translate('uri', $locale);
        if (
            config('app.fallback_locale') != $locale ||
            config('typicms.main_locale_in_url')
        ) {
            $uri = $uri ? $locale.'/'.$uri : $locale;
        }

        return $uri ?: '/';
    }
1227704
public static function getLanguage($locale)
    {
        return isset(self::$locales[$locale])
            ? self::$locales[$locale]
            : $locale;
    }
777456
protected function parseLocale($locale)
	{
		if ( ! is_null($locale))
		{
			return array_filter(array($locale, $this->fallback));
		}
		else
		{
			return array_filter(array($this->locale, $this->fallback));
		}
	}