diff --git a/config.template.php b/config.template.php index 73ad086e58a4f3696e9255d9e798f7a956c5dbdd..563174eec46d536e85693da39e42b46e85f15a95 100644 --- a/config.template.php +++ b/config.template.php @@ -169,7 +169,7 @@ $default_charset = '_VT_CHARSET_'; // default language // default_language default value = en_us -$default_language = 'en_us'; +$default_language = '_VT_DEFAULT_LANGUAGE_'; // add the language pack name to every translation string in the display. // translation_string_prefix default value = false diff --git a/languages/en_us/Install.php b/languages/en_us/Install.php index 83c21d54d560b4b19f79b54d9a18bf1d524ac94d..08da15bdb61fdaa559005223fb87a287e5b055d0 100644 --- a/languages/en_us/Install.php +++ b/languages/en_us/Install.php @@ -17,6 +17,7 @@ $languageStrings = array( 'ERR_UNABLE_CREATE_DATABASE' => 'Unable to Create database', 'LBL_ADMIN_INFORMATION'=>'Admin User Information', 'LBL_ADMIN_USER_INFORMATION' => 'Admin User Information', + 'LBL_CHOOSE_LANGUAGE' => 'Choose the default language for this installation:', 'LBL_CONFIRM_CONFIGURATION_SETTINGS' => 'Confirm Configuration Settings', 'LBL_CREATE_NEW_DB'=>'Create new database', 'LBL_CURRENCIES'=>'Currency', diff --git a/layouts/vlayout/modules/Install/Step1.tpl b/layouts/vlayout/modules/Install/Step1.tpl index 5bff3cdd82031df3b6fd4e8c07b25ecb314ac6ac..011a83ab6701811462afb13bd003171a2ed3aeb7 100644 --- a/layouts/vlayout/modules/Install/Step1.tpl +++ b/layouts/vlayout/modules/Install/Step1.tpl @@ -37,6 +37,17 @@ <h3>{vtranslate('LBL_WELCOME_TO_VTIGER6_SETUP_WIZARD', 'Install')}</h3> {vtranslate('LBL_VTIGER6_SETUP_WIZARD_DESCRIPTION','Install')} </div> + {if $LANGUAGES|@count > 1} + <div> + <label>{vtranslate('LBL_CHOOSE_LANGUAGE', 'Install')} + <select name="lang" id="lang"> + {foreach key=header item=language from=$LANGUAGES} + <option value="{$header}" {if $header eq $CURRENT_LANGUAGE}selected{/if}>{vtranslate("$language",'Install')}</option> + {/foreach} + </select> + </label> + </div> + {/if} </div> </div> <div class="row-fluid"> diff --git a/modules/Install/models/ConfigFileUtils.php b/modules/Install/models/ConfigFileUtils.php index 4814b031ad46741885f7db566af3c3d62198b165..34cbbf0238c1d745c84cbb27bd89c0a2021542c6 100644 --- a/modules/Install/models/ConfigFileUtils.php +++ b/modules/Install/models/ConfigFileUtils.php @@ -20,6 +20,7 @@ class Install_ConfigFileUtils_Model { private $siteUrl; private $cacheDir; private $vtCharset = 'UTF-8'; + private $vtDefaultLanguage = 'en_us'; private $currencyName; private $adminEmail; @@ -43,6 +44,7 @@ class Install_ConfigFileUtils_Model { if (isset($configFileParameters['admin_email'])) $this->adminEmail = $configFileParameters['admin_email']; if (isset($configFileParameters['currency_name'])) $this->currencyName = $configFileParameters['currency_name']; if (isset($configFileParameters['vt_charset'])) $this->vtCharset = $configFileParameters['vt_charset']; + if (isset($configFileParameters['default_language'])) $this->vtDefaultLanguage = $configFileParameters['default_language']; // update default port if ($this->dbPort == '') $this->dbPort = self::getDbDefaultPort($this->dbType); @@ -88,6 +90,9 @@ class Install_ConfigFileUtils_Model { /* replace charset variable */ $buffer = str_replace( "_VT_CHARSET_", $this->vtCharset, $buffer); + /* replace default lanugage variable */ + $buffer = str_replace( "_VT_DEFAULT_LANGUAGE_", $this->vtDefaultLanguage, $buffer); + /* replace master currency variable */ $buffer = str_replace( "_MASTER_CURRENCY_", $this->currencyName, $buffer); @@ -254,7 +259,7 @@ ini_set('memory_limit','64M'); // default language // default_language default value = en_us -\$default_language = 'en_us'; +\$default_language = '{$this->vtDefaultLanguage}'; // add the language pack name to every translation string in the display. // translation_string_prefix default value = false diff --git a/modules/Install/models/InitSchema.php b/modules/Install/models/InitSchema.php index 7b8e5a2498d3308225a89728a79ad33b91718c4f..144283ea97db524ebc6d4be571c8fc7a5a1703ca 100644 --- a/modules/Install/models/InitSchema.php +++ b/modules/Install/models/InitSchema.php @@ -770,6 +770,7 @@ class Install_InitSchema_Model { //Fix for http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/7974 $userFirstName = $_SESSION['config_file_info']['firstname']; $userLastName = $_SESSION['config_file_info']['lastname']; + $userLanguage = $_SESSION['config_file_info']['default_language']; // create default admin user $user = CRMEntity::getInstance('Users'); //Fix for http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/7974 @@ -781,6 +782,7 @@ class Install_InitSchema_Model { $user->column_fields["is_admin"] = 'on'; $user->column_fields["user_password"] = $adminPassword; $user->column_fields["time_zone"] = $userTimeZone; + $user->column_fields["language"] = $userLanguage; $user->column_fields["holidays"] = 'de,en_uk,fr,it,us,'; $user->column_fields["workdays"] = '0,1,2,3,4,5,6,'; $user->column_fields["weekstart"] = '1'; diff --git a/modules/Install/models/Utils.php b/modules/Install/models/Utils.php index 87a7d28c322c3567109ad29f7458f23cd66c69ba..af08cb4aae539510c81d617be55bd4e0f3c4e5c1 100644 --- a/modules/Install/models/Utils.php +++ b/modules/Install/models/Utils.php @@ -273,6 +273,33 @@ class Install_Utils_Model { return $currencies; } + + /** + * Returns an array with the list of languages which are available in source + * Note: the DB has not been initialized at this point, so we have to look at + * the contents of the `languages/` directory. + * @return <Array> + */ + public static function getLanguageList() { + $languageFolder = 'languages/'; + $handle = opendir($languageFolder); + $language_list = array(); + while ($prefix = readdir($handle)) { + if (substr($prefix, 0, 1) === '.' || $prefix === 'Settings') { + continue; + } + if (is_dir('languages/' . $prefix) && is_file('languages/' . $prefix . '/Install.php')) { + $language_list[$prefix] = $prefix; + } + } + + ksort($language_list); + + return $language_list; + } + + + /** * Function checks if its mysql type * @param type $dbType diff --git a/modules/Install/views/Index.php b/modules/Install/views/Index.php index 3d7017986bac49424ffd22a1b4adbe6e79bec7f0..2942acedf33b35b72a69163b4afb3bdbacd07533 100644 --- a/modules/Install/views/Index.php +++ b/modules/Install/views/Index.php @@ -41,8 +41,12 @@ class Install_Index_view extends Vtiger_View_Controller { parent::preProcess($request); $viewer = $this->getViewer($request); $moduleName = $request->getModule(); - $defaultLanguage = ($request->get('lang'))?$request->get('lang'):'en_us'; - vglobal('default_language', $defaultLanguage); + if ($chosenLanguage = $request->get('lang')) { + $_SESSION['config_file_info']['default_language'] = $chosenLanguage; + } elseif (empty($_SESSION['config_file_info']['default_language'])) { + $_SESSION['config_file_info']['default_language'] = 'en_us'; + } + vglobal('default_language', $_SESSION['config_file_info']['default_language']); define('INSTALLATION_MODE', true); define('INSTALLATION_MODE_DEBUG', $this->debug); @@ -67,6 +71,8 @@ class Install_Index_view extends Vtiger_View_Controller { public function Step1(Vtiger_Request $request) { $viewer = $this->getViewer($request); $moduleName = $request->getModule(); + $viewer->assign('CURRENT_LANGUAGE', vglobal('default_language')); + $viewer->assign('LANGUAGES', Install_Utils_model::getLanguageList()); $viewer->view('Step1.tpl', $moduleName); }