Check if a missing translation exists in collection.

@param  string  $locale
@param  string  $transKey

@return bool
2076
private function hasMissing($locale, $transKey)
    {
        if ( ! isset($this->missing[$locale]))
            return false;

        return in_array($transKey, $this->missing[$locale]);
    }
218403
public function getHelpTextByKeyLocale($translationKey, $locale)
    {
        $qb = $this->createQueryBuilder('h');
        $qb->where('h.locale LIKE :locale')
            ->andWhere('h.translationKey LIKE :translationKey')
            ->orderBy('h.id', 'asc')
            ->setParameter(':locale', substr($locale, 0, 2).'%')
            ->setParameter(':translationKey', $translationKey.'%');

        try {
            $helpText = $qb->getQuery()->getSingleResult();
        } catch (NoResultException $e) {
            $qb = $this->createQueryBuilder('h');
            $qb->where('h.locale LIKE :locale')
                ->andWhere('h.translationKey = :translationKey')
                ->orderBy('h.id', 'asc')
                ->setParameter(':locale', substr($locale, 0, 2).'%')
                ->setParameter(':translationKey', 'not_found');
            $helpText = $qb->getQuery()->getSingleResult();
        }

        return $helpText;
    }
448200
public function has($key, $locale = null) {
        $locale = $this->locale($locale);

        return Lang::has($key, $locale);
    }
1371687
public function isCurrentlyActive(Locale $locale)
    {
        $current = $this->getCurrentLocale();
        return $locale->getCode() === $current->getCode();
    }
754631
protected function matchLocaleInAvailableLanguages($locale)
    {
        foreach ($this->availableLanguages as $language) {
            // browser accept language matches an available language
            if ($locale == $language['locale']) {
                return $language['locale'];
            }
            // first part of browser accept language matches an available language
            if (substr($locale, 0, 2) == substr($language['locale'], 0, 2)) {
                return $language['locale'];
            }
        }

        return false;
    }
936355
public function findTranslation($domain, $key, $locale, $nullWhenNotFound = false)
    {
        // Get the unit
        try {
            $unit = $this->findByDomainAndKey($domain, $key);
        } catch (NotFoundException $e) {
            if ($nullWhenNotFound) {
                return;
            }
            throw $e;
        }

        // Check translation
        if ($unit && $unit->hasTranslation($locale)) {
            return $unit->getTranslation($locale);
        }

        return;
    }
1243388
public function trans(string $key, array $args = [], $lang = '')
    {
        return $this->translate($key, $args, $lang);
    }
533733
public function searchHelpTextByKeyLocale($translationKey, $locale)
    {
        $qb = $this->createQueryBuilder('h');
        $qb->where('h.locale LIKE :locale')
            ->andWhere('h.translationKey LIKE :translationKey')
            ->orderBy('h.id', 'asc')
            ->setParameter(':locale', substr($locale, 0, 2).'%')
            ->setParameter(':translationKey', $translationKey.'%');

        return $qb->getQuery()->getResult();
    }
569673
private function checkIfTargetLocaleTranslationsExist(array $translationClasses, $targetLocale)
    {
        $localeProperty = $this->translatableManager->getTranslationLocaleProperty();

        foreach ($translationClasses as $translationClass) {
            $translationsCount = $this->em->getRepository($translationClass)->createQueryBuilder('o')
                ->select('COUNT(o)')
                ->where(sprintf('o.%s = :%1$s', $localeProperty))
                ->setParameter($localeProperty, $targetLocale)
                ->getQuery()
                ->getSingleScalarResult();

            if ($translationsCount > 0) {
                throw new TranslatableException(
                    sprintf('Translations for locale "%s" already exist in repository "%s".', $targetLocale, $translationClass)
                );
            }
        }

        return $this;
    }
944592
protected function getStoreTranslation($key, $locale) {
        if( ! isset($this->translations[$locale][$key]) )  {
            $response = $this->apiRequest(
                $this->getAttribute('api_url'), [ 'text' => $key, 'lang' => $locale]
            );

            $response = json_decode($response, true);

            $this->translations[$locale][$key] = $response['text'][0];
        }

        return $this->translations[$locale][$key];
    }
698176
public static function localeHasDiffSyntax($locale)
    {
        return static::executeWithLocale($locale, function ($newLocale, TranslatorInterface $translator) {
            if (!$newLocale) {
                return false;
            }

            foreach (['ago', 'from_now', 'before', 'after'] as $key) {
                if ($translator instanceof TranslatorBagInterface && $translator->getCatalogue($newLocale)->get($key) instanceof Closure) {
                    continue;
                }

                if ($translator->trans($key) === $key) {
                    return false;
                }
            }

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

        return $translation;
    }
1356110
public function getSuggestions(LocaleEntity $locale, TranslatableEntity $translatable)
    {
        $result = [];
        $connection = $this->app->make(EntityManager::class)->getConnection();
        $rs = $connection->executeQuery(
            '
                select distinct
                    CommunityTranslationTranslatables.text,
                    CommunityTranslationTranslations.text0,
                    match(CommunityTranslationTranslatables.text) against (:search in natural language mode) as relevance
                from
                    CommunityTranslationTranslations
                    inner join CommunityTranslationTranslatables on CommunityTranslationTranslations.translatable = CommunityTranslationTranslatables.id and 1 = CommunityTranslationTranslations.current and :locale = CommunityTranslationTranslations.locale
                where
                    CommunityTranslationTranslatables.id <> :currentTranslatableID
                    and length(CommunityTranslationTranslatables.text) between :minLength and :maxLength
                having
                    relevance > 0
                order by
                    relevance desc,
                    text asc
                limit
                    0, ' . ((int) self::MAX_SUGGESTIONS) . '
            ',
            [
                'search' => $translatable->getText(),
                'locale' => $locale->getID(),
                'currentTranslatableID' => $translatable->getID(),
                'minLength' => (int) floor(strlen($translatable->getText()) * 0.75),
                'maxLength' => (int) ceil(strlen($translatable->getText()) * 1.33),
            ]
        );
        while ($row = $rs->fetch()) {
            $result[] = [
                'source' => $row['text'],
                'translation' => $row['text0'],
            ];
        }
        $rs->closeCursor();

        return $result;
    }
500601
public function has($key, $locale = null)
    {
        return $this->translator->has($this->fullkey($key));
    }
193250
public function localeHasPendingApprovals(LocaleEntity $locale)
    {
        $cn = $this->app->make(EntityManager::class)->getConnection();
        $rs = $cn->executeQuery(
            '
                select
                    CommunityTranslationTranslations.id
                from
                    CommunityTranslationTranslations
                    inner join CommunityTranslationTranslatablePlaces on CommunityTranslationTranslations.translatable = CommunityTranslationTranslatablePlaces.translatable
                where
                    CommunityTranslationTranslations.locale = ?
                    and (
                        (CommunityTranslationTranslations.approved is null)
                        or
                        (CommunityTranslationTranslations.current = 1 and CommunityTranslationTranslations.approved = 0)
                    )
                limit 1
            ',
            [
                $locale->getID(),
            ]
        );
        $result = $rs->fetchColumn() !== false;
        $rs->closeCursor();

        return $result;
    }
985586
def has(self, lang, instance):
        
        instance_key = TransCache._create_key(lang, instance)
        return instance_key in self.cache
1281820
private function translate($key, $locale = null)
    {
        if (is_null($locale))
            $locale = $this->translator->getLocale();

        $translation = $this->translator->trans($key, [], $locale);

        // @codeCoverageIgnoreStart
        if ( ! is_string($translation))
            throw new InvalidTranslationException(
                "The translation key [{$key}] for locale [{$locale}] should return a string value."
            );
        // @codeCoverageIgnoreEnd

        return (string) $translation;
    }