@param LocaleEntity $locale

@return int The number of accepted join requests
970007
private function processLocale(LocaleEntity $locale)
    {
        $result = 0;
        $this->logger->info(sprintf('Processing %s (%s)', $locale->getName(), $locale->getID()));
        $aspiringGroup = $this->groupsHelper->getAspiringTranslators($locale);
        $aspiringGroupMemberIDs = $aspiringGroup->getGroupMemberIDs();
        $numberOfAspiringMembers = count($aspiringGroupMemberIDs);
        if ($numberOfAspiringMembers === 0) {
            $this->logger->info('  - No pending requests found.');
        } else {
            foreach ($aspiringGroupMemberIDs as $memberID) {
                if ($this->processAspiring($locale, $aspiringGroup, $memberID)) {
                    ++$result;
                }
            }
            $this->logger->info(sprintf('  - %d out of %d requests accepted.', $result, $numberOfAspiringMembers));
        }

        return $result;
    }
1006623
protected function getTranslationOrNew($locale)
    {
        if (($translation = $this->getTranslation($locale)) === null) {
            $translation = $this->createNewTranslation($locale);
        }

        return $translation;
    }
418228
private function getOrderQuery($locale)
    {
        $qb = $this->createQueryBuilder('o')
            ->leftJoin('o.deliveryAddress', 'deliveryAddress')
            ->leftJoin('o.invoiceAddress', 'invoiceAddress')
            ->leftJoin('o.status', 'status')
            ->leftJoin('status.translations', 'statusTranslations', 'WITH', 'statusTranslations.locale = :locale')
            ->leftJoin('o.items', 'items')
            ->setParameter('locale', $locale);

        return $qb;
    }
415621
protected function determineLocaleAndQuery($locale, $query)
    {
        if (is_null($query))
        {
            $modelName = $this->getViewModelName();

            $query = with(new $modelName)->newQuery();
        }

        if ($locale)
        {
            $query->where('locale', $locale);
        }

        return $query;
    }
171537
public function getGreeting($locale = null)
    {
        if (! $this->_getVar('user_greeting')) {
            $greeting[] = $this->getGenderGreeting($locale);

            if ($this->_getVar('user_last_name')) {
                $greeting[] = $this->_getVar('user_surname_prefix');
                $greeting[] = $this->_getVar('user_last_name');
            } else {
                $name = $this->getLoginName();
                if ($name) {
                    $name = substr($name, 0, 3) . str_repeat('*', strlen($name) - 2);
                    $greeting[] = $name;
                }
            }
            array_filter($greeting);

            $this->_setVar('user_greeting', implode(' ', $greeting));
        }

        return $this->_getVar('user_greeting');
    }
1308694
protected function getUrlLanguage($locale = null)
    {
        // Check if the functionality is activated
        if (!ConfigQuery::isMultiDomainActivated()) {
            return null;
        }

        // If we don't have a locale value, use the locale value in the session
        if (!$locale) {
            $locale = $this->getCurrentEditionLocale();
        }

        return LangQuery::create()->findOneByLocale($locale)->getUrl();
    }
879532
public function language($locale = null)
    {
        if ($locale !== null) {
            $this->language = $locale;
        }

        return $this->language;
    }
1190523
public static function getLanguageFromLocale($locale)
    {
        if (strpos($locale, '_')) {
            $parts = explode('_', $locale);

            return strtolower($parts[0]);
        }

        return $locale;
    }
1227704
public static function getLanguage($locale)
    {
        return isset(self::$locales[$locale])
            ? self::$locales[$locale]
            : $locale;
    }
247055
public function getByLocale(LocaleEntity $locale)
    {
        $app = Application::getFacadeApplication();
        $result = $this->find($locale);
        if ($result === null) {
            $em = $this->getEntityManager();
            try {
                $numTranslatable = (int) $app->make(TranslatableRepository::class)
                    ->createQueryBuilder('t')
                        ->select('count(t.id)')
                        ->getQuery()->getSingleScalarResult();
            } catch (NoResultException $x) {
                $numTranslatable = 0;
            }
            if ($numTranslatable === 0) {
                $numApprovedTranslations = 0;
            } else {
                try {
                    $numApprovedTranslations = (int) $app->make(TranslationRepository::class)
                    ->createQueryBuilder('t')
                        ->select('count(t.id)')
                        ->where('t.locale = :locale')->setParameter('locale', $locale)
                        ->andWhere('t.current = 1')
                        ->getQuery()->getSingleScalarResult();
                } catch (NoResultException $x) {
                    $numApprovedTranslations = 0;
                }
            }
            $result = LocaleStatsEntity::create($locale, $numTranslatable, $numApprovedTranslations);
            $em->persist($result);
            $em->flush($result);
        }

        return $result;
    }
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;
    }
1372378
protected function getLocalizedRedirect($locale)
    {
        return is_string($localizedUrl = $this->localization->getLocalizedURL($locale))
            ? $this->makeRedirectResponse($localizedUrl)
            : null;
    }
1070763
public function setLocale($locale)
    {
        if ( ! in_array($locale, self::$supportedLocales)) {
            throw new LocaleNotSupported(sprintf('Locale "%s" is not supported.', $locale));
        }
        $this->locale = $locale;
    }
186186
public function statsTable($locale = null)
    {
        return StatsTable::make($this->stats(), $this->levels, $locale);
    }
341533
public function getUnreviewedSelectQuery(LocaleEntity $locale)
    {
        $cn = $this->app->make(EntityManager::class)->getConnection();
        $queryLocaleID = $cn->quote($locale->getID());

        return $cn->executeQuery(
            $this->getBaseSelectString($locale, false, false) .
            " inner join
                (
                    select distinct
                        translatable
                    from
                        CommunityTranslationTranslations
                    where
                        locale = $queryLocaleID
                        and
                        (
                            (approved is null)
                            or
                            (current = 1 and approved = 0)
                        )
                ) as tNR on CommunityTranslationTranslatables.id = tNR.translatable
            order by
                CommunityTranslationTranslatables.text
            "
        );
    }
1349854
public function getTodayCount($locale = null, $query = null)
    {
        $query = $this->determineLocaleAndQuery($locale, $query);

        return $query->where('created_at', '>=', Carbon::today())->count();
    }
1061156
public function uri($locale = null)
    {
        $uri = $this->page->uri($locale).'#'.$this->position.'-'.$this->translate('slug', $locale);

        return $uri;
    }