Default language code changed from 'en_GB' to 'C'.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sat, 7 Aug 2010 10:02:43 +0000 (10:02 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sat, 7 Aug 2010 10:02:43 +0000 (10:02 +0000)
admin/inst_lang.php
includes/lang/gettext.php
includes/lang/language.php
includes/system_tests.inc
sql/alter2.3.php
sql/alter2.3rc.sql
sql/en_US-demo.sql

index 4b51795ab006dc1f0c503a8b19dd8d7071fc1c47..69bd225f59d5588c26b39825d33c61b5d0aea717 100644 (file)
@@ -72,7 +72,7 @@ function display_languages()
                else
                        alt_table_row_color($k);
 
-               $support = ($lang == 'en_GB') ||
+               $support = ($lang == 'C') ||
                        $_SESSION['get_text']->check_support($lang, $charset);
 
                if (function_exists('gettext') && !$support && !get_post('DisplayAll')) continue;
@@ -94,7 +94,7 @@ function display_languages()
                if (function_exists('gettext') && check_value('DisplayAll'))
                        label_cell($support ? _("Yes") :_("No"));
 
-               if (!$available && ($lang != 'en_GB'))  // manually installed language
+               if (!$available && ($lang != 'C'))      // manually installed language
                        button_cell('Edit'.$id, _("Edit"), _('Edit non standard language configuration'), 
                                ICON_EDIT);
                elseif (check_pkg_upgrade($installed, $available)) // outdated or not installed language in repo
@@ -103,7 +103,7 @@ function display_languages()
                else
                        label_cell('');
 
-               if (($id !== null) && ($lang != $currlang) && ($lang != 'en_GB')) {
+               if (($id !== null) && ($lang != $currlang) && ($lang != 'C')) {
                        delete_button_cell('Delete'.$id, _('Delete'));
                        submit_js_confirm('Delete'.$id, 
                                sprintf(_("You are about to remove language \'%s\'.\nDo you want to continue ?"), 
index 9cedafc63ec21f5d435029785620f84646a07b78..16768d677df3041406fd406fc8c22688d7e1f1df 100644 (file)
@@ -80,10 +80,13 @@ class gettext_native_support
                $lshort = strtr($up, '-','');
                $ushort = strtr($low, '-','');
 
-        $set = setlocale(LC_ALL, $lang_code.".".$encoding, 
-                       $lang_code.".".$up, $lang_code.".".$low,
-                       $lang_code.".".$ushort, $lang_code.".".$lshort);
-                       
+               if ($lang_code == 'C')
+                       $set = setlocale(LC_ALL,'C');
+               else
+               $set = setlocale(LC_ALL, $lang_code.".".$encoding, 
+                               $lang_code.".".$up, $lang_code.".".$low,
+                               $lang_code.".".$ushort, $lang_code.".".$lshort);
+
         setlocale(LC_NUMERIC, 'C'); // important for numeric presentation etc.
         if ($set === false) 
         {
index 2c32d84c46a23cd958935139a277794fff81e535..45aa3ee009685101f271e044fd3981e82c7bf969 100644 (file)
@@ -30,7 +30,7 @@ class language
                global $dflt_lang;
                
                $this->name = $name;
-               $this->code = $code ? $code : ($dflt_lang ? $dflt_lang : 'en_GB');
+               $this->code = $code ? $code : ($dflt_lang ? $dflt_lang : 'C');
                $this->encoding = $encoding;
                $this->dir = $dir;
        }
index 2e227bc48ddf36a374dd73c601d9fc58f64b613a..34e97e9639d6721fabc9c2c65e34b54118fa22b2 100644 (file)
@@ -236,25 +236,28 @@ function tst_langs()
        $test['comments'] = array();
 
        $fname =  $path_to_root.'/lang';
-       $test['test'][] = $fname;
+       $test['test'] = $fname;
        if (!(is_dir($fname) && is_writable($fname))) {
                $test['result'] = false;
                $test['comments'][] = _("Languages folder should be writeable.");
+               return $test;
        }
        
        $fname =  $path_to_root.'/lang/installed_languages.inc';
-       $test['test'][] = $fname;
+       $test['test'] = $fname;
        if (!(is_file($fname) && is_writable($fname))) {
                $test['result'] = false;
                $test['comments'][] = _("Languages configuration file should be writeable.");
+               return $test;
        }
 
        $langs = array();
        
        foreach ($installed_languages as $lang) {
+
+               if ($lang['code'] == 'C') continue; // no translation (English)
                $langs[] = $lang['code'];
-               if ($lang['code'] == 'en_GB') continue; // native FA language
-       
+
                $file = $path_to_root.'/lang/'.$lang['code'].'/LC_MESSAGES/'.$lang['code'];
                if (@$lang['version'])
                        $file .= '-'.$lang['version'];
@@ -297,16 +300,25 @@ function tst_config($install)
        return $test;
 }
 
-function tst_dbconfig()
+function tst_dbconfig($install)
 {
        global $path_to_root;
 
        $test['descr'] = _('Database auth file');
-       $test['type'] = 2;
        $test['test'] = $path_to_root.'/config_db.php';
-       $test['result'] = is_file($test['test']) && !is_writable($test['test']);
-       $test['comments'][] = sprintf(_("'%s' file should be read-only if you do not plan to add or change companies"), $test['test']);
 
+       if ($install) {
+               $test['type'] = 3;
+               $writable = check_write($test['test']);
+               $test['result'] = $writable==1;
+               $test['comments'][] = $writable == 0 ?
+                       sprintf(_("Can't write '%s' file. Check FA directory write permissions."), $test['test'])
+                       : sprintf(_("'%s' file exists."), $test['test']);
+       } else {
+               $test['type'] = 2;
+               $test['result'] = is_file($test['test']) && !is_writable($test['test']);
+               $test['comments'][] = sprintf(_("'%s' file should be read-only if you do not plan to add or change companies"), $test['test']);
+       }
        return $test;
 }
 
@@ -386,7 +398,8 @@ function display_system_tests($install = false)
        global $test_level;
 
        if ($install)
-               $system_tests = array('tst_php', 'tst_phpmysql', 'tst_system', 'tst_config',
+               $system_tests = array('tst_php', 'tst_phpmysql', 'tst_system', 'tst_dbconfig', 
+                       'tst_config',
                        'tst_subdirs', 'tst_langs', 'tst_tmpdir', 'tst_sessionpath', 'tst_extconfig'
                );
        else
index e480eda5eb12eed2e79079ffb518722d7bd42890..3c1a2217bd60ef592d0814a32d4f8215a189db80 100644 (file)
@@ -26,7 +26,7 @@ class fa2_3 {
        //
        function install($pref, $force) 
        {
-               global $db_version;
+               global $db_version, $dflt_lang;
 
                if (!$this->preconf)
                        return false;
@@ -91,6 +91,7 @@ class fa2_3 {
                        if (!db_query($sql))
                                return false;
                }
+               $this->update_lang_cfg();
                return  update_company_prefs(array('version_id'=>$db_version), $pref);
        }
        //
@@ -348,6 +349,20 @@ class fa2_3 {
                } else
                        return true;
        }
+       
+       function update_lang_cfg()
+       {
+               global $dflt_lang, $installed_languages;
+
+               foreach($installed_languages as $n => $lang) {
+                       if ($lang['code'] == 'en_GB') {
+                               $installed_languages[$n] = 'C';
+                               if ($dflt_lang == 'en_GB')
+                                       $dflt_lang = 'C';
+                               write_lang();
+                       }
+               }
+       }
 }
 
 $install = new fa2_3;
index c045f069c15a1b6d8cdfb63bbfb24c11bed0b77d..c50b6b05363f2d94454ccaf14e6258b5242f91a8 100644 (file)
@@ -1,2 +1,4 @@
 ALTER TABLE `0_supp_trans` ADD COLUMN `tax_included` tinyint(1) NOT NULL default '0';
 ALTER TABLE `0_purch_orders` ADD COLUMN `tax_included` tinyint(1) NOT NULL default '0';
+UPDATE `crm_persons` SET `lang`='C' WHERE `lang`='en_GB';
+UPDATE `crm_users` SET `language`='C' WHERE `language`='en_GB';
index 06ae277c5e3e84829dc0db91eab8735c75cfd6b2..b2e48be8ab6c828b3f04106d1817a838cf515b6d 100644 (file)
@@ -520,15 +520,15 @@ CREATE TABLE IF NOT EXISTS `0_crm_persons` (
 -- Dumping data for table `0_crm_persons`
 --
 
-INSERT INTO `0_crm_persons` VALUES(1, 'Beefeater', '', NULL, NULL, NULL, NULL, NULL, '', 'en_GB', '', 0);
+INSERT INTO `0_crm_persons` VALUES(1, 'Beefeater', '', NULL, NULL, NULL, NULL, NULL, '', 'C', '', 0);
 INSERT INTO `0_crm_persons` VALUES(2, 'Ghostbusters', '', NULL, NULL, NULL, NULL, NULL, '', NULL, '', 0);
-INSERT INTO `0_crm_persons` VALUES(3, 'Brezan', '', NULL, NULL, NULL, NULL, NULL, '', 'en_GB', '', 0);
+INSERT INTO `0_crm_persons` VALUES(3, 'Brezan', '', NULL, NULL, NULL, NULL, NULL, '', 'C', '', 0);
 INSERT INTO `0_crm_persons` VALUES(4, 'Beefeater', 'Main Branch', NULL, '', '', '', '', '', NULL, '', 0);
 INSERT INTO `0_crm_persons` VALUES(5, 'Ghostbusters', 'Main Branch', NULL, 'Address 1\nAddress 2\nAddress 3', '', '', '', '', NULL, '', 0);
 INSERT INTO `0_crm_persons` VALUES(6, 'Brezan', 'Main Branch', NULL, 'Address 1\nAddress 2\nAddress 3', '', '', '', '', NULL, '', 0);
-INSERT INTO `0_crm_persons` VALUES(7, 'Junk Beer', 'Contact', NULL, 'Address 1\nAddress 2\nAddress 3', '+45 55667788', '', '', '', 'en_GB', '', 0);
+INSERT INTO `0_crm_persons` VALUES(7, 'Junk Beer', 'Contact', NULL, 'Address 1\nAddress 2\nAddress 3', '+45 55667788', '', '', '', 'C', '', 0);
 INSERT INTO `0_crm_persons` VALUES(8, 'Lucky Luke', 'Luke', NULL, 'Address 1\nAddress 2\nAddress 3', '(111) 222.333.444', '', '', '', NULL, '', 0);
-INSERT INTO `0_crm_persons` VALUES(9, 'Money Makers', 'Makers', NULL, 'Address 1\nAddress 2\nAddress 3', '+44 444 555 666', '', '', '', 'en_GB', '', 0);
+INSERT INTO `0_crm_persons` VALUES(9, 'Money Makers', 'Makers', NULL, 'Address 1\nAddress 2\nAddress 3', '+44 444 555 666', '', '', '', 'C', '', 0);
 
 -- --------------------------------------------------------