]> git.mjollnir.org Git - moodle.git/commitdiff
Added a new administration page that can check the current language
authormartin <martin>
Tue, 3 Sep 2002 14:29:39 +0000 (14:29 +0000)
committermartin <martin>
Tue, 3 Sep 2002 14:29:39 +0000 (14:29 +0000)
pack against the English language pack.  It prints any missing strings
or files.  This should help language pack developers.

admin/index.php
admin/lang.php [new file with mode: 0644]
course/lib.php
lang/en/moodle.php
lib/moodlelib.php

index 8e0700269fbea87b403a49d08b59eb84bd2e1532..577dc5d1a2446570817515843cf7012e991dfe5d 100644 (file)
     $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>";
diff --git a/admin/lang.php b/admin/lang.php
new file mode 100644 (file)
index 0000000..43de5e3
--- /dev/null
@@ -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();
+
+?>
index e367527c856281a16f1989fae3dcc6e5db6f98e1..829e1279ee3c14e035cbc6bd89e005627001c4ab 100644 (file)
@@ -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>";
index 37046e51cb9550aea6f1dbe70bbb54e294dfed8f..49bbc3d287462f50a6452317f82d282efc399ef7 100644 (file)
@@ -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";
index 39d8aef4747822b9fe2efbe19688f532018c8007..cfef4ff2209b886b024c93456e60b4519592f87e 100644 (file)
@@ -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;
                 }