@param $locale

@return callable
488555
public function getClosureByLocale($locale)
    {
        return $queryBuilder = function (EntityRepository $er) use ($locale) {
            $queryBuilder = $er->createQueryBuilder('p');
            $queryBuilder->andWhere('p.locale = :locale');
            $queryBuilder->setParameter('locale', $locale);

            return $queryBuilder;
        };
    }
568383
public function setDefault($locale)
    {
        // Make sure locale is available (set it on list if not set yet)
        $this->addLocale($locale);

        // Mark as default locale
        $this->default = $this->findByLocale($locale);

        // Mark as current locale (if none set yet)
        if (!$this->getActive()) {
            $this->setActive($this->default);
        }

        return $this;
    }
940480
public function getLangByLocale($locale)
    {
        // Event parameters prepare
        $arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());

        // Sending service start event
        $arrayParameters = $this->sendEvent('melisengine_service_get_lang_by_local_start', $arrayParameters);

        // Service implementation start
        $langTable = $this->getServiceLocator()->get('MelisEngineTableCmsLang');
        $result = $langTable->getEntryByField('lang_cms_locale', $locale)->toArray();
        if(!isset($result[0]['lang_cms_locale'])) return null;
        $result = $result[0];
        // Service implementation end

        // Adding results to parameters for events treatment if needed
        $arrayParameters['results'] = $result;
        // Sending service end event
        $arrayParameters = $this->sendEvent('melisengine_service_get_lang_by_local_end', $arrayParameters);

        return $arrayParameters['results'];
    }
118918
public function translate($locale = null)
    {
        if (!$locale) {
            $locale = \localizer\locale()->id();
        } else {
            $locale = (int)$locale;
        }

        return $this->getTranslation($locale);
    }
1264169
private function transformLocale($locale)
    {
        $theme = $this->themeContext->getTheme();

        if (null === $theme) {
            return $locale;
        }

        if (null === $locale) {
            $locale = $this->getLocale();
        }

        $locale = $locale . '@' . str_replace('/', '-', $theme->getName());

        return $locale;
    }
393153
public function addLocale($locale)
    {
        // Get sanitized locale
        $locale = Locale::sanitizeLocale($locale);

        if (!isset($this->available[$locale])) {
            $locale = new Locale($locale);

            $this->available[$locale->getLocale()] = $locale;
        }

        return $this;
    }
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;
    }
753763
public static function getByLocale($locale)
    {
        if (!$locale) {
            return null;
        }

        if ($locale instanceof Locale) {
            return $locale;
        }

        if (!static::$locales_by_title) {
            static::$locales_by_title = [];
            foreach (Locale::getCached() as $localeObj) {
                static::$locales_by_title[$localeObj->Locale] = $localeObj;
            }
        }

        // Get filtered locale
        return isset(static::$locales_by_title[$locale]) ? static::$locales_by_title[$locale] : null;
    }
1073188
private function setLocale(string $locale)
    {
        $arr = \Locale::parseLocale($locale);
        
        if ($arr === false) {
            throw new \InvalidArgumentException('Invalid locale');
        }
        
        $this->locale = $arr;
    }
1006623
protected function getTranslationOrNew($locale)
    {
        if (($translation = $this->getTranslation($locale)) === null) {
            $translation = $this->createNewTranslation($locale);
        }

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

        return redirect()->back();
    }
361842
public function setLocale($locale) {
		$this->locale = $locale;
		
		if ($this->checkTranslateObjectIsSet()) {
			$this->translation->setLocale($this->locale);
		}
	}
81011
public function setLocale($locale)
    {
        if ($locale && !is_string($locale)) {
            throw new InvalidArgumentException("Invalid locale");
        }
        $this->locale = $locale;
        return $this;
    }
887394
public function setLocale($locale)
    {
        // Handle from locale + country
        switch (strtolower($locale)) {
            // “…”
            case 'pt-br':
                $this->opening = Fixer::LDQUO;
                $this->openingSuffix = '';
                $this->closing = Fixer::RDQUO;
                $this->closingPrefix = '';

                return;
        }

        // Handle from locale only
        $short = Fixer::getLanguageFromLocale($locale);

        switch ($short) {
            // « … »
            case 'fr':
                $this->opening = Fixer::LAQUO;
                $this->openingSuffix = Fixer::NO_BREAK_SPACE;
                $this->closing = Fixer::RAQUO;
                $this->closingPrefix = Fixer::NO_BREAK_SPACE;
                break;
            // «…»
            case 'hy':
            case 'az':
            case 'hz':
            case 'eu':
            case 'be':
            case 'ca':
            case 'el':
            case 'it':
            case 'no':
            case 'fa':
            case 'lv':
            case 'pt':
            case 'ru':
            case 'es':
            case 'uk':
                $this->opening = Fixer::LAQUO;
                $this->openingSuffix = '';
                $this->closing = Fixer::RAQUO;
                $this->closingPrefix = '';
                break;
            // „…“
            case 'de':
            case 'ka':
            case 'cs':
            case 'et':
            case 'is':
            case 'lt':
            case 'mk':
            case 'ro':
            case 'sk':
            case 'sl':
            case 'wen':
                $this->opening = Fixer::BDQUO;
                $this->openingSuffix = '';
                $this->closing = Fixer::LDQUO;
                $this->closingPrefix = '';
                break;
            // “…”
            case 'en':
            case 'us':
            case 'gb':
            case 'af':
            case 'ar':
            case 'eo':
            case 'id':
            case 'ga':
            case 'ko':
            case 'br':
            case 'th':
            case 'tr':
            case 'vi':
                $this->opening = Fixer::LDQUO;
                $this->openingSuffix = '';
                $this->closing = Fixer::RDQUO;
                $this->closingPrefix = '';
                break;
            // ”…”
            case 'fi':
            case 'sv':
            case 'bs':
                $this->opening = Fixer::RDQUO;
                $this->openingSuffix = '';
                $this->closing = Fixer::RDQUO;
                $this->closingPrefix = '';
                break;
        }
    }
1190523
public static function getLanguageFromLocale($locale)
    {
        if (strpos($locale, '_')) {
            $parts = explode('_', $locale);

            return strtolower($parts[0]);
        }

        return $locale;
    }
833637
public function setLocale(Locale $locale)
    {
        $this->currentLocale = $locale;
        $this->saveCurrentLocaleToSession();

        return $this->currentLocale;
    }
826476
protected function getLocale($locale)
    {
        $result = null;
        if ($locale instanceof LocaleEntity) {
            $result = $locale;
        } elseif (is_string($locale) && $locale !== '') {
            $result = $this->app->make(LocaleRepository::class)->findApproved($locale);
        }

        return $result;
    }