From cdea200a3f1f1c3ebb65f9afae864bf8cde43c6a Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Sat, 7 Aug 2010 10:02:43 +0000 Subject: [PATCH] Default language code changed from 'en_GB' to 'C'. --- admin/inst_lang.php | 6 +++--- includes/lang/gettext.php | 11 +++++++---- includes/lang/language.php | 2 +- includes/system_tests.inc | 31 ++++++++++++++++++++++--------- sql/alter2.3.php | 17 ++++++++++++++++- sql/alter2.3rc.sql | 2 ++ sql/en_US-demo.sql | 8 ++++---- 7 files changed, 55 insertions(+), 22 deletions(-) diff --git a/admin/inst_lang.php b/admin/inst_lang.php index 4b51795a..69bd225f 100644 --- a/admin/inst_lang.php +++ b/admin/inst_lang.php @@ -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 ?"), diff --git a/includes/lang/gettext.php b/includes/lang/gettext.php index 9cedafc6..16768d67 100644 --- a/includes/lang/gettext.php +++ b/includes/lang/gettext.php @@ -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) { diff --git a/includes/lang/language.php b/includes/lang/language.php index 2c32d84c..45aa3ee0 100644 --- a/includes/lang/language.php +++ b/includes/lang/language.php @@ -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; } diff --git a/includes/system_tests.inc b/includes/system_tests.inc index 2e227bc4..34e97e96 100644 --- a/includes/system_tests.inc +++ b/includes/system_tests.inc @@ -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 diff --git a/sql/alter2.3.php b/sql/alter2.3.php index e480eda5..3c1a2217 100644 --- a/sql/alter2.3.php +++ b/sql/alter2.3.php @@ -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; diff --git a/sql/alter2.3rc.sql b/sql/alter2.3rc.sql index c045f069..c50b6b05 100644 --- a/sql/alter2.3rc.sql +++ b/sql/alter2.3rc.sql @@ -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'; diff --git a/sql/en_US-demo.sql b/sql/en_US-demo.sql index 06ae277c..b2e48be8 100644 --- a/sql/en_US-demo.sql +++ b/sql/en_US-demo.sql @@ -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); -- -------------------------------------------------------- -- 2.30.2