This function also includes empty strings in the process.
@param  Locale $locale [description]
@param  [type] $from   [description]
@param  [type] $into   [description]
@return [type]         [description]
965697
public function hardTranslationSetMerge(Locale $locale, $from, $into)
    {
        foreach ($from as $translation) {
            $translationString = $translation->getTranslation();
            $original = $translation->getOriginal();
            $context = $translation->getContext();
            $merged = $this->addOrCreateString($into, $context, $original);
            $merged->setTranslation($translationString);

            // The following raises an array to string warning
            // $merged->setPluralTranslation($translation->getPluralTranslation());
        }
    }
182272
public function getLocaleChain(Locale $locale)
    {
        $fallbackRule = $this->configuration->getFallbackRule();
        $localeChain = [(string)$locale => $locale];

        if ($fallbackRule['strict'] === true) {
            foreach ($fallbackRule['order'] as $localeIdentifier) {
                $localeChain[$localeIdentifier] = new Locale($localeIdentifier);
            }
        } else {
            $locale = $this->findBestMatchingLocale($locale);
            while ($locale !== null) {
                $localeChain[(string)$locale] = $locale;
                $locale = $this->getParentLocaleOf($locale);
            }
            foreach ($fallbackRule['order'] as $localeIdentifier) {
                $locale = new Locale($localeIdentifier);
                $locale = $this->findBestMatchingLocale($locale);
                while ($locale !== null) {
                    $localeChain[(string)$locale] = $locale;
                    $locale = $this->getParentLocaleOf($locale);
                }
            }
        }
        $locale = $this->configuration->getDefaultLocale();
        $localeChain[(string)$locale] = $locale;

        return $localeChain;
    }
591944
public function setLocale($locale)
    {
        if ($locale instanceof Locale) {
            $this->locale = $locale;
            return $this;
        }
        $this->locale = strtolower($locale);
        return $this;
    }
64352
public function getTranslation($locale = 'en_US', ConnectionInterface $con = null)
    {
        if (!isset($this->currentTranslations[$locale])) {
            if (null !== $this->collDealerI18ns) {
                foreach ($this->collDealerI18ns as $translation) {
                    if ($translation->getLocale() == $locale) {
                        $this->currentTranslations[$locale] = $translation;

                        return $translation;
                    }
                }
            }
            if ($this->isNew()) {
                $translation = new ChildDealerI18n();
                $translation->setLocale($locale);
            } else {
                $translation = ChildDealerI18nQuery::create()
                    ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
                    ->findOneOrCreate($con);
                $this->currentTranslations[$locale] = $translation;
            }
            $this->addDealerI18n($translation);
        }

        return $this->currentTranslations[$locale];
    }
1185231
public function locale($locale = null)
    {
        if ($locale) {
            // Normalize the language
            self::$locale = strtolower(str_replace([' ', '_'], '-', $locale));
        }

        return self::$locale;
    }
37580
public function translate(string $from, string $to) : Text
    {
        return $this->pipe(
            function (string $value) use ($from, $to) : string {
                return strtr($value, $from, $to);
            }
        );
    }
507807
protected function getTranslationOrNew( $locale )
    {
        if( ( $translation = $this->getTranslation( $locale, false ) ) === null )
        {
            $translation = $this->getNewTranslation( $locale );
        }

        return $translation;
    }
1090587
public static function fromFile(string $file, string $locale): Resource
    {
        if (!is_file($file)) {
            throw new \InvalidArgumentException("$file is not a file");
        }
        
        $contents = file_get_contents($file);
        
        if ($contents === false) {
            throw new \RuntimeException("Error reading file at $file.");
        }
        
        return static::fromString($contents, $locale);
    }
1192046
public function setLocale($locale = null)
    {

        $this->_locale = Zend_Locale::findLocale($locale);
        $locale        = new Zend_Locale($this->_locale);
        $region        = $locale->getRegion();
        if (empty($region)) {

            throw new Zend_Validate_Exception("Unable to detect a region for the locale '$locale'");
        }

        $format = Zend_Locale::getTranslation(
            $locale->getRegion(),
            'postaltoterritory',
            $this->_locale
        );

        if (empty($format)) {

            throw new Zend_Validate_Exception("Unable to detect a postcode format for the region '{$locale->getRegion()}'");
        }

        $this->setFormat($format);
        return $this;
    }
206936
private static function _checkLocale($locale)
    {
        if (empty($locale)) {
            $locale = new Zend_Locale();
        }

        if (!(Zend_Locale::isLocale((string) $locale, null, false))) {

            throw new Zend_Locale_Exception("Locale (" . (string) $locale . ") is a unknown locale");
        }

        return (string) $locale;
    }
1071317
protected function getFormatter($locale) {
		if (! isset($this->formatters[$locale])) {
			$this->formatters[$locale] = new IntlDateFormatter($locale, IntlDateFormatter::SHORT, IntlDateFormatter::SHORT);
		}
		
		return $this->formatters[$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));
		}
	}
301306
public static function create(string $locale = 'en'): ValidatorFactory
    {
        $translator = new Translator;

        $factory = new ValidatorFactory($translator);
        $factory = $factory->withBuiltInFactories();
        $factory = $factory->withBuiltInTemplates($locale);

        return $factory;
    }
372444
public function getTranslation($locale = 'en_US', ConnectionInterface $con = null)
    {
        if (!isset($this->currentTranslations[$locale])) {
            if (null !== $this->collDealerContactI18ns) {
                foreach ($this->collDealerContactI18ns as $translation) {
                    if ($translation->getLocale() == $locale) {
                        $this->currentTranslations[$locale] = $translation;

                        return $translation;
                    }
                }
            }
            if ($this->isNew()) {
                $translation = new ChildDealerContactI18n();
                $translation->setLocale($locale);
            } else {
                $translation = ChildDealerContactI18nQuery::create()
                    ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
                    ->findOneOrCreate($con);
                $this->currentTranslations[$locale] = $translation;
            }
            $this->addDealerContactI18n($translation);
        }

        return $this->currentTranslations[$locale];
    }
1207865
public function getMessages($locale = null)
    {
        return $locale === null ? $this->messages : $this->messages[$locale];
    }
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';
        });
    }
677558
protected function normalizeLocale($locale) {
		if ($locale instanceof Locale) {
			$locale = $locale->getPrimaryLanguage();
		}
		
		$underlinePos = strpos($locale, '_');
		
		if ($underlinePos !== false) {
			return substr($locale, 0, $underlinePos);
		}
		
		return $locale;
	}