Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
authored September 03, 2002
3  admin/index.php
@@ -188,7 +188,8 @@
188 188
     $table->align = array ("CENTER", "CENTER", "CENTER");
189 189
     $table->data[0][0] = "<P><A HREF=\"site.php\">".get_string("sitesettings")."</A></P>".
190 190
                          "<P><A HREF=\"../course/log.php?id=$site->id\">".get_string("sitelogs")."</A></P>".
191  
-                         "<P><A HREF=\"../theme/index.php\">".get_string("choosetheme")."</A></P>";
  191
+                         "<P><A HREF=\"../theme/index.php\">".get_string("choosetheme")."</A></P>".
  192
+                         "<P><A HREF=\"lang.php\">".get_string("checklanguage")."</A></P>";
192 193
     $table->data[0][1] = "<P><A HREF=\"../course/edit.php\">".get_string("addnewcourse")."</A></P>".
193 194
                          "<P><A HREF=\"../course/teacher.php\">".get_string("assignteachers")."</A></P>".
194 195
                          "<P><A HREF=\"../course/delete.php\">".get_string("deletecourse")."</A></P>";
101  admin/lang.php
... ...
@@ -0,0 +1,101 @@
  1
+<?PHP // $Id$
  2
+
  3
+	require("../config.php");
  4
+
  5
+    require_login();
  6
+
  7
+    if (!isadmin()) {
  8
+        error("You need to be admin to edit this page");
  9
+    }     
  10
+
  11
+    if (! $site = get_site()) {
  12
+        error("Site not defined!");
  13
+    }
  14
+
  15
+    $stradministration = get_string("administration");
  16
+    $strchecklanguage = get_string("checklanguage");
  17
+
  18
+    print_header("$site->fullname", "$site->fullname",
  19
+                 "<A HREF=\"index.php\">$stradministration</A> 
  20
+                  -> $strchecklanguage -> $CFG->lang");
  21
+
  22
+
  23
+    // Get a list of all the files in the English directory
  24
+
  25
+    if (! $files = get_directory_list("$CFG->dirroot/lang/en", "CVS")) {
  26
+        error("Could not find English language pack!");
  27
+    }
  28
+
  29
+    // For each file, check that a counterpart exists, then check all the strings
  30
+
  31
+    $langdir = "$CFG->dirroot/lang/$CFG->lang";
  32
+    $enlangdir = "$CFG->dirroot/lang/en";
  33
+
  34
+    $dir = opendir($enlangdir);
  35
+
  36
+
  37
+    while ($file = readdir($dir)) {
  38
+        if ($file == "." or $file == ".." or $file == "CVS" or $file == "README" or $file == "help" or $file == "docs") {
  39
+            continue;
  40
+        }
  41
+
  42
+        if (!file_exists("$langdir/$file")) {
  43
+            echo "<P><FONT COLOR=red>".get_string("filemissing", "", "$langdir/$file")."</FONT></P>";
  44
+            continue;
  45
+        }
  46
+
  47
+        unset($string);
  48
+        include("$enlangdir/$file");
  49
+        $enstring = $string;  
  50
+
  51
+        unset($string);
  52
+        include("$langdir/$file");
  53
+
  54
+        $first = true;
  55
+        foreach ($enstring as $key => $value) {
  56
+            if (!isset($string[$key])) {
  57
+                $value = htmlentities($value);
  58
+                $value = str_replace("$"."a", "\\$"."a", $value);
  59
+                if ($first) {
  60
+                    echo "</PRE><HR><P><B>".get_string("stringsnotset","","$langdir/$file")."</B></P><PRE>";
  61
+                    $first = false;
  62
+                    $somethingfound = true;
  63
+                }
  64
+                echo "$"."string[$key] = \"$value\";<BR>";
  65
+            }
  66
+        }
  67
+    }
  68
+    closedir($dir);
  69
+
  70
+    if (! $files = get_directory_list("$CFG->dirroot/lang/en/help", "CVS")) {
  71
+        error("Could not find English language help files!");
  72
+    }
  73
+
  74
+    foreach ($files as $filekey => $file) {    // check all the help files.
  75
+        if (!file_exists("$langdir/help/$file")) {
  76
+            echo "<P><FONT COLOR=red>".get_string("filemissing", "", "$langdir/help/$file")."</FONT></P>";
  77
+            $somethingfound = true;
  78
+            continue;
  79
+        }
  80
+    }
  81
+
  82
+    if (! $files = get_directory_list("$CFG->dirroot/lang/en/docs", "CVS")) {
  83
+        error("Could not find English language docs files!");
  84
+    }
  85
+    foreach ($files as $filekey => $file) {    // check all the docs files.
  86
+        if (!file_exists("$langdir/docs/$file")) {
  87
+            echo "<P><FONT COLOR=red>".get_string("filemissing", "", "$langdir/docs/$file")."</FONT></P>";
  88
+            $somethingfound = true;
  89
+            continue;
  90
+        }
  91
+    }
  92
+
  93
+    if (!$somethingfound) {
  94
+        notice(get_string("languagegood"), "index.php");
  95
+    } else {
  96
+        print_continue("index.php");
  97
+    }
  98
+
  99
+    print_footer();
  100
+
  101
+?>
2  course/lib.php
@@ -514,6 +514,8 @@ function print_admin_links ($siteid, $width=180) {
514 514
     $modicon[]=$icon;
515 515
     $moddata[]="<A HREF=\"$CFG->wwwroot/theme/index.php\">".get_string("choosetheme")."</A>";
516 516
     $modicon[]=$icon;
  517
+    $moddata[]="<A HREF=\"$CFG->wwwroot/admin/lang.php\">".get_string("checklanguage")."</A>";
  518
+    $modicon[]=$icon;
517 519
     $moddata[]="<A HREF=\"$CFG->wwwroot/course/edit.php\">".get_string("addnewcourse")."</A>";
518 520
     $modicon[]=$icon;
519 521
     $moddata[]="<A HREF=\"$CFG->wwwroot/course/teacher.php\">".get_string("assignteachers")."</A>";
6  lang/en/moodle.php
@@ -30,8 +30,7 @@
30 30
 $string[changepassword] = "Change password";
31 31
 $string[changedpassword] = "Changed password";
32 32
 $string[changessaved] = "Changes saved";
33  
-$string[checklanguage] = "Check language (\$a)";
34  
-$string[checklanguagediff] = "The following differences were found between the current language and English:";
  33
+$string[checklanguage] = "Check language";
35 34
 $string[choose] = "Choose";
36 35
 $string[choosecourse] = "Choose a course";
37 36
 $string[chooselivelogs] = "Or watch current activity";
@@ -123,6 +122,7 @@
123 122
 $string[existingteachers] = "Existing teachers";
124 123
 $string[error] = "Error";
125 124
 $string[feedback] = "Feedback";
  125
+$string[filemissing] = "\$a is missing";
126 126
 $string[files] = "Files";
127 127
 $string[filloutallfields] = "Please fill out all fields in this form";
128 128
 $string[firstname] = "First name";
@@ -169,6 +169,7 @@
169 169
 $string[leavetokeep] = "Leave blank to keep current password";
170 170
 $string[invalidlogin] = "Invalid login, please try again";
171 171
 $string[invalidemail] = "Invalid email address";
  172
+$string[languagegood] = "This language pack is up-to-date! :-)";
172 173
 $string[lastaccess] = "Last access";
173 174
 $string[lastedited] = "Last edited";
174 175
 $string[lastmodified] = "Last modified";
@@ -348,6 +349,7 @@
348 349
 $string[startdate] = "Course start date";
349 350
 $string[startsignup] = "Start now by creating a new account!";
350 351
 $string[status] = "Status";
  352
+$string[stringsnotset] = "The following strings are not defined in \$a";
351 353
 $string[success] = "Success";
352 354
 $string[summary] = "Summary";
353 355
 $string[summaryof] = "Summary of \$a";
2  lib/moodlelib.php
@@ -1373,7 +1373,7 @@ function get_directory_list($rootdir, $excludefile="") {
1373 1373
         if ($file != "." and $file != ".." and $file != $excludefile) {
1374 1374
             $fullfile = $rootdir."/".$file;
1375 1375
             if (filetype($fullfile) == "dir") {
1376  
-                $subdirs = get_directory_list($fullfile);
  1376
+                $subdirs = get_directory_list($fullfile, $excludefile);
1377 1377
                 foreach ($subdirs as $subdir) {
1378 1378
                     $dirs[] = $file."/".$subdir;
1379 1379
                 }

0 notes on commit 31410e9

Please sign in to comment.
Something went wrong with that request. Please try again.