Translate a level.

@param  string       $level
@param  string|null  $locale

@return string
764521
private function getTranslatedName($level, $locale)
    {
        if ($locale === 'auto') {
            $locale = null;
        }

        return $this->translator->get('log-viewer::levels.' . $level, [], $locale);
    }
650461
public function locale($locale = null)
    {
        if ($locale) {
            $this->_locale = $locale;
        }
        if ($this->_locale) {
            return $this->_locale;
        }
        if (isset($this->_params['locale'])) {
            return $this->_params['locale'];
        }
    }
1344509
public function LocaleInformation($locale = null)
    {
        // Check locale and get object
        if ($locale) {
            $localeObj = Locale::getByLocale($locale);
        } else {
            $localeObj = Locale::getDefault();
        }
        $locale = $localeObj->getLocale();

        // Check linking mode
        $linkingMode = $this->getLinkingMode($locale);

        // Check link
        $link = $this->LocaleLink($locale);

        // Store basic locale information
        return ArrayData::create([
            'Locale' => $locale,
            'LocaleRFC1766' => i18n::convert_rfc1766($locale),
            'URLSegment' => $localeObj->getURLSegment(),
            'Title' => $localeObj->getTitle(),
            'LanguageNative' => $localeObj->getNativeName(),
            'Language' => i18n::getData()->langFromLocale($locale),
            'Link' => $link,
            'AbsoluteLink' => $link ? Director::absoluteURL($link) : null,
            'LinkingMode' => $linkingMode
        ]);
    }
283264
public function getDefaultResourceForLocale( $locale )
    {
        $resource = null;

        if( $this->getValue() && !$this->getValue()->isEmpty() )
        {
            foreach( $this->getValue() as $index => $item )
            {
                if( $item->{$this->getModel()->getLocaleKey()} === $locale )
                {
                    $resource = $item;
                }
            }
        }

        return $resource;
    }
1207865
public function getMessages($locale = null)
    {
        return $locale === null ? $this->messages : $this->messages[$locale];
    }
1036604
public function locale(string $locale = null, ...$fallbackLocales)
    {
        if ($locale === null) {
            return $this->getLocalTranslator()->getLocale();
        }

        if (!$this->localTranslator || $this->localTranslator->getLocale() !== $locale) {
            $translator = Translator::get($locale);

            if (!empty($fallbackLocales)) {
                $translator->setFallbackLocales($fallbackLocales);

                foreach ($fallbackLocales as $fallbackLocale) {
                    $messages = Translator::get($fallbackLocale)->getMessages();

                    if (isset($messages[$fallbackLocale])) {
                        $translator->setMessages($fallbackLocale, $messages[$fallbackLocale]);
                    }
                }
            }

            $this->setLocalTranslator($translator);
        }

        return $this;
    }
507807
protected function getTranslationOrNew( $locale )
    {
        if( ( $translation = $this->getTranslation( $locale, false ) ) === null )
        {
            $translation = $this->getNewTranslation( $locale );
        }

        return $translation;
    }
389610
public function translate($key, $defaultValue = '', $locale = null) {
		return $this->translation->translate($key, $defaultValue, $locale);
	}
185046
private function getFallbackLocale($locale = null)
    {
        if ($locale && $this->isLocaleCountryBased($locale)) {
            if ($fallback = $this->getLanguageFromCountryBasedLocale($locale)) {
                return $fallback;
            }
        }

        $locales = $this->getLocales();

        foreach ($locales as $code) {
            if ($this->getTranslationByLocaleKey($code) !== null)
                return $code;
        }

        return app()->make('config')->get('revy.translatable.fallback_locale');
    }
1372378
protected function getLocalizedRedirect($locale)
    {
        return is_string($localizedUrl = $this->localization->getLocalizedURL($locale))
            ? $this->makeRedirectResponse($localizedUrl)
            : null;
    }
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;
    }
159555
public function names($locale = null)
    {
        $levels = self::all(true);

        array_walk($levels, function (&$name, $level) use ($locale) {
            $name = $this->getTranslatedName($level, $locale);
        });

        return $levels;
    }
67231
public function translate($key, $translation, $locale = null, $driver = null) {
        $driver = ! is_null($driver) ? $this->getDriver($driver) : $this->driver();

        return $driver->translate(
            $key, $translation, $locale
        );
    }
165554
public function get($key, $locale = null)
    {
        if(!$locale){
            $locale = $this->getLocale();
        }

        if($locale == config('translator.default')){
            return $key;
        }

        $this->load($locale);

        if (!isset($this->languages[$locale][$key])){
            $this->setMissing($key, $locale);
            return $key;
        }

        return $this->languages[$locale][$key]["value"];
    }
1282328
protected function newTranslation($locale = null, array $attributes) {
        $locale = isset($locale) ? $locale : Locale\get_active_locale();

        $language = $this->getByLocale($locale);

        $class = $this->classTranslation();

        $update = [
            'language_id' => $language->id,
             isset($this->translation_id) ? $this->translation_id : str_singular($this->getModel()->getTable()) . '_id' => $this->id,
        ];

        $attributes = array_merge($update, $attributes);

       return $class::updateOrCreate($update, $attributes);
    }
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;
    }
513893
private static Level translateLevel(final int level) {
		if (level <= TRACE_INT) {
			return Level.TRACE;
		} else if (level <= DEBUG_INT) {
			return Level.DEBUG;
		} else if (level <= INFO_INT) {
			return Level.INFO;
		} else if (level <= WARN_INT) {
			return Level.WARN;
		} else {
			return Level.ERROR;
		}
	}