Commit 7c7fc897 authored by Stefan Galinski's avatar Stefan Galinski 🎮
Browse files

[BUGFIX] Chinese can't be translated by editors

parent 08dbe8b2
......@@ -47,7 +47,7 @@ class ConfigurationService extends AbstractService {
* @var array extension configuration
* @see prepareConfig()
*/
protected $extConfig = array();
protected $extConfig = [];
/**
* @var string
......@@ -57,7 +57,7 @@ class ConfigurationService extends AbstractService {
/**
* @var array
*/
protected $langArray = array();
protected $langArray = [];
/**
* @var \SGalinski\Lfeditor\Service\FileBaseService
......@@ -99,7 +99,7 @@ class ConfigurationService extends AbstractService {
$this->extConfig['anzBackup'] = 5;
// Options for number of constants presented on EditFile page
$this->extConfig['numSiteConstsOptions']
= array('10' => 10, '20' => 20, '50' => 50, '100' => 100, '150' => 150, '200' => 200);
= ['10' => 10, '20' => 20, '50' => 50, '100' => 100, '150' => 150, '200' => 200];
// paths and files (dont need to exist)
$this->extConfig['pathBackup'] = Typo3Lib::fixFilePath(
......@@ -122,7 +122,7 @@ class ConfigurationService extends AbstractService {
$langs = GeneralUtility::trimExplode(',', $this->extConfig['viewLanguages'], TRUE);
unset($this->extConfig['viewLanguages']);
$availableLanguageKeys = array();
$availableLanguageKeys = [];
if (GeneralUtility::compat_version('6.0')) {
/** @var Locales $locales */
$locales = GeneralUtility::makeInstance('TYPO3\CMS\Core\Localization\Locales');
......@@ -174,7 +174,7 @@ class ConfigurationService extends AbstractService {
*/
public function menuExtList() {
// search extensions
$tmpExtList = array();
$tmpExtList = [];
try {
// local extensions
if ($this->extConfig['viewLocalExt']) {
......@@ -226,7 +226,7 @@ class ConfigurationService extends AbstractService {
// create list
/** @var array $extList */
$extList = Functions::prepareExtList($tmpExtList);
$extList = array_merge(array(PATH_site . 'fileadmin' => 'fileadmin/', ''), $extList);
$extList = array_merge([PATH_site . 'fileadmin' => 'fileadmin/', ''], $extList);
foreach ($extList as $extAddress => $extLabel) {
unset ($extList[$extAddress]);
......@@ -263,7 +263,7 @@ class ConfigurationService extends AbstractService {
);
}
$fileArray = array();
$fileArray = [];
if (count($files)) {
foreach ($files as $file) {
$filename = substr($file, strlen($extensionAddress) + 1);
......@@ -291,7 +291,7 @@ class ConfigurationService extends AbstractService {
) {
// build languages
$languageArray = $this->getLangArray($backendUser);
$languageList = array();
$languageList = [];
foreach ($languageArray as $language) {
$constCount = 0;
if (is_array($langData[$language])) {
......@@ -310,7 +310,7 @@ class ConfigurationService extends AbstractService {
// add default value
if (!empty($default)) {
$languageList = array_merge(array('###default###' => $default), $languageList);
$languageList = array_merge(['###default###' => $default], $languageList);
}
return $languageList;
}
......@@ -324,7 +324,7 @@ class ConfigurationService extends AbstractService {
*/
public function menuConstList($langData, $default) {
// generate constant list
$constList = array();
$constList = [];
$languages = Functions::buildLangArray();
foreach ($languages as $language) {
if (!is_array($langData[$language]) || !count($langData[$language])) {
......@@ -340,7 +340,7 @@ class ConfigurationService extends AbstractService {
// sorting and default entry
asort($constList);
$constList = array_merge(array('###default###' => $default), $constList);
$constList = array_merge(['###default###' => $default], $constList);
return $constList;
}
......@@ -398,7 +398,7 @@ class ConfigurationService extends AbstractService {
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @return void
*/
public function execWrite($modArray, $modMetaArray = array(), $forceDel = FALSE, $editedLanguages = NULL) {
public function execWrite($modArray, $modMetaArray = [], $forceDel = FALSE, $editedLanguages = NULL) {
// checks
if (!is_array($modArray)) {
throw new LFException('failure.file.notWritten');
......@@ -444,7 +444,7 @@ class ConfigurationService extends AbstractService {
// delete possible language files
$absFile = $fileObject->getVar('absFile');
$originLang = $fileObject->getOriginLangData();
$emptyFiles = array();
$emptyFiles = [];
foreach ($originLang as $lang => $origin) {
if ($origin == $absFile || !is_file($origin)) {
continue;
......@@ -485,7 +485,7 @@ class ConfigurationService extends AbstractService {
}
// rewrite originLang array
$delLangFiles = array();
$delLangFiles = [];
foreach ($langModes as $langKey => $mode) {
if ($langKey == 'default') {
continue;
......@@ -524,7 +524,7 @@ class ConfigurationService extends AbstractService {
}
// write new language file
$this->execWrite(array());
$this->execWrite([]);
// delete old localized files, if single mode was selected
try {
......@@ -679,10 +679,10 @@ class ConfigurationService extends AbstractService {
$languages = $this->narrowToUserLanguages($languages, $backendUser);
if (!in_array('default', $languages)) {
$languages = array_merge(array('default'), $languages);
$languages = array_merge(['default'], $languages);
}
if (!in_array($this->extConfig['defaultLanguage'], $languages)) {
$languages = array_merge(array($this->extConfig['defaultLanguage']), $languages);
$languages = array_merge([$this->extConfig['defaultLanguage']], $languages);
}
$this->langArray = $languages;
}
......
......@@ -55,7 +55,7 @@ class SysLanguageService extends AbstractService {
($uids !== NULL ? 'uid IN (' . $typo3Db->cleanIntList($uids) . ')' : ''),
'flag ASC'
);
$sysLanguageList = array();
$sysLanguageList = [];
while ($row = $typo3Db->sql_fetch_assoc($res)) {
$sysLanguageList[$row['flag']]['uid'] = $row['uid'];
$sysLanguageList[$row['flag']]['title'] = $row['title'];
......@@ -73,6 +73,22 @@ class SysLanguageService extends AbstractService {
}
}
/**
* Returns the iso reverse mapped flag language or the given value if nothing could be mapped.
*
* @param string $flag language acronym (iso language code, e.g.: 'de', 'da', 'fi'...)
* @return string
*/
public function doIsoReverseMapping($flag) {
$isoReverseMapping = $this->getIsoReverseMapping();
$mappedFlag = (string) $isoReverseMapping[$flag];
if ($mappedFlag !== '') {
$flag = $mappedFlag;
}
return $flag;
}
/**
* Returns system language id for given language acronym ($flag).
* If that language is not registered in system, function returns NULL.
......@@ -82,15 +98,19 @@ class SysLanguageService extends AbstractService {
*/
public function getSysLanguageIdByFlag($flag) {
$this->initSysLanguageList();
$isoReverseMapping = $this->getIsoReverseMapping();
$mappedFlag = (string) $isoReverseMapping[$flag];
if ($mappedFlag !== '') {
$flag = $mappedFlag;
$flag = $this->doIsoReverseMapping($flag);
// chinese seems to have a big mapping issue. In general it seems that the iso handling is currently more
// or less simply fucked up in TYPO3. Also it's possible that I don't get the bigger picture here. Who knows...
// Also note: Chinese isn't working without a default file in the override mode.
if ($flag === 'zh') {
$flag = 'cn';
}
if (!empty($this->sysLanguageList[$flag]['uid'])) {
return (int) $this->sysLanguageList[$flag]['uid'];
}
return NULL;
}
......
Markdown is supported
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