Fixed multilanguage tests.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 25 Jul 2010 12:24:06 +0000 (12:24 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 25 Jul 2010 12:24:06 +0000 (12:24 +0000)
admin/system_diagnostics.php
includes/lang/gettext.php

index 060a2ec8c2537179051dba736cb3d8adf523292d..665b6f02c701c5694bb90743bb7e44768da77a18 100644 (file)
@@ -227,29 +227,41 @@ function tst_langs()
        $test['result'] = true;
        $test['comments'] = array();
 
-       $old = setlocale(LC_MESSAGES, '0');
+       $fname =  $path_to_root.'/lang';
+       $test['test'][] = $fname;
+       if (!(is_dir($fname) && is_writable($fname))) {
+               $test['result'] = false;
+               $test['comments'][] = _("Languages folder should be writeable.");
+       }
        
+       $fname =  $path_to_root.'/lang/installed_languages.inc';
+       $test['test'][] = $fname;
+       if (!(is_file($fname) && is_writable($fname))) {
+               $test['result'] = false;
+               $test['comments'][] = _("Languages configuration file should be writeable.");
+       }
+
        $langs = array();
        
        foreach ($installed_languages as $lang) {
                $langs[] = $lang['code'];
                if ($lang['code'] == 'en_GB') continue; // native FA language
-               
+       
                $file = $path_to_root.'/lang/'.$lang['code'].'/LC_MESSAGES/'.$lang['code'];
-        $file .= function_exists('gettext') ? '.mo' : '.po';
+               if (@$lang['version'])
+                       $file .= '-'.$lang['version'];
+               $file .= function_exists('gettext') ? '.mo' : '.po';
 
                if (!is_file($file)) {
                        $test['result'] = false;
                        $test['comments'][] = sprintf( _('Missing %s translation file.'), $file);
                }
                if (!$_SESSION['get_text']->check_support($lang['code'], $lang['encoding']))
-        {
+               {
                        $test['result'] = false;
                        $test['comments'][] = sprintf(_('Missing system locale: %s'), $lang['code'].".".$lang['encoding']);
-        };
+               };
        }
-       
-       setlocale(LC_MESSAGES, $old);
 
        $test['test'] = $langs;
 
@@ -291,7 +303,6 @@ function tst_extconfig()
        $test['test'][] = $fname;
        $test['result'] = is_file($fname) && is_writable($fname);
        $test['test'][] = company_path().'/*/installed_extensions.php';
-       $test['comments'][] = _("Extensions configuration files and directories should be writeable");
 
        foreach ($db_connections as $n => $comp) {
                $path = company_path($n);
@@ -308,12 +319,41 @@ function tst_extconfig()
        $test['test'][] = $fname;
        $test['result'] &= is_dir($fname) && is_writable($fname);
        $fname =  $path_to_root.'/modules/_cache';
+
        $test['test'][] = $fname;
        $test['result'] &= is_dir($fname) && is_writable($fname);
        $fname =  $path_to_root.'/themes';
+
        $test['test'][] = $fname;
        $test['result'] &= is_dir($fname) && is_writable($fname);
+       if(!$test['result'])
+               $test['comments'][] = _("Extensions configuration files and directories should be writeable");
+
+       $themedir = opendir($fname);
+       while (false !== ($fname = readdir($themedir)))
+       {
+               if ($fname!='.' && $fname!='..' && $fname!='CVS' && is_dir($path_to_root.'/themes/'.$fname)
+                       && !in_array($fname, array('aqua', 'cool', 'default')))
+               {
+                       $test['test'][] = $fname;
+                       $test['result'] = is_writable($path_to_root.'/themes/'.$fname);
+                       if (!$test['result']) {
+                               $test['comments'][] = 
+                                       sprintf(_("Non-standard theme directory '%s' is not writable"), $fname);
+                               break;
+                       }
+               }
+       }
+       closedir($themedir);
 
+       $test['test'][] = 'OpenSSL PHP extension';
+       if (!extension_loaded('openssl')) {
+               $test['result'] = false;
+               $test['comments'][] = _("OpenSSL PHP extension have to be enabled to use extension repository system.");
+       } elseif (!function_exists('openssl_verify')) {
+               $test['result'] = false;
+               $test['comments'][] = _("OpenSSL have to be available on your server to use extension repository system.");
+       }
        return $test;
 }
 //-------------------------------------------------------------------------------------------------
index f2115a9aa95a17b46932072b77faab517d6554e8..9cedafc63ec21f5d435029785620f84646a07b78 100644 (file)
@@ -100,20 +100,21 @@ class gettext_native_support
         */
        function check_support($lang_code, $encoding)
     {
-               $old = setlocale(LC_MESSAGES, '0');
+
+               $old = setlocale(LC_CTYPE, '0'); // LC_MESSAGES does not exist on Win
                $up = strtoupper($encoding);
                $low = strtolower($encoding);
                $lshort = strtr($up, '-','');
                $ushort = strtr($low, '-','');
 
-        $test = setlocale(LC_MESSAGES,
+        $test = setlocale(LC_ALL,
                        $lang_code.".".$encoding, 
                        $lang_code.".".$up,
                        $lang_code.".".$low,
                        $lang_code.".".$ushort,
                        $lang_code.".".$lshort) !== false;
-
-               setlocale(LC_MESSAGES, $old);
+               setlocale(LC_ALL, $old);
+               setlocale(LC_NUMERIC, 'C');
                return $test;
        }
     /**