Bug #29386
closedL10n: locales dependency is not taken into account
100%
Description
Localization support comes with a dependencies between locales. By default the main language is taken as "mother language":
fr_CA -> fr
pt_BR -> pt
A user may easily define his/her own locales dependency:
$TYPO3_CONF_VARS['SYS']['localization']['locales'] = array( 'dependencies' => array( 'fr_CA' => array('pt_BR', 'fr'), ), );
which would make 'fr_CA' depend on 'pt_BR' and then 'fr'.
These dependencies are taken into account when retrieving translations using the (new) Extension Manager but are not taken into account when retrieving a label in a given language.
It should naturally fall back on the dependency languages to search for missing label translations before using default English label.
Files
Updated by Xavier Perseguers over 13 years ago
- File 29386_v1.diff 29386_v1.diff added
Updated by Xavier Perseguers over 13 years ago
- Target version set to 4.6.0-beta3
IMPORTANT REMARK: This patch does not aim at allowing arbitrary fall-back from a TS perspective (allowing different fallbacks according to the position in page tree, typically in a multi-site context).
This is not the goal as it would be slightly more complicated and would introduce a new feature. This should hopefully be discussed for 4.7, in line with another, enhanced L10n API.
This feature allows Pootle to deliver files with only translated, accepted labels and provides a meaningful first step into a proper, generic, language fallback mechanism.
Updated by Xavier Perseguers over 13 years ago
- File 29386_v2.diff 29386_v2.diff added
Updated by Mr. Hudson over 13 years ago
Patch set 1 of change Icb2789e9ad3c56b65d098fe136d898954e39a51c has been pushed to the review server.
It is available at http://review.typo3.org/4718
Updated by Xavier Perseguers over 13 years ago
- Status changed from New to Under Review
- Assignee set to Xavier Perseguers
Updated by Mr. Hudson over 13 years ago
Patch set 2 of change Icb2789e9ad3c56b65d098fe136d898954e39a51c has been pushed to the review server.
It is available at http://review.typo3.org/4718
Updated by Xavier Perseguers over 13 years ago
When creating a wizard for new CE, typical code (including support of TYPO3 versions older than 4.6) looks as follows:
/** * Reads the extension locallang.xml and returns the $LOCAL_LANG array found in that file. * * @return array The array with language labels */ protected function includeLocalLang() { $version = class_exists('t3lib_utility_VersionNumber') ? t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) : t3lib_div::int_from_ver(TYPO3_version); if ($version < 4006000) { $llFile = t3lib_extMgm::extPath('egovapi') . 'Resources/Private/Language/locallang.xml'; $LOCAL_LANG = t3lib_div::readLLXMLfile($llFile, $GLOBALS['LANG']->lang); } else { $llFile = t3lib_extMgm::extPath('egovapi') . 'Resources/Private/Language/locallang.xlf'; /** @var $factory t3lib_l10n_Factory */ $factory = t3lib_div::makeInstance('t3lib_l10n_Factory'); $LOCAL_LANG = $factory->getParsedData($llFile, $GLOBALS['LANG']->lang, '', 1); } return $LOCAL_LANG; }
However the call to
$LOCAL_LANG = $factory->getParsedData($llFile, $GLOBALS['LANG']->lang, '', 1);
(where "1" stands for the errorMode "do nothing when file was not found") returns the English version of the labels if no translation is found for $GLOBALS['LANG']->lang.
It should fall back properly using the language dependency as well.
Updated by Xavier Perseguers over 13 years ago
After debugging this problem and thinking more about it, there is no need to further change the proposed patch.
Here is how a CE wizard should be updated to properly work with language dependencies:
/** * Reads the extension locallang.xml and returns the $LOCAL_LANG array found in that file. * * @return array The array with language labels */ protected function includeLocalLang() { $version = class_exists('t3lib_utility_VersionNumber') ? t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) : t3lib_div::int_from_ver(TYPO3_version); if ($version < 4006000) { $llFile = t3lib_extMgm::extPath('egovapi') . 'Resources/Private/Language/locallang.xml'; } else { $llFile = t3lib_extMgm::extPath('egovapi') . 'Resources/Private/Language/locallang.xlf'; } return $GLOBALS['LANG']->includeLLFile($llFile, FALSE); }
Updated by Mr. Hudson over 13 years ago
Patch set 3 of change Icb2789e9ad3c56b65d098fe136d898954e39a51c has been pushed to the review server.
It is available at http://review.typo3.org/4718
Updated by Xavier Perseguers over 13 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 24d05a390c42b2ebffbef2a7bf080e1bb6647948.
Updated by Riccardo De Contardi about 7 years ago
- Status changed from Resolved to Closed