public function getPackageVersionTranslations($packageHandle, $packageVersion, $localeID, $formatHandle)
    {
        $this->start();
        try {
            $this->getUserControl()->checkRateLimit();
            $accessibleLocales = $this->getUserControl()->checkLocaleAccess(__FUNCTION__);
            $locale = $this->app->make(LocaleRepository::class)->findApproved($localeID);
            if ($locale === null) {
                throw new UserMessageException(t('Unable to find the specified locale'), Response::HTTP_NOT_FOUND);
            }
            if (!in_array($locale, $accessibleLocales, true)) {
                throw AccessDeniedException::create(t('Access denied to the specified locale'));
            }
            $package = $this->app->make(PackageRepository::class)->findOneBy(['handle' => $packageHandle]);
            if ($package === null) {
                throw new UserMessageException(t('Unable to find the specified package'), Response::HTTP_NOT_FOUND);
            }
            $version = $this->getPackageVersion($package, $packageVersion);
            if ($version === null) {
                throw new UserMessageException(t('Unable to find the specified package version'), Response::HTTP_NOT_FOUND);
            }
            $format = $this->app->make(TranslationsConverterProvider::class)->getByHandle($formatHandle);
            if ($format === null) {
                throw new UserMessageException(t('Unable to find the specified translations format'), Response::HTTP_NOT_FOUND);
            }
            $translationsFile = $this->app->make(TranslationsFileExporter::class)->getSerializedTranslationsFile($version, $locale, $format);
            $this->app->make(DownloadStatsRepository::class)->logDownload($locale, $version);
            $result = BinaryFileResponse::create(
                // $file
                $translationsFile,
                // $status
                Response::HTTP_OK,
                // $headers
                [
                    'Content-Type' => 'application/octet-stream',
                    'Content-Transfer-Encoding' => 'binary',
                ]
            )->setContentDisposition(
                'attachment',
                'translations-' . $locale->getID() . '.' . $format->getFileExtension()
            );
        } catch (Exception $x) {
            $result = $this->buildErrorResponse($x);
        } catch (Throwable $x) {
            $result = $this->buildErrorResponse($x);
        }

        return $this->finish($result);
    }
public function getPackageVersionTranslations($packageHandle, $packageVersion, $localeID, $formatHandle)
    {
        $this->start();
        try {
            $this->getUserControl()->checkRateLimit();
            $accessibleLocales = $this->getUserControl()->checkLocaleAccess(__FUNCTION__);
            $locale = $this->app->make(LocaleRepository::class)->findApproved($localeID);
            if ($locale === null) {
                throw new UserMessageException(t('Unable to find the specified locale'), Response::HTTP_NOT_FOUND);
            }
            if (!in_array($locale, $accessibleLocales, true)) {
                throw AccessDeniedException::create(t('Access denied to the specified locale'));
            }
            $package = $this->app->make(PackageRepository::class)->findOneBy(['handle' => $packageHandle]);
            if ($package === null) {
                throw new UserMessageException(t('Unable to find the specified package'), Response::HTTP_NOT_FOUND);
            }
            $version = $this->getPackageVersion($package, $packageVersion);
            if ($version === null) {
                throw new UserMessageException(t('Unable to find the specified package version'), Response::HTTP_NOT_FOUND);
            }
            $format = $this->app->make(TranslationsConverterProvider::class)->getByHandle($formatHandle);
            if ($format === null) {
                throw new UserMessageException(t('Unable to find the specified translations format'), Response::HTTP_NOT_FOUND);
            }
            $translationsFile = $this->app->make(TranslationsFileExporter::class)->getSerializedTranslationsFile($version, $locale, $format);
            $this->app->make(DownloadStatsRepository::class)->logDownload($locale, $version);
            $result = BinaryFileResponse::create(
                // $file
                $translationsFile,
                // $status
                Response::HTTP_OK,
                // $headers
                [
                    'Content-Type' => 'application/octet-stream',
                    'Content-Transfer-Encoding' => 'binary',
                ]
            )->setContentDisposition(
                'attachment',
                'translations-' . $locale->getID() . '.' . $format->getFileExtension()
            );
        } catch (Exception $x) {
            $result = $this->buildErrorResponse($x);
        } catch (Throwable $x) {
            $result = $this->buildErrorResponse($x);
        }

        return $this->finish($result);
    }
public function getPackageVersionTranslations ( $ packageHandle , $ packageVersion , $ localeID , $ formatHandle ) { $ this -> start ( ) ; try { $ this -> getUserControl ( ) -> checkRateLimit ( ) ; $ accessibleLocales = $ this -> getUserControl ( ) -> checkLocaleAccess ( __FUNCTION__ ) ; $ locale = $ this -> app -> make ( LocaleRepository :: class ) -> findApproved ( $ localeID ) ; if ( $ locale === null ) { throw new UserMessageException ( t ( 'Unable to find the specified locale' ) , Response :: HTTP_NOT_FOUND ) ; } if ( ! in_array ( $ locale , $ accessibleLocales , true ) ) { throw AccessDeniedException :: create ( t ( 'Access denied to the specified locale' ) ) ; } $ package = $ this -> app -> make ( PackageRepository :: class ) -> findOneBy ( [ 'handle' => $ packageHandle ] ) ; if ( $ package === null ) { throw new UserMessageException ( t ( 'Unable to find the specified package' ) , Response :: HTTP_NOT_FOUND ) ; } $ version = $ this -> getPackageVersion ( $ package , $ packageVersion ) ; if ( $ version === null ) { throw new UserMessageException ( t ( 'Unable to find the specified package version' ) , Response :: HTTP_NOT_FOUND ) ; } $ format = $ this -> app -> make ( TranslationsConverterProvider :: class ) -> getByHandle ( $ formatHandle ) ; if ( $ format === null ) { throw new UserMessageException ( t ( 'Unable to find the specified translations format' ) , Response :: HTTP_NOT_FOUND ) ; } $ translationsFile = $ this -> app -> make ( TranslationsFileExporter :: class ) -> getSerializedTranslationsFile ( $ version , $ locale , $ format ) ; $ this -> app -> make ( DownloadStatsRepository :: class ) -> logDownload ( $ locale , $ version ) ; $ result = BinaryFileResponse :: create ( // $file $ translationsFile , // $status Response :: HTTP_OK , // $headers [ 'Content-Type' => 'application/octet-stream' , 'Content-Transfer-Encoding' => 'binary' , ] ) -> setContentDisposition ( 'attachment' , 'translations-' . $ locale -> getID ( ) . '.' . $ format -> getFileExtension ( ) ) ; } catch ( Exception $ x ) { $ result = $ this -> buildErrorResponse ( $ x ) ; } catch ( Throwable $ x ) { $ result = $ this -> buildErrorResponse ( $ x ) ; } return $ this -> finish ( $ result ) ; }
Get the translations of a package version.


@param string $packageHandle
@param string $packageVersion
@param string $localeID
@param string $formatHandle

@return Response

@example http://www.example.com/api/package/concrete5/8.2/translations/it_IT/mo/
@example http://www.example.com/api/package/concrete5/best-match-version/translations/it_IT/mo/?v=8.2rc1
Get the translations of a package version .