[FEATURE] Add backend for loading translations via ajax
This commit is contained in:
@@ -141,6 +141,11 @@ class ActionController extends BaseController
|
||||
*/
|
||||
protected $propertyMapperConfigurationBuilder;
|
||||
|
||||
/**
|
||||
* translation extensions
|
||||
*/
|
||||
protected $translations = [];
|
||||
|
||||
/**
|
||||
* @param \TYPO3\CMS\Extbase\Service\ExtensionService $extensionService
|
||||
*/
|
||||
@@ -616,10 +621,26 @@ class ActionController extends BaseController
|
||||
$this->request->getControllerActionName(),
|
||||
$pluginArguments
|
||||
);
|
||||
$uriTranslation = $this->getControllerContext()
|
||||
->getUriBuilder()
|
||||
->reset()
|
||||
->setCreateAbsoluteUri(true)
|
||||
->setAddQueryString(true)
|
||||
->setTargetPageType(6001)
|
||||
->uriFor(
|
||||
'translations',
|
||||
[
|
||||
'extensions' => $this->translations,
|
||||
],
|
||||
'Translation',
|
||||
'TemplatesAide',
|
||||
'Translationplugin'
|
||||
);
|
||||
$this->ajaxEnv = [
|
||||
'uri' => $uri,
|
||||
'object' => $object,
|
||||
'namespace' => $this->getPluginNamespace(),
|
||||
'uri' => $uri,
|
||||
'uriTranslation' => $uriTranslation,
|
||||
'object' => $object,
|
||||
'namespace' => $this->getPluginNamespace(),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
57
Classes/Controller/TranslationController.php
Normal file
57
Classes/Controller/TranslationController.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace Cjel\TemplatesAide\Controller;
|
||||
|
||||
/***
|
||||
*
|
||||
* This file is part of the "Templates Aide" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* (c) 2024 Philipp Dieter <philippdieter@attic-media.net>
|
||||
*
|
||||
***/
|
||||
|
||||
use TYPO3\CMS\Core\Localization\LocalizationFactory;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* TranslationController
|
||||
*/
|
||||
class TranslationController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController
|
||||
{
|
||||
|
||||
protected static $locallangPath = 'Resources/Private/Language/';
|
||||
|
||||
/**
|
||||
* action translations
|
||||
*
|
||||
* @param array $extensions
|
||||
* @return void
|
||||
*/
|
||||
public function translationsAction($extensions = [])
|
||||
{
|
||||
$result = [];
|
||||
foreach ($extensions as $extension) {
|
||||
$langfilePath = 'EXT:'
|
||||
. GeneralUtility::camelCaseToLowerCaseUnderscored($extension)
|
||||
. '/'
|
||||
. self::$locallangPath
|
||||
. 'locallang.xlf';
|
||||
$languageFactory = GeneralUtility::makeInstance(
|
||||
LocalizationFactory::class
|
||||
);
|
||||
$langfileContent = $languageFactory->getParsedData(
|
||||
$langfilePath,
|
||||
$GLOBALS['LANG']->lang
|
||||
);
|
||||
$langfileResult = [];
|
||||
foreach (reset($langfileContent) as $key => $row) {
|
||||
$langfileResult[$key] = reset($row)['target'];
|
||||
}
|
||||
$result[$extension] = $langfileResult;
|
||||
}
|
||||
$GLOBALS['TSFE']->setContentType('application/json');
|
||||
return json_encode($result);
|
||||
}
|
||||
}
|
||||
20
Classes/Domain/Model/Translation.php
Normal file
20
Classes/Domain/Model/Translation.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace Cjel\TemplatesAide\Domain\Model;
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* This file is part of the "Templates Aide" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* (c) 2024 Philipp Dieter <philippdieter@attic-media.net>
|
||||
*
|
||||
***/
|
||||
/**
|
||||
* Translation
|
||||
*/
|
||||
class Translation extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user