菜单

Typo3 xlf/xml translation

2017年06月13日 - typo3
xlf:

/** @var $languageFactory LocalizationFactory */
        $languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
        $LOCAL_LANG = $languageFactory->getParsedData('EXT:sitebase/Resources/Private/Language/locallang.xlf', 'en', 'utf-8');
xml:

public function getTranslate($file, $key, $lang)
    {
        $xml = GeneralUtility::xml2array(file_get_contents($file));
        if (isset($xml['data'][$lang][$key])) {
            return $xml['data'][$lang][$key];
        } else {
            return $xml['data']['default'][$key];
        }
    }

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注