Project

General

Profile

Actions

Bug #29386

closed

L10n: locales dependency is not taken into account

Added by Xavier Perseguers over 12 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Should have
Category:
-
Target version:
Start date:
2011-08-31
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
4.6
PHP Version:
Tags:
Complexity:
medium
Is Regression:
Sprint Focus:

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

29386_v1.diff (7.09 KB) 29386_v1.diff Initial try Xavier Perseguers, 2011-08-31 16:48
29386_v2.diff (1.79 KB) 29386_v2.diff Xavier Perseguers, 2011-09-01 14:20

Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Feature #17368: Add a second language fallback in sysext/lang/Closed2007-06-08

Actions
Related to TYPO3 Core - Feature #39597: Multiple locale names for TS config.locale_allClosed2012-08-07

Actions
Actions #1

Updated by Xavier Perseguers over 12 years ago

  • File 29386_v1.diff added
Actions #2

Updated by Xavier Perseguers over 12 years ago

  • File deleted (29386_v1.diff)
Actions #3

Updated by Xavier Perseguers over 12 years ago

  • File 29386_v1.diff added
Actions #4

Updated by Xavier Perseguers over 12 years ago

  • File deleted (29386_v1.diff)
Actions #6

Updated by Xavier Perseguers over 12 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.

Actions #8

Updated by Mr. Hudson over 12 years ago

Patch set 1 of change Icb2789e9ad3c56b65d098fe136d898954e39a51c has been pushed to the review server.
It is available at http://review.typo3.org/4718

Actions #9

Updated by Xavier Perseguers over 12 years ago

  • Status changed from New to Under Review
  • Assignee set to Xavier Perseguers
Actions #10

Updated by Mr. Hudson over 12 years ago

Patch set 2 of change Icb2789e9ad3c56b65d098fe136d898954e39a51c has been pushed to the review server.
It is available at http://review.typo3.org/4718

Actions #11

Updated by Xavier Perseguers over 12 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.

Actions #12

Updated by Xavier Perseguers over 12 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);
}

Actions #13

Updated by Mr. Hudson over 12 years ago

Patch set 3 of change Icb2789e9ad3c56b65d098fe136d898954e39a51c has been pushed to the review server.
It is available at http://review.typo3.org/4718

Actions #14

Updated by Xavier Perseguers over 12 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #15

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF