diff --git a/checkin_notes b/checkin_notes index a316364ecd..4ed46e8913 100644 --- a/checkin_notes +++ b/checkin_notes @@ -3281,3 +3281,21 @@ David 24 Mar 2009 client/ main.cpp,h + +David 24 Mar 2009 + - upgrade and make_project scripts: run update_translations.php, + which compiles the translation files into the form + used by the web code. + Projects that don't use "upgrade" will need to do this manually + whenever translation files change. + + html/ + inc/ + translation.inc + ops/ + update_translations.php + user/ + language_select.php + tools/ + upgrade + make_project diff --git a/html/inc/translation.inc b/html/inc/translation.inc index 36e8221564..e657d37178 100644 --- a/html/inc/translation.inc +++ b/html/inc/translation.inc @@ -20,8 +20,7 @@ $lang_language_dir = "../languages/"; $lang_translations_dir = "translations/"; $lang_prj_translations_dir = "project_specific_translations/"; $lang_compiled_dir = "compiled/"; -$lang_log_level = 0; -$lang_log_file = $lang_language_dir."translator.log"; +$lang_log_level = 1; /** * Fetches a list of compiled languages from the directory @@ -30,6 +29,7 @@ $lang_log_file = $lang_language_dir."translator.log"; */ function getSupportedLanguages(){ global $lang_language_dir, $lang_compiled_dir; + $list = array(); if (is_dir($lang_language_dir.$lang_compiled_dir)) { if ($dh = opendir($lang_language_dir.$lang_compiled_dir)) { while ($file = readdir($dh)) { @@ -180,19 +180,13 @@ function tr_specific($text, $language){ } function language_log($message, $loglevel=0){ - global $lang_log_level, $lang_log_file; + global $lang_log_level; if ($loglevel==0) $msg = "[ Debug ]"; if ($loglevel==1) $msg = "[ Warning ]"; if ($loglevel==2) $msg = "[ CRITICAL ]"; if ($loglevel>=$lang_log_level){ - $fh = fopen($lang_log_file,"a"); - if (!$fh) { - echo "failed to open log file $lang_log_file\n"; - return; - } - fwrite($fh, date("Y-m-d H:i:s",time())." ".$msg." ".$message."\n"); - fclose($fh); + echo date("Y-m-d H:i:s",time())." ".$msg." ".$message."\n"; } } diff --git a/html/ops/update_translations.php b/html/ops/update_translations.php index 797b10647b..8e6378236f 100644 --- a/html/ops/update_translations.php +++ b/html/ops/update_translations.php @@ -1,4 +1,21 @@ . + error_reporting(E_ALL); ini_set('display_errors', true); ini_set('display_startup_errors', true); @@ -7,5 +24,4 @@ require_once("../inc/translation.inc"); buildLanguages($lang_language_dir,$lang_translations_dir, $lang_compiled_dir); buildLanguages($lang_language_dir,$lang_prj_translations_dir, $lang_compiled_dir, true); -echo "update_translations finished\n"; ?> diff --git a/html/user/language_select.php b/html/user/language_select.php index be64d831e1..591ad49f01 100644 --- a/html/user/language_select.php +++ b/html/user/language_select.php @@ -21,6 +21,10 @@ require_once("../inc/util.inc"); require_once("../inc/translation.inc"); $languages = getSupportedLanguages(); +if (!is_array($languages)) { + error_page("Language selection not enabled. Project admins must run the update_translations.php script."); +} + $prefs = $_SERVER["HTTP_ACCEPT_LANGUAGE"]; $set_lang = get_str("set_lang", true); diff --git a/tools/make_project b/tools/make_project index de151c791c..e127ba6df5 100755 --- a/tools/make_project +++ b/tools/make_project @@ -278,6 +278,16 @@ try: except: print '''Couldn't find svnversion''' +try: + os.system('/bin/sh -c /usr/bin/svnversion > '+proot+'/db_revision') +except: + print '''Couldn't find svnversion''' + +try: + os.system('cd '+proot+'/html/ops; php update_translations.php') +except: + print '''Couldn't install translation files''' + print '''Done installing default daemons.''' # copy the test app if needed diff --git a/tools/upgrade b/tools/upgrade index 42613430d9..8e299e94d7 100755 --- a/tools/upgrade +++ b/tools/upgrade @@ -70,6 +70,11 @@ try: except: print '''Couldn't find svnversion''' +try: + os.system('cd '+INSTALL_DIR+'/html/ops; php update_translations.php') +except: + print '''Couldn't install translation files''' + os.system('cd '+INSTALL_DIR+'/html/ops; ./upgrade_db.php') if not options.web_only: