const TRANSLATION_FAILED = 2;
const TRANSLATION_OK = 3;
const TRANSLATION_INVALID = 4;
+ const TRANSLATION_UPDATED = 5;
/**
* @var \TYPO3\CMS\Lang\Domain\Repository\LanguageRepository
*/
protected $terConnection;
- /**
- * @var \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
- */
- protected $cache;
-
/**
* @var array
*/
- protected $icons = array();
-
- /**
- * Keep cache for one day
- * @var integer
- */
- protected $cacheLifetime = 86400;
+ protected $translationStates = array();
/**
* JSON actions
* @var array
*/
- protected $jsonActions = array('checkTranslation', 'updateTranslation');
+ protected $jsonActions = array('updateTranslation');
/**
* Inject the language repository
}
}
- /**
- * Initialize cache frontend
- *
- * @return void
- */
- public function initializeAction() {
- $cacheIdentifier = $this->request->getControllerExtensionKey();
- $cacheFrontend = $GLOBALS['typo3CacheManager'];
- if (!$cacheFrontend->hasCache($cacheIdentifier)) {
- throw new \Exception('The cache with identifier "' . $cacheIdentifier . '" is not available.', 1341301708);
- }
- $this->cache = $cacheFrontend->getCache($cacheIdentifier);
- }
-
/**
* Index action
*
$this->redirect('index');
}
-
/**
- * Check translation state for one extension
+ * Update translation for one extension
*
* @param string $extension The extension key
- * @param mixed $locales List or array of locales to check
- * @param boolean $update Update translations if is TRUE
+ * @param mixed $locales List or array of locales to update
* @return void
*/
- public function checkTranslationAction($extension, $locales, $update = FALSE) {
+ public function updateTranslationAction($extension, $locales) {
if (is_string($locales)) {
$locales = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $locales);
}
$state = static::TRANSLATION_INVALID;
try {
$state = $this->getTranslationStateForExtension($extension, $locale);
- if ($update && $state === static::TRANSLATION_AVAILABLE) {
+ if ($state === static::TRANSLATION_AVAILABLE) {
$state = $this->updateTranslationForExtension($extension, $locale);
}
} catch (\Exception $exception) {
$this->view->assign('locales', $locales);
}
- /**
- * Update translation for one extension
- *
- * @param string $extension The extension key
- * @param mixed $locales List or array of locales to update
- * @return void
- */
- public function updateTranslationAction($extension, $locales) {
- $this->checkTranslationAction($extension, $locales, TRUE);
- }
-
/**
* Returns the translation state for an extension
*
return static::TRANSLATION_INVALID;
}
- $identifier = 'translationState-' . $extensionKey . '-' . $locale;
- if ($this->cache->has($identifier)) {
- return $this->cache->get($identifier);
+ $identifier = $extensionKey . '-' . $locale;
+ if (isset($this->translationStates[$identifier])) {
+ return $this->translationStates[$identifier];
}
$selectedLanguages = $this->languageRepository->findSelected();
- if (empty($selectedLanguages)) {
+ if (empty($selectedLanguages) || !is_array($selectedLanguages)) {
return static::TRANSLATION_INVALID;
}
$mirrorUrl = $this->repositoryHelper->getMirrors()->getMirrorUrl();
$status = $this->terConnection->fetchTranslationStatus($extensionKey, $mirrorUrl);
- $states = array();
foreach ($selectedLanguages as $language) {
- $selectedLocale = $language->getLocale();
+ $stateLocale = $language->getLocale();
+ $stateIdentifier = $extensionKey . '-' . $stateLocale;
+ $this->translationStates[$stateIdentifier] = static::TRANSLATION_INVALID;
- if (empty($status[$selectedLocale]) || !is_array($status[$selectedLocale])) {
- $states[$selectedLocale] = static::TRANSLATION_NOT_AVAILABLE;
+ if (empty($status[$stateLocale]) || !is_array($status[$stateLocale])) {
+ $this->translationStates[$stateIdentifier] = static::TRANSLATION_NOT_AVAILABLE;
continue;
}
- $md5 = $this->getTranslationFileMd5($extensionKey, $selectedLocale);
- if ($md5 !== $status[$selectedLocale]['md5']) {
- $states[$selectedLocale] = static::TRANSLATION_AVAILABLE;
+ $md5 = $this->getTranslationFileMd5($extensionKey, $stateLocale);
+ if ($md5 !== $status[$stateLocale]['md5']) {
+ $this->translationStates[$stateIdentifier] = static::TRANSLATION_AVAILABLE;
continue;
}
- $states[$selectedLocale] = static::TRANSLATION_OK;
- }
-
- if (!isset($states[$locale])) {
- $states[$locale] = static::TRANSLATION_INVALID;
- }
-
- foreach ($states as $stateLocale => $state) {
- $identifier = 'translationState-' . $extensionKey . '-' . $stateLocale;
- $this->cache->set($identifier, $state, array(), $this->cacheLifetime);
+ $this->translationStates[$stateIdentifier] = static::TRANSLATION_OK;
}
- return $states[$locale];
+ return $this->translationStates[$identifier];
}
/**
$mirrorUrl = $this->repositoryHelper->getMirrors()->getMirrorUrl();
$updateResult = $this->terConnection->updateTranslation($extensionKey, $locale, $mirrorUrl);
if ($updateResult === TRUE) {
- $state = static::TRANSLATION_OK;
+ $state = static::TRANSLATION_UPDATED;
}
- $identifier = 'translationState-' . $extensionKey . '-' . $locale;
- $this->cache->set($identifier, $state, array(), $this->cacheLifetime);
-
return $state;
}
<trans-unit id="state.notAvailable" xml:space="preserve">
<source>Not available</source>
</trans-unit>
- <trans-unit id="state.updateAvailable" xml:space="preserve">
- <source>Update available</source>
- </trans-unit>
<trans-unit id="state.failed" xml:space="preserve">
<source>Failed</source>
</trans-unit>
<trans-unit id="state.invalid" xml:space="preserve">
<source>Invalid</source>
</trans-unit>
+ <trans-unit id="state.updated" xml:space="preserve">
+ <source>Updated</source>
+ </trans-unit>
<trans-unit id="state.checking" xml:space="preserve">
<source>Checking...</source>
</trans-unit>
<source>Not checked</source>
</trans-unit>
- <trans-unit id="button.check" xml:space="preserve">
- <source>Check against repository</source>
- </trans-unit>
<trans-unit id="button.update" xml:space="preserve">
<source>Update from repository</source>
</trans-unit>
<trans-unit id="flashmessage.multipleErrors" xml:space="preserve">
<source>Several requests have been failed. Please check your internet connection!</source>
</trans-unit>
- <trans-unit id="flashmessage.checkComplete" xml:space="preserve">
- <source>The translation check has been successfully completed.</source>
- </trans-unit>
<trans-unit id="flashmessage.updateComplete" xml:space="preserve">
<source>The translation update has been successfully completed.</source>
</trans-unit>
1: 'flashmessage.information',
2: 'flashmessage.success',
3: 'flashmessage.multipleErrors',
- 4: 'flashmessage.checkComplete',
- 5: 'flashmessage.updateComplete',
- 6: 'flashmessage.canceled'
+ 4: 'flashmessage.updateComplete',
+ 5: 'flashmessage.canceled'
}"
>
<div class="typo3-fullDoc">
<f:for each="{extensions}" as="extension">
<tr
class="translationListRow"
- data-checkurl="<f:uri.action action="checkTranslation" arguments="{extension:'{extension.key}', locales:'{languageSelectionForm.selectedLanguagesLocaleList}'}" />"
data-updateurl="<f:uri.action action="updateTranslation" arguments="{extension:'{extension.key}', locales:'{languageSelectionForm.selectedLanguagesLocaleList}'}" />"
>
<td class="icon">
class="language languageStateNone translationListCell"
data-extension="{extension.key}"
data-locale="{selectedLanguage.locale}"
- data-checkurl="<f:uri.action action="checkTranslation" arguments="{extension:'{extension.key}', locales:'{selectedLanguage.locale}'}" />"
data-updateurl="<f:uri.action action="updateTranslation" arguments="{extension:'{extension.key}', locales:'{selectedLanguage.locale}'}" />"
>
<span class="stateIconNone"><f:translate key="state.notChecked"/></span>
<f:section name="iconButtons">
<span class="menuItem updateItem"><lang:be.spriteIcon icon="actions-system-extension-download" title="{f:translate(key:'button.update')}" /><f:translate key="button.update"/></span>
- <span class="menuItem checkItem"><lang:be.spriteIcon icon="actions-system-refresh" title="{f:translate(key:'button.check')}" /><f:translate key="button.check"/></span>
-
<span class="menuItem cancelItem"><lang:be.spriteIcon icon="status-status-permission-denied" title="{f:translate(key:'button.cancel')}" /><f:translate key="button.cancel"/></span>
</f:section>
<span class="stateIcon" id="stateIcon4">
<lang:be.spriteIcon icon="status-status-permission-denied" /><f:translate key="state.invalid"/>
</span>
+ <span class="stateIcon" id="stateIcon5">
+ <lang:be.spriteIcon icon="status-status-checked" /><f:translate key="state.updated"/>
+ </span>
<span class="stateIcon" id="stateIconChecking">
<span class="stateIconChecking"><f:translate key="state.checking"/></span>
</span>
available: 1,
failed: 2,
ok: 3,
- invalid: 4
+ invalid: 4,
+ updated: 5
},
/**
* Execute AJAX call for given cell of the translation matrix
*
* @param mixed cell The cell to process
- * @param string type Type of the AJAX call
* @return void
*/
- processCell: function(cell, type) {
+ processCell: function(cell) {
// Intialize
var $cell = jQuery(cell);
languageModule.toggleEventHandlers('off');
$cell.html(jQuery('#stateIconChecking').html());
// Process AJAX call
- languageModule.executeAjaxCall($cell.data(type + 'url'), function(response, error) {
+ languageModule.executeAjaxCall($cell.data('updateurl'), function(response, error) {
var state = 'Error';
if (error === undefined || error === null) {
var locale = $cell.data('locale');
return;
}
languageModule.updateCellState($cell, state);
- languageModule.displaySuccess('flashmessage.' + type + 'Complete');
+ languageModule.displaySuccess('flashmessage.updateComplete');
languageModule.toggleEventHandlers('on');
});
},
* Execute AJAX calls for given rows of the translation matrix
*
* @param mixed rows Rows to process
- * @param string type Type of the AJAX call
* @return void
*/
- processRows: function(rows, type) {
+ processRows: function(rows) {
// Intialize processing within first run
if (rows) {
languageModule.addElementsToStack(rows);
// Stop processing if stack is empty
if (languageModule.isStackEmpty()) {
- languageModule.displaySuccess('flashmessage.' + type + 'Complete');
+ languageModule.displaySuccess('flashmessage.updateComplete');
languageModule.toggleEventHandlers('on');
return;
}
$cells.html(jQuery('#stateIconChecking').html());
// Process AJAX call
- languageModule.executeAjaxCall($row.data(type + 'url'), function(response, error) {
+ languageModule.executeAjaxCall($row.data('updateurl'), function(response, error) {
if (error !== undefined && error !== null) {
$cells.html(jQuery('#stateIconError').html());
if (error === 'abort') {
languageModule.updateCellState($cell, state);
});
}
- languageModule.processRows(null, type);
+ languageModule.processRows();
});
},
var className = 'waiting';
var fadeSpeed = 150;
if (action === 'on') {
- jQuery('.checkItem').on('click', languageModule.checkTranslations).removeClass(className);
jQuery('.updateItem').on('click', languageModule.updateTranslations).removeClass(className);
jQuery('.cancelItem').off().fadeOut(fadeSpeed);
jQuery('.selectionList input, .selectionList label').off().parent().removeClass(className);
jQuery('.selectionList input:checkbox').on('change', languageModule.submitSelectionForm);
jQuery('.selectionList tr, .selectionList td').removeClass(className);
jQuery('.translationList tr, .translationList td').removeClass(className);
- jQuery('.languageState1').on('click', function() {
- languageModule.updateSingleTranslation(this);
- });
jQuery('.languageStateNone').on('click', function() {
- languageModule.checkSingleTranslation(this);
+ languageModule.updateSingleTranslation(this);
});
} else {
- jQuery('.checkItem').off().addClass(className);
jQuery('.updateItem').off().addClass(className);
jQuery('.cancelItem').on('click', languageModule.cancelProcess).fadeIn(fadeSpeed);
jQuery('.selectionList input:checkbox').off();
}).parent().addClass(className);
jQuery('.selectionList tr, .selectionList td').addClass(className);
jQuery('.translationList tr, .translationList td').addClass(className);
- jQuery('.languageState1').off();
jQuery('.languageStateNone').off();
}
},
jQuery('form[name="languageSelectionForm"]').submit();
},
- /**
- * Check for new translations
- *
- * @return void
- */
- checkTranslations: function() {
- languageModule.processRows('.translationListRow', 'check');
- },
-
- /**
- * Check for new translation for a single element
- *
- * @return void
- */
- checkSingleTranslation: function(element) {
- languageModule.processCell(element, 'check');
- },
-
/**
* Update translations
*
* @return void
*/
updateTranslations: function() {
- languageModule.processRows('.translationListRow', 'update');
+ languageModule.processRows('.translationListRow');
},
/**
* @return void
*/
updateSingleTranslation: function(element) {
- languageModule.processCell(element, 'update');
+ languageModule.processCell(element);
},
/**
}
// Register Ajax call
$GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX']['lang::clearCache'] = 'TYPO3\CMS\Lang\LanguageCacheClearer->clearCache';
-
- // Register cache
-if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$_EXTKEY])
- || !is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$_EXTKEY])) {
- $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$_EXTKEY] = array();
-}
?>
\ No newline at end of file
'after:extensionmanager', // Position
array(
// An array holding the controller-action-combinations that are accessible
- 'Language' => 'index, updateLanguageSelection, checkTranslation, updateTranslation'
+ 'Language' => 'index, updateLanguageSelection, updateTranslation'
),
array(
'access' => 'admin',