@param PreciseDifference $difference
@param string            $locale

@return string
338391
public function formatDifference(PreciseDifference $difference, $locale = 'en')
    {
        $diff = [];

        foreach ($difference->getCompoundResults() as $result) {
            $diff[] = $this->translator->transChoice(
                'compound.'.$result->getUnit()->getName(),
                $result->getQuantity(),
                ['%count%' => $result->getQuantity()],
                'difference',
                $locale
            );
        }

        return $this->translator->trans(
            'compound.'.($difference->isPast() ? 'past' : 'future'),
            ['%value%' => \implode(', ', $diff)],
            'difference',
            $locale
        );
    }
1353649
public static function getRegion($locale)
    {
        $parts = explode('-', str_replace('_', '-', $locale));

        if (count($parts) === 1) {
            return '';
        }

        $region = end($parts);

        if (strlen($region) === 4) {
            return '';
        }

        if ($region === 'POSIX') {
            $region = 'US';
        }

        return strtoupper($region);
    }
955557
public static function localeHasDiffOneDayWords($locale)
    {
        return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
            return $newLocale &&
                $translator->trans('diff_now') !== 'diff_now' &&
                $translator->trans('diff_yesterday') !== 'diff_yesterday' &&
                $translator->trans('diff_tomorrow') !== 'diff_tomorrow';
        });
    }
1190523
public static function getLanguageFromLocale($locale)
    {
        if (strpos($locale, '_')) {
            $parts = explode('_', $locale);

            return strtolower($parts[0]);
        }

        return $locale;
    }
32566
public function getTranslation(string $locale): ?string
    {
        if (! isset($this->text[$locale])) {
            $fallback = config('app.fallback_locale');

            return $this->text[$fallback] ?? null;
        }

        return $this->text[$locale];
    }
771926
public function formatDifference(Verta $v = null)
    {
        $difference = $this->diffSeconds($v);
        $absolute = $difference < 0 ? self::POST : self::PRE;
        $difference = abs($difference);

        for ($j = 0; $difference >= static::$unitNumber[$j] and $j < count(static::$unitNumber) - 1; $j++) {
            $difference /= static::$unitNumber[$j];
        }
        $difference = intval(round($difference));

        if($difference === 0) {
            return self::NOW;
        }

        return sprintf('%s %s %s', $difference, static::$unitName[$j], $absolute);
    }
663103
public function getNewTranslation($locale)
    {
        $modelName = $this->getTranslationModelName();
        $translation = new $modelName();
        $translation->setAttribute($this->getLocaleKey(), $locale);
        $this->translations->add($translation);

        return $translation;
    }
750284
public function getDisplayedDescription( $locale = self::FALLBACK_LOCALE )
    {
        if ( ! empty( $this->displayDescription[$locale] ) )
        {
            return $this->displayDescription[$locale];
        }

        $language = Locale::getPrimaryLanguage( $locale );

        if ( ! empty( $this->displayDescription[$language] ) )
        {
            return $this->displayDescription[$language];
        }

        if ( ! empty( $this->displayDescription[static::FALLBACK_LOCALE] ) )
        {
            return $this->displayDescription[static::FALLBACK_LOCALE];
        }

        if ( ! empty( $this->description ) && strpos( $this->description, "\n" ) )
        {
            list( $name, $description ) = explode( "\n", $this->description, 2 );
            return $description;
        }

        return $this->description;
    }
1154585
protected function getFormatter($locale, $digits)
    {
        $formatter = $this->retrieveDecimalFormatter($locale);
        $formatter->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, $digits);
        $formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, $digits);
        $formatter->setAttribute(NumberFormatter::DECIMAL_ALWAYS_SHOWN, 1);

        return $formatter;
    }
656030
private function hasLocale(string $locale): bool
    {
        assert(empty($locale) === false);

        $result = in_array($locale, $this->getLocales());

        return $result;
    }
597828
public function translateOrFirst($locale = null)
    {
        $translation = $this->translate($locale, true);

        if ( ! $translation)
        {
            $translation = $this->translations->first();
        }

        return $translation;
    }
729915
private function getFormatter($locale = 'de-AT')
    {
        $formatter = new \NumberFormatter($locale, \NumberFormatter::DECIMAL);
        $formatter->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, 2);
        $formatter->setAttribute(\NumberFormatter::DECIMAL_ALWAYS_SHOWN, 1);

        return $formatter;
    }
891044
function languageNameFromLocale( $locale )
    {
         $pos = strpos( $locale , "-");
         $languageName = substr( $locale , 0, $pos );
         return $languageName;
    }
91666
private static function _calendarDetail($locale, $list)
    {
        $ret = "001";
        foreach ($list as $key => $value) {
            if (strpos($locale, '_') !== false) {
                $locale = substr($locale, strpos($locale, '_') + 1);
            }
            if (strpos($key, $locale) !== false) {
                $ret = $key;
                break;
            }
        }
        return $ret;
    }
1069782
public static function number(float $n, int $precision = 0): string
    {
        return self::$locale->number(round($n, $precision));
    }
127682
public function xliffAsJsonAction($locale)
    {
        $this->response->setHeader('Content-Type', 'application/json');
        $this->response->setHeader('Cache-Control', 'max-age=' . (3600 * 24 * 7));

        return $this->xliffService->getCachedJson(new Locale($locale));
    }
230089
public function setLocale($locale)
    {
        $this->locale = $locale;

        $this->getContentRoute()->setLocale($locale);

        return $this;
    }