Changeset 5167 for branches/gettext/include
- Timestamp:
- Mar 17, 2010, 8:46:45 PM (15 years ago)
- Location:
- branches/gettext/include
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gettext/include/common.inc.php
r5138 r5167 148 148 load_language('local.lang', '', array('no_fallback'=>true) ); 149 149 150 bind_pwg_textdomain(); 151 150 152 // only now we can set the localized username of the guest user (and not in 151 153 // include/user.inc.php) -
branches/gettext/include/constants.php
r5158 r5167 98 98 if (!defined('OLD_PERMALINKS_TABLE')) 99 99 define('OLD_PERMALINKS_TABLE', $prefixeTable.'old_permalinks'); 100 if (!defined('THEMES_TABLE')) 101 define('THEMES_TABLE', $prefixeTable.'themes'); 100 102 101 103 ?> -
branches/gettext/include/functions.inc.php
r5138 r5167 542 542 // we ask midday because Windows think it's prior to midnight with a 543 543 // zero and refuse to work 544 $formated_date.= $lang['day'][date('w', mktime(12,0,0,$ymdhms[1],$ymdhms[2],$ymdhms[0]))];544 $formated_date.= l10n(date('l', mktime(12,0,0,$ymdhms[1],$ymdhms[2],$ymdhms[0]))); 545 545 } 546 546 $formated_date.= ' '.$ymdhms[2]; 547 $formated_date.= ' '. $lang['month'][(int)$ymdhms[1]];547 $formated_date.= ' '.l10n(date('F', mktime(12,0,0,$ymdhms[1],$ymdhms[2],$ymdhms[0]))); 548 548 $formated_date.= ' '.$ymdhms[0]; 549 549 if ($show_time and count($ymdhms)>=5 ) … … 714 714 function get_pwg_themes() 715 715 { 716 global $conf;717 716 $themes = array(); 718 717 719 $template_dir = PHPWG_ROOT_PATH.'themes'; 720 721 foreach (get_dirs($template_dir) as $theme) 722 { 723 if ( $theme != 'default' ) 724 { 725 array_push($themes, $theme); 726 } 718 $query = ' 719 SELECT 720 id, 721 name 722 FROM '.THEMES_TABLE.' 723 ORDER BY name ASC 724 ;'; 725 $result = pwg_query($query); 726 while ($row = pwg_db_fetch_assoc($result)) 727 { 728 $themes[ $row['id'] ] = $row['name']; 727 729 } 728 730 729 731 // plugins want remove some themes based on user status maybe? 730 732 $themes = trigger_event('get_pwg_themes', $themes); 733 731 734 return $themes; 732 735 } … … 862 865 863 866 /** 867 * bind piwigo textdomain 868 */ 869 function bind_pwg_textdomain() 870 { 871 global $user; 872 873 if (empty($user['language'])) 874 { 875 $locale = $GLOBALS['language']; 876 } 877 else 878 { 879 $locale = $user['language']; 880 } 881 882 $locale .= '.UTF-8'; 883 putenv('LC_ALL='.$locale); 884 T_setlocale(LC_ALL, $locale); 885 886 T_bindtextdomain('piwigo', './language'); 887 } 888 889 /** 864 890 * returns the corresponding value from $lang if existing. Else, the key is 865 891 * returned 866 892 * 867 893 * @param string key 894 * @param string textdomain domain where to find keys 868 895 * @return string 869 896 */ 870 function l10n($key, $textdomain='messages') 871 { 872 global $user; 873 874 if (empty($user['language'])) 875 { 876 $locale = $GLOBALS['language']; 877 } 878 else 879 { 880 $locale = $user['language']; 881 } 882 883 T_setlocale(LC_ALL, $locale.'.UTF-8'); 884 885 // Specify location of translation tables 886 T_bindtextdomain($textdomain, "./language"); 887 888 // Choose domain 897 function l10n($key, $textdomain='piwigo') 898 { 899 T_bind_textdomain_codeset($textdomain, 'UTF-8'); 889 900 T_textdomain($textdomain); 890 901 891 902 return T_gettext($key); 892 903 } … … 899 910 * @param plural string key 900 911 * @param decimal value 912 * @param textdomain string value 901 913 * @return string 902 914 */ 903 915 function l10n_dec($singular_fmt_key, $plural_fmt_key, 904 $decimal, $textdomain='messages') 905 { 906 global $user; 907 908 if (empty($user['language'])) 909 { 910 $locale = $GLOBALS['language']; 911 } 912 else 913 { 914 $locale = $user['language']; 915 } 916 917 T_setlocale(LC_ALL, $locale.'.UTF-8'); 918 919 // Specify location of translation tables 920 T_bindtextdomain($textdomain, "./language"); 921 922 // Choose domain 916 $decimal, $textdomain='piwigo') 917 { 918 T_bind_textdomain_codeset($textdomain, 'UTF-8'); 923 919 T_textdomain($textdomain); 924 920 -
branches/gettext/include/template.class.php
r5126 r5167 67 67 68 68 $this->smarty->assign_by_ref( 'pwg', new PwgTemplateAdapter() ); 69 $this->smarty->register_modifier( 'translate', array( 'Template', 'mod_translate') );69 $this->smarty->register_modifier( 'translate', array(&$this, 'mod_translate') ); 70 70 $this->smarty->register_modifier( 'explode', array('Template', 'mod_explode') ); 71 71 $this->smarty->register_modifier( 'get_extent', array(&$this, 'get_extent') ); 72 72 $this->smarty->register_block('html_head', array(&$this, 'block_html_head') ); 73 $this->smarty->register_function( 'known_script', array(&$this, 'func_known_script') );73 $this->smarty->register_function( 'known_script', array(&$this, 'func_known_script') ); 74 74 $this->smarty->register_prefilter( array('Template', 'prefilter_white_space') ); 75 75 if ( $conf['compiled_template_cache_language'] ) … … 99 99 include($root.'/'.$theme.'/themeconf.inc.php'); 100 100 101 if (isset($themeconf['parent']) )101 if (isset($themeconf['parent']) and $themeconf['parent'] != $theme) 102 102 { 103 103 $this->set_theme($root, $themeconf['parent'], $path); … … 386 386 * language 387 387 */ 388 static function mod_translate($text)389 { 390 return l10n($text );388 public function mod_translate($text, $domain='piwigo') 389 { 390 return l10n($text, $domain); 391 391 } 392 392 … … 561 561 class PwgTemplateAdapter 562 562 { 563 function l10n($text )564 { 565 return l10n($text );566 } 567 568 function l10n_dec($s, $p, $v )569 { 570 return l10n_dec($s, $p, $v );563 function l10n($text, $domain='piwigo') 564 { 565 return l10n($text, $domain); 566 } 567 568 function l10n_dec($s, $p, $v, $domain='piwigo') 569 { 570 return l10n_dec($s, $p, $v, $domain); 571 571 } 572 572
Note: See TracChangeset
for help on using the changeset viewer.