- Timestamp:
- Jul 7, 2012, 7:45:22 PM (11 years ago)
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/messages.php
r273 r276 17 17 /// when instanciated, stores the language to lookup for _() 18 18 public $lang; 19 19 20 20 /// The order of array elements in $msg. This array maps 21 21 /// $lang shortstring to array index position. … … 30 30 * There's actually no long method name version :D 31 31 * @param str_id Some key from the $msg array 32 * @param lang The wanted target language (string like 'de' or 'en'). Leave empty for object default lang ($this->lang) 32 33 * @returns Found string in current locale ($lang) 33 34 **/ 34 function _($str_id) { 35 function _($str_id, $lang=null) { 36 $lang = ($lang && isset(self::$order[$lang])) ? $lang : $this->lang; 35 37 if(!isset(self::$msg[$str_id])) { 36 38 return "<$str_id>"; // error; mediawiki style 37 39 } else { 38 40 if(is_array(self::$msg[$str_id])) { 39 return self::$msg[$str_id][ self::$order[$ this->lang] ];41 return self::$msg[$str_id][ self::$order[$lang] ]; 40 42 } else 41 43 return self::$msg[$str_id]; … … 53 55 function get_shorthand_printer() { 54 56 $t = $this; 55 return function($str )use($t) { print $t->_($str); };57 return function($str,$lang=null)use($t) { print $t->_($str,$lang); }; 56 58 } 57 59 … … 59 61 function get_shorthand_returner() { 60 62 $t = $this; 61 return function($str )use($t) { return $t->_($str); };63 return function($str,$lang=null)use($t) { return $t->_($str,$lang); }; 62 64 } 63 65 … … 94 96 'sidebar-h2-lang' => array('Sprachauswahl', 'Language'), 95 97 96 'topnav-interlang-title' => array('Read this page (%s) in English', 'Diese Seite (%s) auf Deutsch lesen'), 98 'topnav-interlang-title' => array('Die Seite "%s" auf Deutsch lesen', 'Read the page "%s" in English'), 99 'topnav-interlang-active' => array('Sie betrachten gerade die Seite "%s" auf Deutsch', 'You currently read the page "%s" in English'), 100 'topnav-interlang-nonexistent' => array('Diese Seite steht auf Deutsch nicht zur Verfügung', 'This page is not available in English'), 97 101 'topnav-search-label' => array('Suchen', 'Search'), 98 102 'topnav-search-page' => array('/suche.php', '/search.php'), … … 115 119 'head-rel-prev' => array('Zur vorherigen Seite (%s)', 'Previous Page (%s)'), 116 120 'head-rel-next' => array('Zur folgenden Seite (%s)', 'Next Page (%s)'), 117 'head-rel-interlang' => array(' Englische Version dieser Seite (%s)', 'Deutsche Version dieser Seite (%s)'),121 'head-rel-interlang' => array('Deutsche Version dieser Seite (%s)', 'English Version of this page (%s)'), 118 122 119 123 // used in /shared/js/modules/heading_links.js -
lib/template.php
r275 r276 121 121 // print interlanguage links for all languages except the active one 122 122 foreach($this->interlang_links as $lang => $a) { 123 if($lang != $this->conf['lang'] ) {123 if($lang != $this->conf['lang'] && !is_null($a)) { 124 124 printf('<link rel="alternate" href="%s" hreflang="%s" title="%s">', 125 $a['href'], $lang, sprintf($_('head-rel-interlang' ), $a)125 $a['href'], $lang, sprintf($_('head-rel-interlang', $lang), $a) 126 126 ); 127 127 } … … 192 192 <?php 193 193 foreach($this->interlang_links as $lang => $a) { 194 $is_current_lang = $lang == $this->conf['lang']; 195 if(is_null($a)) { 196 // when interlanguage link not present (null) = no translation exists 197 $a = t29Menu::dom_new_link('#', 'not present'); 198 $title = sprintf($_('topnav-interlang-nonexistent', $lang)); 199 $class = 'nonexistent'; 200 } elseif($is_current_lang) { 201 $title = sprintf($_('topnav-interlang-active'), $a); 202 $class = 'active'; 203 } else { 204 // ordinary interlang link 205 $title = sprintf($_('topnav-interlang-title', $lang), $a); 206 $class = ''; 207 } 194 208 printf("\t\t\t\t<li%s><a href='%s' title='%s'>%s</a></li>\n", 195 ( $lang == $this->conf['lang'] ? ' class="active"' : ''),196 $a['href'], sprintf($_('topnav-interlang-title'), $a),209 (empty($class) ? '' : " class='$class'"), 210 $a['href'], htmlspecialchars($title), 197 211 $this->conf['languages'][$lang][0] // verbose language name 198 212 );
Note: See TracChangeset
for help on using the changeset viewer.