Changeset 24917
- Timestamp:
- 11/29/08 10:59:35 (6 weeks ago)
- Location:
- development/main
- Files:
-
- 1 added
- 1 removed
- 11 modified
-
config/config.php (modified) (1 diff)
-
includes/BlockUtil.class.php (modified) (1 diff)
-
includes/DBConnectionStack.class.php (modified) (1 diff)
-
includes/Theme.class.php (modified) (7 diffs)
-
locale/gettext_notes.txt (modified) (2 diffs)
-
locale/gettext-structure.txt (added)
-
locale/pn-gettext-structure.txt (deleted)
-
system/pnRender/plugins/function.dcgt.php (modified) (4 diffs)
-
system/pnRender/plugins/function.dcngt.php (modified) (3 diffs)
-
system/pnRender/plugins/function.dgt.php (modified) (4 diffs)
-
system/pnRender/plugins/function.dngt.php (modified) (4 diffs)
-
system/pnRender/plugins/function.gt.php (modified) (4 diffs)
-
system/pnRender/plugins/function.ngt.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
development/main/config/config.php
r24881 r24917 41 41 $PNConfig['System']['development'] = 1; // should be set to 0/false when cutting a release for production use 42 42 $PNConfig['System']['default_timezone'] = 'GMT'; // TZ timezone 43 $PNConfig['System']['dom'] = 'zikula'; // gettext system domain 43 44 44 45 // ---------------------------------------------------------------------- -
development/main/includes/BlockUtil.class.php
r24916 r24917 74 74 $blockinfo = self::getInfo($blockplacement['bid']); 75 75 // block filtering 76 //bp 2008-02-12 - if session variable 'area' is set retrieve it77 $area = SessionUtil::getVar('area',null);78 76 79 77 if (!empty($blockinfo['filter']['modules']) || -
development/main/includes/DBConnectionStack.class.php
r24916 r24917 123 123 // bplagge - 2008/11/18 124 124 if (!defined('_PNINSTALLVER') && ($dbdriver == 'mysql' || $dbdriver == 'mysqli')) { 125 if (isset($dbcharset)) { 126 $cs = str_replace('-','', strtolower($dbcharset)); 127 $conn->Execute("set names $cs"); 125 if (isset($dbcharset)) { 126 $dbcharset = str_replace('-','', strtolower($dbcharset)); 127 $res = $conn->Execute("SHOW VARIABLES LIKE 'character_set_database'"); 128 $curdbcharset = $res->fields[1]; 129 if ($dbcharset != $curdbcharset) { 130 return pn_exit("Inconsistent DB character set in config ($dbcharset) and in current DB ($curdbcharset)"); 131 } else { 132 // ensure that the server charset is also set! (see Mysql manual for details) 133 $conn->Execute("set names $dbcharset"); 134 } 135 } 128 136 } 129 }130 137 131 138 $GLOBALS['PNRuntime']['DB'][$count] = $GLOBALS['PNConfig']['DBInfo'][$name]; -
development/main/includes/Theme.class.php
r24916 r24917 59 59 protected $isloggedin; 60 60 61 //bp 2008-02-1162 // area, logical subset of the website (similar to category63 protected $area;64 65 61 /** 66 62 * Initialize our class … … 149 145 //bp 2008-11-17 - bindtextdomain 150 146 //the name of the theme's textdomain must correspond to the name defined in pnversion.php! 151 //e.g. $themeversion['name'] = sql_ledger;147 //e.g. $themeversion['name'] = theme99; 152 148 $syscharset = Zikula::getConfigVar('syscharset'); 153 149 … … 167 163 echo "syscharset: $syscharset, locale: $loc, themelocpath: $themelocpath, themedom: $this->name<br/> 168 164 bindtextdomain: $rt, bind_textdomain_codeset: $rc<br/>"; 169 echo dgettext($this->name, 'Home');165 echo dgettext($this->name, 'Home'); 170 166 171 echo "<br/>set textdomain<br/>";172 $rd=textdomain($this->name);173 echo _('Home');167 echo "<br/>set textdomain<br/>"; 168 $rd=textdomain($this->name); 169 echo _('Home'); 174 170 */ 175 171 //end bp … … 310 306 $masterpath = "themes/$os_theme/templates"; 311 307 312 //bp 2008-02-11 area template path -> so we can specify area-specific templates313 $areapath = "themes/$os_theme/templates/category";314 //bp end315 316 308 // 2. The module template path 317 309 $modulepath = "themes/$os_theme/templates/modules"; … … 321 313 $ostemplate = DataUtil::formatForOS($template); 322 314 323 //bp 2008-02-11 - add $areapath and subdir for module to the search path324 315 $search_path = array($masterpath, 325 $areapath,326 $areapath.'/'.$modulepath,327 316 $modulepath, 328 317 $blockpath); … … 474 463 } 475 464 476 //bp 2008-02-11 - extract and save area id477 foreach ($queryparts as $querypart) {478 if (stristr($querypart, 'area=')) {479 $n = strpos($querypart, '=');480 $this->area = substr($querypart, $n+1);481 $this->assign('area', $this->area);482 SessionUtil::setVar('area', $this->area);483 }484 }485 $this->area = SessionUtil::getVar('area',null);486 //bp487 488 465 489 466 // identify and load the correct module configuration … … 496 473 $this->cachepage = false; 497 474 $file = $pageconfigurations['*admin']['file']; 498 //bp 2008-02-11499 } else if (isset($this->area) && isset($pageconfigurations[$this->area])) {500 $file = $pageconfigurations[$this->area]['file'];501 //bp502 475 } else { 503 476 $customargs = $this->module.'/'.$this->type.'/'.$this->func.$customargs; -
development/main/locale/gettext_notes.txt
r24779 r24917 1 1 B.Plagge, First Choice Internet, Tokyo 2 2 bplagge@choicenet.ne.jp 3 2007-12-31, 2008-02-29 4 Version: 0. 23 2007-12-31, 2008-02-29, 2008-11-29 4 Version: 0.3 5 5 6 6 This are a few notes how to use gettext functions in PostNuke programs. … … 74 74 <!--[gt text="Edit %s" tag="Theme" html="1"]--> 75 75 or 76 <!--[gt text="User %s has email address %s" tag= array($user,$email)html="1"]-->76 <!--[gt text="User %s has email address %s" tag="$user|True,$email" html="1"]--> 77 77 78 78 The 'tag' and 'html' parameters are optional. 79 79 80 The 'tag' parameter has the following format: 81 * Format of the 'tag' parameter: 82 * value string separated by commas; will converted to array('a','b', 'c') 83 * if a value itself has the form 'a|True' it will be converted to array('a', 'True') 80 84 81 What else?82 83 PHP also supports the dgettext, dngettext, dcgettext, dcngettext functions which are only relevant if the domain is being84 changed. I put corresponding plugin functions into the pnRender/plugin directory.85 This may be useful if we want to provide theme-based domain override. However, afaik there is no 'fallback domain' in case the selected domain86 (e.g. = theme) does not provide a translation.87 85 88 86 89 87 Conversion 90 ---------- 91 To build one common language constants file I used the pnlwb (PN language workbench). The resulting file you find 'allcore.txt' 92 in directory locale/eng. 93 Note: I had to replace single quotes with dobule quotes to inclose the strings because some text strings contained '%s' and that 94 would cause syntax errors. 88 ------------ 89 Please use the pnlwb (PN language workbench) to build a suitable file contain all text defines and specify it in 90 the program gettexttizer.php. 91 92 Previously the main gettext Smarty plugin was name 'pngt'; now it is called 'gt'. So, if you find pngt Smarty 93 calls in any template please replace them! 95 94 96 95 I used our gettexttizer.php program to replace constant strings with gettext clear text messages. This program also replaces pnml strings 97 in templates with pngt string. The program worked fine but in some cases it failed to correctly replace message strings. These were:96 in templates with gt string. The program worked fine but in some cases it failed to correctly replace message strings. These were: 98 97 1) we really MEAN a constant e.g. _PNINSTALLER 99 98 2) pnML function in programs (function seems to be quite new, program needs to be enhanced) -
development/main/system/pnRender/plugins/function.dcgt.php
r24783 r24917 5 5 * @copyright (c) 2004, Zikula Development Team 6 6 * @link http://www.zikula.org 7 * @version $Id: $7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 8 8 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 9 * @author Bernd Plagge 9 10 * @package Zikula_Template_Plugins 10 11 * @subpackage Functions 11 12 */ 13 12 14 13 15 /** … … 17 19 * 18 20 * Available parameters: 19 * - domain:textdomain to be used20 * - text: string to translate21 * - cat: Locale category (e.g. '4' -> LC_MONETARY22 * - html: Treat the textas HTML21 * - domain: textdomain to be used 22 * - name: Name of the language constant to return 23 * - cat: Locale category (e.g. '4' -> LC_MONETARY 24 * - html: Treat the language define as HTML 23 25 * - assign: If set, the results are assigned to the corresponding variable instead of printed out 24 26 * 25 27 * Example 26 * <!--[dcgt domain="OtherModule" text="String" cat="4" html="1"]-->28 * <!--[dcgt domain="OtherModule" name="At the tone, the time will be 12:00pm" cat="2" html="0"]--> 27 29 * 28 30 * The normal textdomain and the now to be used textdomain must have been set beforehand! … … 35 37 * 36 38 * @author Bernd Plagge 37 * @author Frank Schummertz38 39 * @since 2007-04-20 39 40 * @param array $params All attributes passed to this function from the template … … 49 50 /* Gettext initialisation finished */ 50 51 51 if (!isset($params['domain'])) { 52 extract($params); 53 unset($params); 54 55 if (!isset($domain)) { 52 56 $smarty->trigger_error('dcgt: attribute domain required'); 53 57 return false; 54 58 } 55 if (!isset($ params['text'])) {56 $smarty->trigger_error('dcgt: attribute textrequired');59 if (!isset($name)) { 60 $smarty->trigger_error('dcgt: attribute name required'); 57 61 return false; 58 62 } 59 if (!isset($ params['cat'])) {63 if (!isset($name)) { 60 64 $smarty->trigger_error('dcgt: attribute cat required'); 61 65 return false; 62 66 } 63 67 64 if (isset($ params['html']) && ($params['html']> 0)) {65 $result = DataUtil::formatForDisplayHTML(d gettext($params['domain'], $params['text'], $params['cat']));68 if (isset($html) && ($html > 0)) { 69 $result = DataUtil::formatForDisplayHTML(dcgettext($domain, $name, $cat)); 66 70 } else { 67 $result = DataUtil::formatForDisplay(d gettext($params['domain'], $params['text'], $params['cat']));71 $result = DataUtil::formatForDisplay(dcgettext($domain, $name, $cat)); 68 72 } 69 73 70 if (isset($ params['assign'])) {71 $smarty->assign($ params['assign'], $result);74 if (isset($assign)) { 75 $smarty->assign($assign, $result); 72 76 } else { 73 77 return $result; 74 78 } 75 79 } 80 ?> -
development/main/system/pnRender/plugins/function.dcngt.php
r24783 r24917 5 5 * @copyright (c) 2004, Zikula Development Team 6 6 * @link http://www.zikula.org 7 * @version $Id: $7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 8 8 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 9 * @author Bernd Plagge 9 10 * @package Zikula_Template_Plugins 10 11 * @subpackage Functions 11 12 */ 13 12 14 13 15 /** 14 * Smarty function to use the PHP dcngettext() function 16 * Smarty function to use the PHP dcngettext() function 15 17 * 16 18 * This function takes a identifier and returns the corresponding language constant. 17 19 * 18 20 * Available parameters: 19 * - domain:textdomain to be used20 * - text: string to translate21 * - plural:Plural form22 * - count: The actual number (e.g. '5' apples -> count='5')23 * - cat: Locale category (e.g. '4' -> LC_MONETARY24 * - html: Treat the textas HTML25 * - assign: If set, the results are assigned to the corresponding variable instead of printed out21 * - domain: textdomain to be used 22 * - name: Name of the language constant to return 23 * - plural: Plural form 24 * - count: The actual number (e.g. '5' apples -> count='5') 25 * - cat: Locale category (e.g. '4' -> LC_MONETARY 26 * - html: Treat the language define as HTML 27 * - assign: If set, the results are assigned to the corresponding variable instead of printed out 26 28 * 27 29 * Example 28 * <!--[dcngt domain="OtherModule" name=" String" cat="4" html="1"]-->30 * <!--[dcngt domain="OtherModule" name="%d person attended" plural="%d people attended" cat="0" html="0"]--> 29 31 * 30 32 * The normal textdomain and the now to be used textdomain must have been set beforehand! … … 37 39 * 38 40 * @author Bernd Plagge 39 * @author Frank Schummertz40 41 * @since 2007-04-20 41 42 * @param array $params All attributes passed to this function from the template … … 51 52 /* Gettext initialisation finished */ 52 53 53 if (!isset($params['domain'])) { 54 extract($params); 55 unset($params); 56 57 if (!isset($domain)) { 54 58 $smarty->trigger_error('dcngt: attribute domain required'); 55 59 return false; 56 60 } 57 if (!isset($ params['text'])) {58 $smarty->trigger_error('dcngt: attribute textrequired');61 if (!isset($name)) { 62 $smarty->trigger_error('dcngt: attribute name required'); 59 63 return false; 60 } 61 if (!isset($params['cat'])) { 64 } 65 if (!isset($plural)) { 66 $smarty->trigger_error('dcngt: attribute plural required'); 67 return false; 68 } 69 if (!isset($count)) { 70 $smarty->trigger_error('dcngt: attribute count required'); 71 return false; 72 } 73 if (!isset($cat)) { 62 74 $smarty->trigger_error('dcngt: attribute cat required'); 63 75 return false; 64 76 } 65 if (!isset($params['plural'])) { 66 $smarty->trigger_error('dcngt: attribute plural required'); 67 return false; 68 } 69 if (!isset($params['count'])) { 70 $smarty->trigger_error('dcngt: attribute count required'); 71 return false; 72 } 73 74 if (isset($params['html']) && ($params['html'] > 0)) { 75 $result = DataUtil::formatForDisplayHTML(dgettext($params['domain'], $params['text'], $params['plural'], $params['count'], $params['cat'])); 77 78 79 if (isset($html) && ($html > 0)) { 80 $result = DataUtil::formatForDisplayHTML(dcngettext($domain, $name, $plural, $count, $cat)); 76 81 } else { 77 $result = DataUtil::formatForDisplay(d gettext($params['domain'], $params['text'], $params['plural'], $params['count'], $params['cat']));78 } 82 $result = DataUtil::formatForDisplay(dcngettext($domain, $name, $plural, $count, $cat)); 83 } 79 84 80 if (isset($ params['assign'])) {81 $smarty->assign($ params['assign'], $result);85 if (isset($assign)) { 86 $smarty->assign($assign, $result); 82 87 } else { 83 88 return $result; 84 89 } 85 90 } 91 ?> -
development/main/system/pnRender/plugins/function.dgt.php
r24783 r24917 5 5 * @copyright (c) 2004, Zikula Development Team 6 6 * @link http://www.zikula.org 7 * @version $Id: $7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 8 8 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 9 9 * @package Zikula_Template_Plugins 10 * @subpackage Functions 10 * @author Bernd Plagge 11 * @package Zikula_Template_Plugins 12 * @subpackage Functions 11 13 */ 12 14 13 15 /** 14 16 * Smarty function to use the PHP dgettext() function … … 17 19 * 18 20 * Available parameters: 19 * - domain:textdomain to be used20 * - text: string to translate21 * - html: Treat the textas HTML21 * - domain: textdomain to be used 22 * - name: Name of the language constant to return 23 * - html: Treat the language define as HTML 22 24 * - assign: If set, the results are assigned to the corresponding variable instead of printed out 23 25 * 24 26 * Example 25 * <!--[dgt domain="OtherModule" name=" String" html="1"]-->27 * <!--[dgt domain="OtherModule" name="Example Text" html="1"]--> 26 28 * 27 29 * The normal textdomain and the now to be used textdomain must have been set beforehand! … … 30 32 * 31 33 * @author Bernd Plagge 32 * @author Frank Schummertz33 34 * @since 2007-04-20 34 35 * @param array $params All attributes passed to this function from the template … … 44 45 /* Gettext initialisation finished */ 45 46 46 if (!isset($params['domain'])) { 47 extract($params); 48 unset($params); 49 50 if (!isset($domain)) { 47 51 $smarty->trigger_error('dgt: attribute domain required'); 48 52 return false; 49 53 } 50 if (!isset($ params['text'])) {51 $smarty->trigger_error('dgt: attribute textrequired');54 if (!isset($name)) { 55 $smarty->trigger_error('dgt: attribute name required'); 52 56 return false; 53 57 } 54 58 55 59 if (isset($html) && ($html > 0)) { 56 $result = DataUtil::formatForDisplayHTML(dgettext($ params['domain'], $params['text']));60 $result = DataUtil::formatForDisplayHTML(dgettext($domain, $name)); 57 61 } else { 58 $result = DataUtil::formatForDisplay(dgettext($ params['domain'], $params['text']));62 $result = DataUtil::formatForDisplay(dgettext($domain, $name)); 59 63 } 60 64 61 if (isset($ params['assign'])) {62 $smarty->assign($ params['assign'], $result);65 if (isset($assign)) { 66 $smarty->assign($assign, $result); 63 67 } else { 64 68 return $result; 65 69 } 66 70 } 71 ?> -
development/main/system/pnRender/plugins/function.dngt.php
r24783 r24917 5 5 * @copyright (c) 2004, Zikula Development Team 6 6 * @link http://www.zikula.org 7 * @version $Id: $7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 8 8 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 9 * @author Bernd Plagge 9 10 * @package Zikula_Template_Plugins 10 11 * @subpackage Functions 11 12 */ 12 13 14 13 15 /** 14 16 * Smarty function to use the PHP dngettext() function … … 17 19 * 18 20 * Available parameters: 19 * - domain: textdomain to be used 20 * - text: string to translate 21 * - plural: Plural form 22 * - count: The actual number (e.g. '5' apples -> count='5') 23 * - html: Treat the text as HTML 24 * - assign: If set, the results are assigned to the corresponding variable instead of printed out 21 * - domain: textdomain to be used 22 * - name: Name of the language constant to return 23 * - plural: Plural form 24 * - count: The actual number (e.g. '5' apples -> count='5') 25 26 * - html: Treat the language define as HTML 27 * - assign: If set, the results are assigned to the corresponding variable instead of printed out 25 28 * 26 29 * Example … … 32 35 * 33 36 * @author Bernd Plagge 34 * @author Frank Schummertz35 37 * @since 2007-04-20 36 38 * @param array $params All attributes passed to this function from the template … … 46 48 /* Gettext initialisation finished */ 47 49 48 if (!isset($params['domain'])) { 50 extract($params); 51 unset($params); 52 53 if (!isset($domain)) { 49 54 $smarty->trigger_error('dngt: attribute domain required'); 50 55 return false; 51 56 } 52 if (!isset($ params['text'])) {53 $smarty->trigger_error('dngt: attribute textrequired');57 if (!isset($name)) { 58 $smarty->trigger_error('dngt: attribute name required'); 54 59 return false; 55 60 } 56 if (!isset($p arams['plural'])) {61 if (!isset($plural)) { 57 62 $smarty->trigger_error('dngt: attribute plural required'); 58 63 return false; 59 64 } 60 if (!isset($ params['count'])) {65 if (!isset($count)) { 61 66 $smarty->trigger_error('dngt: attribute count required'); 62 67 return false; 63 } 68 } 69 64 70 65 if (isset($ params['html']) && ($params['html']> 0)) {66 $result = DataUtil::formatForDisplayHTML(dngettext($ params['domain'], $params['text'], $params['plural'], $params['count']));71 if (isset($html) && ($html > 0)) { 72 $result = DataUtil::formatForDisplayHTML(dngettext($domain, $name, $plural, $count)); 67 73 } else { 68 $result = DataUtil::formatForDisplay(dngettext($ params['domain'], $params['text'], $params['plural'], $params['count']));74 $result = DataUtil::formatForDisplay(dngettext($domain, $name, $plural, $count)); 69 75 } 70 76 71 if (isset($ params['assign'])) {72 $smarty->assign($ params['assign'], $result);77 if (isset($assign)) { 78 $smarty->assign($assign, $result); 73 79 } else { 74 80 return $result; 75 81 } 76 82 } 83 ?> -
development/main/system/pnRender/plugins/function.gt.php
r24779 r24917 5 5 * @copyright (c) 2004, Zikula Development Team 6 6 * @link http://www.zikula.org 7 * @version $Id: $7 * @version $Id: block.pnsecauthaction_block.php 24342 2008-06-06 12:03:14Z markwest $ 8 8 * @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html 9 * @author Bernd Plagge 9 10 * @package Zikula_Template_Plugins 10 11 * @subpackage Functions 11 12 */
