concrete/src/Localization/Service/TranslationsInstaller.php
public function installMissingPackageTranslations(Package $package)
    {
        // Get the list of languages that users may need for the user interface.
        $wanted = Localization::getAvailableInterfaceLanguages();
        // Get the list of languages that users may need for the site locales.
        $siteService = $this->app->make(SiteService::class);
        $site = $siteService->getSite();
        if ($site) {
            foreach ($site->getLocales() as $locale) {
                $wanted[] = $locale->getLocale();
            }
        }
        $wanted = array_unique($wanted);
        $wanted = array_filter($wanted, function ($localeID) {
            return $localeID !== Localization::BASE_LOCALE;
        });
        $already = array_keys($this->localFactory->getAvailablePackageStats($package));
        $missing = array_diff($wanted, $already);
        $result = [];
        if (count($missing) > 0) {
            $available = $this->remoteProvider->getAvailablePackageStats($package->getPackageHandle(), $package->getPackageVersion());
            $toDownload = array_intersect($missing, array_keys($available));
            foreach ($missing as $missingID) {
                if (!in_array($missingID, $toDownload, true)) {
                    $result[$missingID] = false;
                } else {
                    try {
                        $this->installPackageTranslations($package, $missingID);
                        $result[$missingID] = true;
                    } catch (Exception $x) {
                        $result[$missingID] = $x;
                    }
                }
            }
        }

        return $result;
    }
public function installMissingPackageTranslations(Package $package)
    {
        // Get the list of languages that users may need for the user interface.
        $wanted = Localization::getAvailableInterfaceLanguages();
        // Get the list of languages that users may need for the site locales.
        $siteService = $this->app->make(SiteService::class);
        $site = $siteService->getSite();
        if ($site) {
            foreach ($site->getLocales() as $locale) {
                $wanted[] = $locale->getLocale();
            }
        }
        $wanted = array_unique($wanted);
        $wanted = array_filter($wanted, function ($localeID) {
            return $localeID !== Localization::BASE_LOCALE;
        });
        $already = array_keys($this->localFactory->getAvailablePackageStats($package));
        $missing = array_diff($wanted, $already);
        $result = [];
        if (count($missing) > 0) {
            $available = $this->remoteProvider->getAvailablePackageStats($package->getPackageHandle(), $package->getPackageVersion());
            $toDownload = array_intersect($missing, array_keys($available));
            foreach ($missing as $missingID) {
                if (!in_array($missingID, $toDownload, true)) {
                    $result[$missingID] = false;
                } else {
                    try {
                        $this->installPackageTranslations($package, $missingID);
                        $result[$missingID] = true;
                    } catch (Exception $x) {
                        $result[$missingID] = $x;
                    }
                }
            }
        }

        return $result;
    }
public function installMissingPackageTranslations ( Package $ package ) { // Get the list of languages that users may need for the user interface. $ wanted = Localization :: getAvailableInterfaceLanguages ( ) ; // Get the list of languages that users may need for the site locales. $ siteService = $ this -> app -> make ( SiteService :: class ) ; $ site = $ siteService -> getSite ( ) ; if ( $ site ) { foreach ( $ site -> getLocales ( ) as $ locale ) { $ wanted [ ] = $ locale -> getLocale ( ) ; } } $ wanted = array_unique ( $ wanted ) ; $ wanted = array_filter ( $ wanted , function ( $ localeID ) { return $ localeID !== Localization :: BASE_LOCALE ; } ) ; $ already = array_keys ( $ this -> localFactory -> getAvailablePackageStats ( $ package ) ) ; $ missing = array_diff ( $ wanted , $ already ) ; $ result = [ ] ; if ( count ( $ missing ) > 0 ) { $ available = $ this -> remoteProvider -> getAvailablePackageStats ( $ package -> getPackageHandle ( ) , $ package -> getPackageVersion ( ) ) ; $ toDownload = array_intersect ( $ missing , array_keys ( $ available ) ) ; foreach ( $ missing as $ missingID ) { if ( ! in_array ( $ missingID , $ toDownload , true ) ) { $ result [ $ missingID ] = false ; } else { try { $ this -> installPackageTranslations ( $ package , $ missingID ) ; $ result [ $ missingID ] = true ; } catch ( Exception $ x ) { $ result [ $ missingID ] = $ x ; } } } } return $ result ; }
Install missing package translation files.

@param Package $package

@return array array keys are the missing locale IDs, array values are: false (package not translated), true (language file downloaded), \Exception (in case of errors)
Install missing package translation files .