Finds a shipping by id and locale
@param $id
@param $locale
@return Shipping|null
491520
public function findByIdAndLocale($id, $locale)
    {
        try {
            $qb = $this->getShippingQuery($locale);
            $qb->andWhere('shipping.id = :shippingId');
            $qb->setParameter('shippingId', $id);

            return $qb->getQuery()->getSingleResult();
        } catch (NoResultException $exc) {
            return null;
        }
    }
219455
private function getSiteByLocale ($locale)
	{
		$sites = \Craft::$app->sites;

		if ($locale === null)
			return static::$sitesByOldLocale[$locale] = $sites->primarySite;

		if (array_key_exists($locale, static::$sitesByOldLocale))
			return static::$sitesByOldLocale[$locale];

		$handle = $this->locale2handle($locale);

		$siteId = (new Query())
			->select('id')
			->from(Table::SITES)
			->where(['like', 'handle', '%' . $handle])
			->column();

		if (!empty($siteId))
			return static::$sitesByOldLocale[$locale] = $sites->getSiteById($siteId[0]);

		return static::$sitesByOldLocale[$locale] = $sites->primarySite;
	}
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;
    }
1037264
public function findByOrderId($orderId, $locale)
    {
        $result = array();
        $items = $this->getShippingRepository()->findByOrderId($orderId, $locale);
        foreach ($items as $item) {
            $result[] = $this->shippingFactory->createApiEntity($item, $locale);
        }
        return $result;
    }
553442
public function findContactsByAccountId($id, $locale, $onlyFetchMainAccounts = false)
    {
        $contactsEntities = $this->contactRepository->findByAccountId(
            $id,
            null,
            false,
            $onlyFetchMainAccounts
        );

        if (!empty($contactsEntities)) {
            $contacts = [];
            foreach ($contactsEntities as $contact) {
                $contacts[] = new Contact($contact, $locale);
            }

            return $contacts;
        }

        return;
    }
1069418
public function findByLocale(string $locale): ICollection
	{
		$builder = $this->builder()
			->innerJoin('_pages', '[_locales]', 'l', '_pages.localeId = l.id')
			->andWhere('[url] IS NOT NULL')
			->andWhere('[visible] = %i', 1)
			->andWhere('[l.name] = %s', $locale);
		return $this->toCollection($builder);
	}
397690
public function findAllByLocale($locale)
    {
        try {
            $qb = $this->getUnitQuery($locale)
                ->orderBy('unitTranslations.name', 'ASC');

            return $qb->getQuery()->getResult();
        } catch (NoResultException $exc) {
            return null;
        }
    }
555344
protected function fetchProduct($id, $locale)
    {
        $product = $this->productRepository->findByIdAndLocale($id, $locale);

        if (!$product) {
            throw new ProductNotFoundException($id);
        }

        return $this->productFactory->createApiEntity($product, $locale);
    }
187759
public function findByLocale($locale)
    {
        // Get sanitized locale
        $locale = Locale::sanitizeLocale($locale);

        return isset($this->available[$locale]) ? $this->available[$locale] : null;
    }
208702
public function findAll($locale)
    {
        $statuses = $this->deliveryStatusRepository->findAllByLocale($locale);

        array_walk(
            $statuses,
            function (&$status) use ($locale) {
                $status = new DeliveryStatus($status, $locale);
            }
        );

        return $statuses;
    }
473657
public function findById($id, $locale)
    {
        $currency = $this->currencyRepository->findById($id);

        return new Currency($currency, $locale);
    }
108692
public function findApproved($localeID)
    {
        $result = null;
        if (is_string($localeID) && $localeID !== '') {
            $l = $this->find($localeID);
            if ($l !== null && $l->isApproved() && !$l->isSource()) {
                $result = $l;
            }
        }

        return $result;
    }
4096
private function getTranslationsForDomainAndIds($locale, $domain, $ids)
    {
        /** @var Translator $translator */
        $translator = $this->container->get('translator');

        $translations = [];
        foreach ($ids as $id) {
            $translations[$id] = $translator->trans($id, [], $domain, $locale);
        }

        return $translations;
    }
426603
public function findFromLocalReferenceId($localId, $itemType)
    {
        /** @var $item IAmazonReferenceId */
        foreach ($this->idLists[$itemType] as $item) {
            if ($localId === $item->getLocalId()) {
                reset($this->idLists);

                return $item;
            }
        }

        return null;
    }
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;
    }
691736
final protected function trans($id, array $parameters = [], $domain = null, $locale = null)
    {
        $domain = $domain ?: $this->admin->getTranslationDomain();

        return $this->get('translator')->trans($id, $parameters, $domain, $locale);
    }
150020
public function getByUrl(?string $url, $locale): ?Page
	{
		/* @var $orm Orm */
		$orm = $this->getRepository()->getModel();
		if ($locale instanceof Locale) {
			$eLocale = $locale;
		} else {
			$eLocale = $orm->locales->getByLocale($locale);
		}

		$urls = $this->getPageList();
		if (isset($urls[$url])) {
			$builder = $this->builder()
				->andWhere('[id] = %i', $urls[$url])
				->andWhere('[localeId] = %i', $eLocale->id);
			return $this->toEntity($builder);
		}
		return null;
	}