phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] phpgwapi/inc class.translation_sql.inc.php


From: Sigurd Nes
Subject: [Phpgroupware-cvs] phpgwapi/inc class.translation_sql.inc.php
Date: Tue, 04 Jul 2006 13:06:37 +0000

CVSROOT:        /sources/phpgwapi
Module name:    phpgwapi
Changes by:     Sigurd Nes <sigurdne>   06/07/04 13:06:36

Modified files:
        inc            : class.translation_sql.inc.php 

Log message:
        Support for loading lang files into shared memory

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgwapi/inc/class.translation_sql.inc.php?cvsroot=phpgwapi&r1=1.20&r2=1.21

Patches:
Index: class.translation_sql.inc.php
===================================================================
RCS file: /sources/phpgwapi/phpgwapi/inc/class.translation_sql.inc.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- class.translation_sql.inc.php       26 Apr 2005 10:55:25 -0000      1.20
+++ class.translation_sql.inc.php       4 Jul 2006 13:06:36 -0000       1.21
@@ -7,7 +7,7 @@
        * @license http://www.fsf.org/licenses/lgpl.html GNU Lesser General 
Public License
        * @package phpgwapi
        * @subpackage application
-       * @version $Id: class.translation_sql.inc.php,v 1.20 2005/04/26 
10:55:25 powerstat Exp $
+       * @version $Id: class.translation_sql.inc.php,v 1.21 2006/07/04 
13:06:36 sigurdne Exp $
        */
 
        /**
@@ -25,25 +25,14 @@
        */
        class translation
        {
-               function translate($key, $vars=false ) 
-               {
-                       if (!$vars)
+               function translation()  
                        {
-                               $vars = array();
-                       }
-                       $ret = $key;
-                       // check also if $GLOBALS['lang'] is a array
-                       // php-nuke and postnuke are using $GLOBALS['lang'] too
-                       // as string
-                       // this makes many problems
-                       if ( !is_array($GLOBALS['lang']) ) //This should avoid 
problems for php-nuke & postnuke I guess (Caeies)
+
+                       if(!is_object($GLOBALS['phpgw']->shm))
                        {
-                               $GLOBALS['lang'] = array();
+                               $GLOBALS['phpgw']->shm = 
CreateObject('phpgwapi.shm');
                        }
-                       
if(!array_key_exists(strtolower(trim(substr($key,0,MAX_MESSAGE_ID_LENGTH))),$GLOBALS['lang']))
 //Using array_key_exists permits empty string ... Ugly but ... (Caeies)
-//                     if (!isset($GLOBALS['lang']) || !$GLOBALS['lang'] || 
!is_array($GLOBALS['lang']))
-                       {
-//                             $GLOBALS['lang'] =  array();
+                               
         if 
(isset($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']) &&
                                        
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'])
                                {
@@ -53,6 +42,58 @@
                                {
                                        $userlang = 'en';
                                }
+                       
+                       $this->userlang = $userlang;
+                       
+                       if ( !is_array($GLOBALS['lang']) ) //This should avoid 
problems for php-nuke & postnuke I guess (Caeies)
+                       {
+                               if($GLOBALS['lang'] = 
$GLOBALS['phpgw']->shm->get_value('lang_' . $userlang))
+                               {
+                                       $this->loade_from_shm = true;
+                               }
+                               else
+                               {
+                                       $GLOBALS['lang'] = array();
+                               }
+                       }
+               }
+               
+               function populate_shm()
+               {
+                       $sql = "SELECT * from phpgw_lang order by app_name 
desc";
+                       $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
+                       while ($GLOBALS['phpgw']->db->next_record())
+                       {
+                               
$lang_set[$GLOBALS['phpgw']->db->resultSet->fields('lang')][strtolower($GLOBALS['phpgw']->db->resultSet->fields('message_id'))]
 = $GLOBALS['phpgw']->db->resultSet->fields('content');
+                       }
+                       
+                       $language = array_keys($lang_set);
+                       if (isset($language) AND is_array($language))
+                       {
+                               foreach($language as $lang)
+                               {
+                                       
$GLOBALS['phpgw']->shm->store_value('lang_' . $lang,$lang_set[$lang]);
+                               }
+                       }
+               }
+               
+               function translate($key, $vars=false ) 
+               {
+                       if (!$vars)
+                       {
+                               $vars = array();
+                       }
+                       $ret = $key;
+                       // check also if $GLOBALS['lang'] is a array
+                       // php-nuke and postnuke are using $GLOBALS['lang'] too
+                       // as string
+                       // this makes many problems
+
+                               $userlang = $this->userlang;
+ 
+
+                       
if(!array_key_exists(strtolower(trim(substr($key,0,MAX_MESSAGE_ID_LENGTH))),$GLOBALS['lang'])
 && !$this->loade_from_shm) //Using array_key_exists permits empty string ... 
Ugly but ... (Caeies)
+                       {
                                $sql = "select message_id,content from 
phpgw_lang where lang = '".$userlang."' ".
                                        "and message_id = 
'".$GLOBALS['phpgw']->db->db_addslashes($key)."' or message_id = 'charset' and 
(app_name = '".$GLOBALS['phpgw_info']['flags']['currentapp']."' or app_name = 
'common' or app_name = 'all')";
                        //              "and (app_name = 
'".$GLOBALS['phpgw_info']['flags']['currentapp']."' or app_name = 'common' or 
app_name = 'all')";




reply via email to

[Prev in Thread] Current Thread [Next in Thread]