Fix language if it is not found in the i18n. Reported by le_
This commit is contained in:
		
							parent
							
								
									4aa3529131
								
							
						
					
					
						commit
						c84cec9516
					
				
					 3 changed files with 15 additions and 4 deletions
				
			
		
							
								
								
									
										5
									
								
								base.php
									
										
									
									
									
								
							
							
						
						
									
										5
									
								
								base.php
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -169,7 +169,10 @@ function localize($phrase, $count=-1) {
 | 
			
		|||
            $translations = array_merge ($translations_en, $translations);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return $translations[$phrase];
 | 
			
		||||
    if (array_key_exists ($phrase, $translations)) {
 | 
			
		||||
        return $translations[$phrase];
 | 
			
		||||
    }
 | 
			
		||||
    return $phrase;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function addURLParameter($urlParams, $paramName, $paramValue) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								book.php
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								book.php
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -227,7 +227,7 @@ class Book extends Base {
 | 
			
		|||
        $result->execute (array ($this->id));
 | 
			
		||||
        while ($post = $result->fetchObject ())
 | 
			
		||||
        {
 | 
			
		||||
            array_push ($lang, localize("languages.".$post->lang_code));
 | 
			
		||||
            array_push ($lang, Language::getLanguageString($post->lang_code));
 | 
			
		||||
        }
 | 
			
		||||
        return implode (", ", $lang);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										12
									
								
								language.php
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								language.php
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -26,6 +26,14 @@ class language extends Base {
 | 
			
		|||
    public function getEntryId () {
 | 
			
		||||
        return self::ALL_LANGUAGES_ID.":".$this->id;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static function getLanguageString ($code) {
 | 
			
		||||
        $string = localize("languages.".$code);
 | 
			
		||||
        if (preg_match ("/^languages/", $string)) {
 | 
			
		||||
            return $code;
 | 
			
		||||
        }
 | 
			
		||||
        return $string;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function getCount() {
 | 
			
		||||
        $nLanguages = parent::getDb ()->query('select count(*) from languages')->fetchColumn();
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +48,7 @@ class language extends Base {
 | 
			
		|||
        $result = parent::getDb ()->prepare('select id, lang_code  from languages where id = ?');
 | 
			
		||||
        $result->execute (array ($languageId));
 | 
			
		||||
        if ($post = $result->fetchObject ()) {
 | 
			
		||||
            return new Language ($post->id, localize("languages.".$post->lang_code));
 | 
			
		||||
            return new Language ($post->id, Language::getLanguageString ($post->lang_code));
 | 
			
		||||
        }
 | 
			
		||||
        return NULL;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -57,7 +65,7 @@ order by languages.lang_code');
 | 
			
		|||
        while ($post = $result->fetchObject ())
 | 
			
		||||
        {
 | 
			
		||||
            $language = new Language ($post->id, $post->lang_code);
 | 
			
		||||
            array_push ($entryArray, new Entry (localize("languages.".$language->lang_code), $language->getEntryId (), 
 | 
			
		||||
            array_push ($entryArray, new Entry (Language::getLanguageString ($language->lang_code), $language->getEntryId (), 
 | 
			
		||||
                str_format (localize("bookword", $post->count), $post->count), "text non", 
 | 
			
		||||
                array ( new LinkNavigation ($language->getUri ()))));
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue