Project

General

Profile

« Previous | Next » 

Revision 1926

Added by darkviper about 11 years ago

TranslateAdaptorWbOldStyle now also accepts modified admin directory names

View differences:

TranslateAdaptorWbOldStyle.php
45 45
	{
46 46
		$this->sAddon = $sAddon;
47 47
		$this->sFilePath = str_replace('\\', '/', dirname(dirname(__FILE__)).'/'.$sAddon);
48
		$this->sFilePath = rtrim($this->sFilePath, '/').'/languages/';
49 48
	}
50 49
/**
51 50
 * Load languagefile
......
54 53
 */
55 54
	public function loadLanguage($sLangCode)
56 55
	{
56
		$this->_getAddonPath();
57 57
		$aTranslations = array();
58 58
		$sLangFile = strtolower($sLangCode.'.php');
59 59
		if( ($aDirContent = scandir($this->sFilePath)) !== false) {
......
76 76
 */
77 77
	public function findFirstLanguage()
78 78
	{
79
		$this->_getAddonPath();
79 80
	// search for first available and readable language file
80 81
		$sRetval = '';
81 82
		if(is_readable($this->sFilePath)) {
......
92 93
		return $sRetval;
93 94
	}
94 95
/**
96
 * set path to translation files
97
 * @throws TranslationException
98
 */
99
	private function _getAddonPath()
100
	{
101
		$sAddon   = str_replace('\\', '/', $this->sAddon);
102
		$sDirname = str_replace('\\', '/', dirname(dirname(__FILE__))).'/';
103
		$this->sFilePath = $sDirname.$sAddon.'/languages/';
104
		if(!is_readable($this->sFilePath) && (strpos('admin', $this->sAddon) === 0)) {
105
		// correct modified admin directory
106
			$sTmp = trim(WbAdaptor::getInstance()->AcpDir);
107
			$this->sFilePath = $sDirname.preg_replace('/^admin/', $sTmp, $sAddon).'/languages/';
108
			if(!is_readable($this->sFilePath)) {
109
				throw new TranslationException('missing language definitions in: '.$sAddon.'/languages');
110
			}
111
		}
112
	}
113
/**
95 114
 * Import language definitions into array
96 115
 * @param string load language from filename
97 116
 * @return array contains all found translations

Also available in: Unified diff