[BUGFIX] Cannot use own translation with XLIFF
authorXavier Perseguers <xavier@typo3.org>
Mon, 29 Aug 2011 06:55:55 +0000 (08:55 +0200)
committerXavier Perseguers <xavier@typo3.org>
Tue, 30 Aug 2011 08:35:38 +0000 (10:35 +0200)
XLIFF files contains the definition for a single language. Additional languages cannot
be stored as when using ll-XML (locallang*.xml) files.

Allow localization files to be stored next to the main locallang*.xlf file, by prefixing
its name with the language key, just as for localization files retrieved from TYPO3
translation server.

Change-Id: If930350527077be33bdbeced9672f13793d1d8f4
Fixes: #29248
Releases: 4.6
Reviewed-on: http://review.typo3.org/4601
Reviewed-by: Björn Pedersen
Reviewed-by: Dominique Feyer
Tested-by: Dominique Feyer
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
t3lib/class.t3lib_div.php
t3lib/l10n/parser/class.t3lib_l10n_parser_abstractxml.php

index 60dddc7..187108c 100644 (file)
@@ -4463,11 +4463,17 @@ final class t3lib_div {
         *
         * @param string $fileRef Absolute file reference to locallang-XML file. Must be inside system/global/local extension
         * @param string $language Language key
+        * @param boolean $sameLocation if TRUE, then locallang-XML localization file name will be returned with same directory as $fileRef
         * @return string Returns the filename reference for the language unless error occured (or local mode is used) in which case it will be NULL
         */
-       public static function llXmlAutoFileName($fileRef, $language) {
+       public static function llXmlAutoFileName($fileRef, $language, $sameLocation = FALSE) {
+               if ($sameLocation) {
+                       $location = 'EXT:';
+               } else {
+                       $location = 'typo3conf/l10n/' . $language . '/'; // Default location of translations
+               }
+
                        // Analyse file reference:
-               $location = 'typo3conf/l10n/' . $language . '/'; // Default location of translations
                if (self::isFirstPartOfStr($fileRef, PATH_typo3 . 'sysext/')) { // Is system:
                        $validatedPrefix = PATH_typo3 . 'sysext/';
                        #$location = 'EXT:csh_'.$language.'/';  // For system extensions translations are found in "csh_*" extensions (language packs)
index f2dd2f9..167173d 100644 (file)
@@ -67,6 +67,12 @@ abstract class t3lib_l10n_parser_AbstractXml implements t3lib_l10n_parser {
                        $this->sourcePath = t3lib_div::getFileAbsFileName(
                                t3lib_div::llXmlAutoFileName($this->sourcePath, $this->languageKey)
                        );
+                       if (!@is_file($this->sourcePath)) {
+                                               // Global localization is not available, try split localization file
+                                       $this->sourcePath = t3lib_div::getFileAbsFileName(
+                                       t3lib_div::llXmlAutoFileName($sourcePath, $languageKey, TRUE)
+                               );
+                       }
 
                        if (!@is_file($this->sourcePath)) {
                                throw new t3lib_l10n_exception_FileNotFound(