Changeset 522 for trunk/WordPress/plugin/transposh/transposh.php
- Timestamp:
- 08/27/2010 02:26:28 PM (21 months ago)
- File:
-
- 1 edited
-
trunk/WordPress/plugin/transposh/transposh.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/transposh.php
r500 r522 60 60 /** @var transposh_3rdparty Happens after editing */ 61 61 private $third_party; 62 63 62 // list of properties 64 63 /** @var string The site url */ … … 72 71 /** @var boolean Enable rewriting of URLs */ 73 72 public $enable_permalinks_rewrite; 74 /** @var string The language to translate the page to */73 /** @var string The language to translate the page to, from params */ 75 74 public $target_language; 75 /** @var string The language extracted from the url */ 76 public $tgl; 76 77 /** @var boolean Are we currently editing the page? */ 77 78 public $edit_mode; … … 139 140 // add_action('admin_menu', array(&$this, 'transposh_post_language')); 140 141 // add_action('save_post', array(&$this, 'transposh_save_post_language')); 141 142 142 //TODO add_action('manage_comments_nav', array(&$this,'manage_comments_nav')); 143 143 //TODO comment_row_actions (filter) 144 // toying around the mo/po stuff 145 add_filter('gettext', array(&$this, 'transposh_gettext_filter'), 10, 3); 144 // Intergrating with the gettext interface 145 add_filter('gettext', array(&$this, 'transposh_gettext_filter'), 10, 2); 146 add_filter('gettext_with_context', array(&$this, 'transposh_gettext_filter'), 10, 2); 147 add_filter('ngettext', array(&$this, 'transposh_ngettext_filter'), 10, 3); 148 add_filter('ngettext_with_context', array(&$this, 'transposh_ngettext_filter'), 10, 3); 146 149 add_filter('locale', array(&$this, 'transposh_locale_filter')); 147 150 151 //CHECK TODO!!!!!!!!!!!! 152 $this->tgl = transposh_utils::get_language_from_url($_SERVER['REQUEST_URI'], $this->home_url); 148 153 149 154 register_activation_hook(__FILE__, array(&$this, 'plugin_activate')); … … 244 249 */ 245 250 function on_shutdown() { 246 ob_flush();251 //TODO !!!!!!!!!!!! ob_flush(); 247 252 } 248 253 … … 321 326 322 327 // first we get the target language 323 $this->target_language = $wp->query_vars[LANG_PARAM]; 324 if (!$this->target_language) 325 $this->target_language = $this->options->get_default_language(); 328 /* $this->target_language = (isset($wp->query_vars[LANG_PARAM])) ? $wp->query_vars[LANG_PARAM] : ''; 329 if (!$this->target_language) 330 $this->target_language = $this->options->get_default_language(); 331 logger("requested language: {$this->target_language}"); */ 332 // TODO TOCHECK!!!!!!!!!!!!!!!!!!!!!!!!!!1 333 $this->target_language = $this->tgl; 326 334 logger("requested language: {$this->target_language}"); 335 327 336 328 337 // make themes that support rtl - go rtl http://wordpress.tv/2010/05/01/yoav-farhi-right-to-left-themes-sf10 … … 676 685 $n = !empty($q['exact']) ? '' : '%'; 677 686 $searchand = ''; 687 $search = ''; 678 688 foreach ((array) $q['search_terms'] as $term) { 679 689 // now we'll get possible translations for this term … … 820 830 } 821 831 822 function transposh_gettext_filter($a, $orig, $domain) { 823 //logger("$a $orig $domain"); 824 return $a; 832 /** 833 * This function adds our markings around gettext results 834 * @param string $translation 835 * @param string $orig 836 * @return string 837 */ 838 function transposh_gettext_filter($translation, $orig) { 839 if ($this->is_special_page($_SERVER['REQUEST_URI']) || ($this->options->is_default_language($this->tgl) && !$this->options->get_enable_default_translate())) { 840 logger($translation); 841 return $translation; 842 } 843 if ($translation != $orig) { 844 $translation = TP_GTXT_BRK . $translation . TP_GTXT_BRK_CLOSER; 845 } 846 $translation = str_replace(array('%s', '%1$s', '%2$s', '%3$s', '%4$s', '%5$s'), array(TP_GTXT_IBRK . '%s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%1$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%2$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%3$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%4$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%5$s' . TP_GTXT_IBRK_CLOSER), $translation); 847 return $translation; 848 } 849 850 /** 851 * This function adds our markings around ngettext results 852 * @param string $translation 853 * @param string $single 854 * @param string $plural 855 * @return string 856 */ 857 function transposh_ngettext_filter($translation, $single, $plural) { 858 if ($this->is_special_page($_SERVER['REQUEST_URI']) || ($this->options->is_default_language($this->tgl) && !$this->options->get_enable_default_translate())) 859 return $translation; 860 if ($translation != $single && $translation != $plural) { 861 $translation = TP_GTXT_BRK . $translation . TP_GTXT_BRK_CLOSER; 862 } 863 $translation = str_replace(array('%s', '%1$s', '%2$s', '%3$s', '%4$s', '%5$s'), array(TP_GTXT_IBRK . '%s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%1$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%2$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%3$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%4$s' . TP_GTXT_IBRK_CLOSER, TP_GTXT_IBRK . '%5$s' . TP_GTXT_IBRK_CLOSER), $translation); 864 return $translation; 825 865 } 826 866 827 867 function transposh_locale_filter($locale) { 828 //logger($locale); 868 $lang = transposh_utils::get_language_from_url($_SERVER['REQUEST_URI'], $this->home_url); 869 if (!$lang) return $locale; 870 list ($l, $n, $f, $locale) = explode(',', transposh_consts::$languages[$lang]); 871 if ($locale) { 872 return $locale; 873 } else { 874 return $lang; 875 } 829 876 return $locale; 830 877 }
Note: See TracChangeset
for help on using the changeset viewer.
