From: martin Date: Tue, 3 Sep 2002 14:29:39 +0000 (+0000) Subject: Added a new administration page that can check the current language X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=31410e9a16c19d694a3c56ecb3914c525e36b922;p=moodle.git Added a new administration page that can check the current language pack against the English language pack. It prints any missing strings or files. This should help language pack developers. --- diff --git a/admin/index.php b/admin/index.php index 8e0700269f..577dc5d1a2 100644 --- a/admin/index.php +++ b/admin/index.php @@ -188,7 +188,8 @@ $table->align = array ("CENTER", "CENTER", "CENTER"); $table->data[0][0] = "

".get_string("sitesettings")."

". "

id\">".get_string("sitelogs")."

". - "

".get_string("choosetheme")."

"; + "

".get_string("choosetheme")."

". + "

".get_string("checklanguage")."

"; $table->data[0][1] = "

".get_string("addnewcourse")."

". "

".get_string("assignteachers")."

". "

".get_string("deletecourse")."

"; diff --git a/admin/lang.php b/admin/lang.php new file mode 100644 index 0000000000..43de5e3ed7 --- /dev/null +++ b/admin/lang.php @@ -0,0 +1,101 @@ +fullname", "$site->fullname", + "$stradministration + -> $strchecklanguage -> $CFG->lang"); + + + // Get a list of all the files in the English directory + + if (! $files = get_directory_list("$CFG->dirroot/lang/en", "CVS")) { + error("Could not find English language pack!"); + } + + // For each file, check that a counterpart exists, then check all the strings + + $langdir = "$CFG->dirroot/lang/$CFG->lang"; + $enlangdir = "$CFG->dirroot/lang/en"; + + $dir = opendir($enlangdir); + + + while ($file = readdir($dir)) { + if ($file == "." or $file == ".." or $file == "CVS" or $file == "README" or $file == "help" or $file == "docs") { + continue; + } + + if (!file_exists("$langdir/$file")) { + echo "

".get_string("filemissing", "", "$langdir/$file")."

"; + continue; + } + + unset($string); + include("$enlangdir/$file"); + $enstring = $string; + + unset($string); + include("$langdir/$file"); + + $first = true; + foreach ($enstring as $key => $value) { + if (!isset($string[$key])) { + $value = htmlentities($value); + $value = str_replace("$"."a", "\\$"."a", $value); + if ($first) { + echo "

".get_string("stringsnotset","","$langdir/$file")."

";
+                    $first = false;
+                    $somethingfound = true;
+                }
+                echo "$"."string[$key] = \"$value\";
"; + } + } + } + closedir($dir); + + if (! $files = get_directory_list("$CFG->dirroot/lang/en/help", "CVS")) { + error("Could not find English language help files!"); + } + + foreach ($files as $filekey => $file) { // check all the help files. + if (!file_exists("$langdir/help/$file")) { + echo "

".get_string("filemissing", "", "$langdir/help/$file")."

"; + $somethingfound = true; + continue; + } + } + + if (! $files = get_directory_list("$CFG->dirroot/lang/en/docs", "CVS")) { + error("Could not find English language docs files!"); + } + foreach ($files as $filekey => $file) { // check all the docs files. + if (!file_exists("$langdir/docs/$file")) { + echo "

".get_string("filemissing", "", "$langdir/docs/$file")."

"; + $somethingfound = true; + continue; + } + } + + if (!$somethingfound) { + notice(get_string("languagegood"), "index.php"); + } else { + print_continue("index.php"); + } + + print_footer(); + +?> diff --git a/course/lib.php b/course/lib.php index e367527c85..829e1279ee 100644 --- a/course/lib.php +++ b/course/lib.php @@ -514,6 +514,8 @@ function print_admin_links ($siteid, $width=180) { $modicon[]=$icon; $moddata[]="wwwroot/theme/index.php\">".get_string("choosetheme").""; $modicon[]=$icon; + $moddata[]="wwwroot/admin/lang.php\">".get_string("checklanguage").""; + $modicon[]=$icon; $moddata[]="wwwroot/course/edit.php\">".get_string("addnewcourse").""; $modicon[]=$icon; $moddata[]="wwwroot/course/teacher.php\">".get_string("assignteachers").""; diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 37046e51cb..49bbc3d287 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -30,8 +30,7 @@ $string[category] = "Category"; $string[changepassword] = "Change password"; $string[changedpassword] = "Changed password"; $string[changessaved] = "Changes saved"; -$string[checklanguage] = "Check language (\$a)"; -$string[checklanguagediff] = "The following differences were found between the current language and English:"; +$string[checklanguage] = "Check language"; $string[choose] = "Choose"; $string[choosecourse] = "Choose a course"; $string[chooselivelogs] = "Or watch current activity"; @@ -123,6 +122,7 @@ $string[enteremailaddress] = "Enter in your email address to reset your $string[existingteachers] = "Existing teachers"; $string[error] = "Error"; $string[feedback] = "Feedback"; +$string[filemissing] = "\$a is missing"; $string[files] = "Files"; $string[filloutallfields] = "Please fill out all fields in this form"; $string[firstname] = "First name"; @@ -169,6 +169,7 @@ $string[idnumber] = "ID number"; $string[leavetokeep] = "Leave blank to keep current password"; $string[invalidlogin] = "Invalid login, please try again"; $string[invalidemail] = "Invalid email address"; +$string[languagegood] = "This language pack is up-to-date! :-)"; $string[lastaccess] = "Last access"; $string[lastedited] = "Last edited"; $string[lastmodified] = "Last modified"; @@ -348,6 +349,7 @@ $string[someallowguest] = "Some courses may allow guest access"; $string[startdate] = "Course start date"; $string[startsignup] = "Start now by creating a new account!"; $string[status] = "Status"; +$string[stringsnotset] = "The following strings are not defined in \$a"; $string[success] = "Success"; $string[summary] = "Summary"; $string[summaryof] = "Summary of \$a"; diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 39d8aef474..cfef4ff220 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1373,7 +1373,7 @@ function get_directory_list($rootdir, $excludefile="") { if ($file != "." and $file != ".." and $file != $excludefile) { $fullfile = $rootdir."/".$file; if (filetype($fullfile) == "dir") { - $subdirs = get_directory_list($fullfile); + $subdirs = get_directory_list($fullfile, $excludefile); foreach ($subdirs as $subdir) { $dirs[] = $file."/".$subdir; }