Commit 445ff455 authored by Nicole Cordes's avatar Nicole Cordes Committed by Morton Jonuschat
Browse files

[BUGFIX] Make language module accessible without internet connection

This patch adds the possibility to access the language module without
having an internet connection. You are able to activate and deactivate
languages but trying to update files will give you an error.

Resolves: #75820
Releases: master, 7.6
Change-Id: I27be7f34c76f680a4240e6c75c4a331d96467681
Reviewed-on: https://review.typo3.org/47840


Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
parent 9302d22c
......@@ -166,7 +166,7 @@ class LanguageController extends ActionController
$result = $this->translationService->updateTranslation($extensionKey, $data['locale']);
$progress = round((($offset + 1) * 100) / $allCount, 2);
$response['result'][$data['locale']][$extensionKey] = $result[$data['locale']];
if (empty($result[$extensionKey][$data['locale']]['error'])) {
if (empty($result[$data['locale']]['error'])) {
$response['success'] = true;
} else {
// Could not update an extension, stop here!
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Lang\Service;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
use TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException;
use TYPO3\CMS\Extensionmanager\Utility\Repository\Helper;
/**
......@@ -70,7 +71,11 @@ class TranslationService implements SingletonInterface
*/
public function injectRepositoryHelper(Helper $helper)
{
$this->mirrorUrl = $helper->getMirrors(false)->getMirrorUrl();
try {
$this->mirrorUrl = $helper->getMirrors(false)->getMirrorUrl();
} catch (ExtensionManagerException $e) {
$this->mirrorUrl = '';
}
}
/**
......@@ -108,15 +113,22 @@ class TranslationService implements SingletonInterface
* @param string $extensionKey The extension key
* @param string $locale Locale to update
* @return int Translation state
* @throws \Exception
*/
protected function updateTranslationForExtension($extensionKey, $locale)
{
if (empty($extensionKey) || empty($locale)) {
return static::TRANSLATION_INVALID;
}
$mirrorUrl = $this->getMirrorUrl($extensionKey);
if (empty($mirrorUrl)) {
throw new \Exception('Not able to fetch languages files due to missing mirror url.', 1461248062);
}
$state = static::TRANSLATION_FAILED;
$updateResult = $this->terService->updateTranslation($extensionKey, $locale, $this->getMirrorUrl($extensionKey));
$updateResult = $this->terService->updateTranslation($extensionKey, $locale, $mirrorUrl);
if ($updateResult === true) {
$state = static::TRANSLATION_UPDATED;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment