[phpwebapp-commits] CVS: web_app/parser class.WebPage.php,1.15,1.16 class.WebClassTpl.php,1.11,1.12
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2005-06-21 08:39:59
|
Update of /cvsroot/phpwebapp/web_app/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22457/parser Modified Files: class.WebPage.php class.WebClassTpl.php Log Message: added translation (i18n/l10n) support for messages in the JS code Index: class.WebPage.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.WebPage.php,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** class.WebPage.php 11 Oct 2004 09:50:52 -0000 1.15 --- class.WebPage.php 21 Jun 2005 08:39:51 -0000 1.16 *************** *** 46,49 **** --- 46,55 ---- /** + * Keeps a list of translatable messages that are used + * in the JavaScript code. + */ + var $js_i18n_messages; + + /** * Keeps a list of messages that are displayed with alert() * to the user after the page is loaded. *************** *** 63,69 **** --- 69,77 ---- * Keeps a list of debug messages that are displayed * after the page is rendered. + * @see WebApp::debug_msg() */ var $dbg_messages; + /** used to measure the execution time of several parts of the application */ var $timer; *************** *** 76,81 **** $this->rs_collection = array(); $this->messages = array(); ! $this->popup_windows = array(); $this->dbg_messages = array(); --- 84,90 ---- $this->rs_collection = array(); + $this->js_i18n_messages = array(); $this->messages = array(); ! $this->popup_windows = array(); $this->dbg_messages = array(); Index: class.WebClassTpl.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/parser/class.WebClassTpl.php,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** class.WebClassTpl.php 22 Jul 2004 16:25:37 -0000 1.11 --- class.WebClassTpl.php 21 Jun 2005 08:39:51 -0000 1.12 *************** *** 122,128 **** --- 122,137 ---- { global $webPage; + + //include the JS file in the <head> of the page $fname = WebApp::to_url($fname); $include_js = " <script type=\"text/javascript\" language=\"javascript\" src=\"$fname\"></script>\n"; $webPage->append_to_head($include_js); + + //extract translatable messages in the JS code + $pattern = '#T_\("([^"]+)"\)#'; //match patterns like this: T_("....") + $js_code = file_get_contents($fname); + preg_match_all($pattern, $js_code, $matches); + $webPage->js_i18n_messages = + array_merge($webPage->js_i18n_messages, $matches[1]); } } |