Bug #44273 ยป 44273_v46.diff

Patch for TYPO3 4.6 - Xavier Perseguers, 2013-01-02 19:02

View differences:

t3lib/class.t3lib_pagerenderer.php
53 53
	protected $locales;
54 54
	protected $lang;
55 55

  
56
	/**
57
	 * List of language dependencies for actual language. This is used for local variants of a language
58
	 * that depend on their "main" language, like Brazilian Portuguese or Canadian French.
59
	 *
60
	 * @var array
61
	 */
62
	protected $languageDependencies = array();
63

  
56 64
	/** @var t3lib_Compressor $compressor */
57 65
	protected $compressor;
58 66

  
......
252 260
	 */
253 261
	public function setLanguage($lang) {
254 262
		$this->lang = $lang;
263
		$this->languageDependencies = array();
264

  
265
		// Language is found. Configure it:
266
		if (in_array($this->lang, $this->locales->getLocales())) {
267
			$this->languageDependencies[] = $this->lang;
268
			foreach ($this->locales->getLocaleDependencies($this->lang) as $language) {
269
				$this->languageDependencies[] = $language;
270
			}
271
		}
255 272
	}
256 273

  
257 274
	/**
......
1885 1902
		}
1886 1903

  
1887 1904
		$labelsFromFile = array();
1888
		$allLabels = t3lib_div::readLLfile($fileRef, $this->lang, $this->charSet, $errorMode);
1905
		$allLabels = $this->readLLfile($fileRef, $errorMode);
1889 1906

  
1890 1907
			// Regular expression to strip the selection prefix and possibly something from the label name:
1891 1908
		$labelPattern = '#^' . preg_quote($selectionPrefix, '#') . '(' . preg_quote($stripFromSelectionName, '#') . ')?#';
......
1912 1929
		}
1913 1930
	}
1914 1931

  
1932
	/**
1933
	 * Reads a locallang file.
1934
	 *
1935
	 * @param string $fileRef Reference to a relative filename to include.
1936
	 * @param integer $errorMode Error mode (when file could not be found): 0 - syslog entry, 1 - do nothing, 2 - throw an exception
1937
	 * @return array Returns the $LOCAL_LANG array found in the file. If no array found, returns empty array.
1938
	 */
1939
	protected function readLLfile($fileRef, $errorMode = 0) {
1940
		if ($this->lang !== 'default') {
1941
			$languages = array_reverse($this->languageDependencies);
1942
			// At least we need to have English
1943
			if (empty($languages)) {
1944
				$languages[] = 'default';
1945
			}
1946
		} else {
1947
			$languages = array('default');
1948
		}
1949

  
1950
		$localLanguage = array();
1951
		foreach ($languages as $language) {
1952
			$tempLL = t3lib_div::readLLfile($fileRef, $language, $this->charSet, $errorMode);
1953
			$localLanguage['default'] = $tempLL['default'];
1954
			if (!isset($localLanguage[$this->lang])) {
1955
				$localLanguage[$this->lang] = $localLanguage['default'];
1956
			}
1957
			if ($this->lang !== 'default' && isset($tempLL[$language])) {
1958
				// Merge current language labels onto labels from previous language
1959
				// This way we have a labels with fall back applied
1960
				$localLanguage[$this->lang] = t3lib_div::array_merge_recursive_overrule($localLanguage[$this->lang], $tempLL[$language], FALSE, FALSE);
1961
			}
1962
		}
1963

  
1964
		return $localLanguage;
1965
	}
1966

  
1915 1967
	/*****************************************************/
1916 1968
	/*                                                   */
1917 1969
	/*  Tools                                            */
    (1-1/1)