Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 31410e9a16c19d694a3c56ecb3914c525e36b922 1 parent cf38360
martin authored
View
3  admin/index.php
@@ -188,7 +188,8 @@
$table->align = array ("CENTER", "CENTER", "CENTER");
$table->data[0][0] = "<P><A HREF=\"site.php\">".get_string("sitesettings")."</A></P>".
"<P><A HREF=\"../course/log.php?id=$site->id\">".get_string("sitelogs")."</A></P>".
- "<P><A HREF=\"../theme/index.php\">".get_string("choosetheme")."</A></P>";
+ "<P><A HREF=\"../theme/index.php\">".get_string("choosetheme")."</A></P>".
+ "<P><A HREF=\"lang.php\">".get_string("checklanguage")."</A></P>";
$table->data[0][1] = "<P><A HREF=\"../course/edit.php\">".get_string("addnewcourse")."</A></P>".
"<P><A HREF=\"../course/teacher.php\">".get_string("assignteachers")."</A></P>".
"<P><A HREF=\"../course/delete.php\">".get_string("deletecourse")."</A></P>";
View
101 admin/lang.php
@@ -0,0 +1,101 @@
+<?PHP // $Id$
+
+ require("../config.php");
+
+ require_login();
+
+ if (!isadmin()) {
+ error("You need to be admin to edit this page");
+ }
+
+ if (! $site = get_site()) {
+ error("Site not defined!");
+ }
+
+ $stradministration = get_string("administration");
+ $strchecklanguage = get_string("checklanguage");
+
+ print_header("$site->fullname", "$site->fullname",
+ "<A HREF=\"index.php\">$stradministration</A>
+ -> $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 "<P><FONT COLOR=red>".get_string("filemissing", "", "$langdir/$file")."</FONT></P>";
+ 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 "</PRE><HR><P><B>".get_string("stringsnotset","","$langdir/$file")."</B></P><PRE>";
+ $first = false;
+ $somethingfound = true;
+ }
+ echo "$"."string[$key] = \"$value\";<BR>";
+ }
+ }
+ }
+ 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 "<P><FONT COLOR=red>".get_string("filemissing", "", "$langdir/help/$file")."</FONT></P>";
+ $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 "<P><FONT COLOR=red>".get_string("filemissing", "", "$langdir/docs/$file")."</FONT></P>";
+ $somethingfound = true;
+ continue;
+ }
+ }
+
+ if (!$somethingfound) {
+ notice(get_string("languagegood"), "index.php");
+ } else {
+ print_continue("index.php");
+ }
+
+ print_footer();
+
+?>
View
2  course/lib.php
@@ -514,6 +514,8 @@ function print_admin_links ($siteid, $width=180) {
$modicon[]=$icon;
$moddata[]="<A HREF=\"$CFG->wwwroot/theme/index.php\">".get_string("choosetheme")."</A>";
$modicon[]=$icon;
+ $moddata[]="<A HREF=\"$CFG->wwwroot/admin/lang.php\">".get_string("checklanguage")."</A>";
+ $modicon[]=$icon;
$moddata[]="<A HREF=\"$CFG->wwwroot/course/edit.php\">".get_string("addnewcourse")."</A>";
$modicon[]=$icon;
$moddata[]="<A HREF=\"$CFG->wwwroot/course/teacher.php\">".get_string("assignteachers")."</A>";
View
6 lang/en/moodle.php
@@ -30,8 +30,7 @@
$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[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[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[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";
View
2  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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.