[LON-CAPA-cvs] cvs: loncom /homework daxeopen.pm

raeburn raeburn at source.lon-capa.org
Wed Aug 23 18:25:48 EDT 2023


raeburn		Wed Aug 23 22:25:48 2023 EDT

  Modified files:              
    /loncom/homework	daxeopen.pm 
  Log:
  - Localize error messages using &mt().
  
  
Index: loncom/homework/daxeopen.pm
diff -u loncom/homework/daxeopen.pm:1.9 loncom/homework/daxeopen.pm:1.10
--- loncom/homework/daxeopen.pm:1.9	Wed Aug 23 22:21:05 2023
+++ loncom/homework/daxeopen.pm	Wed Aug 23 22:25:48 2023
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Opening converted problems and directory listings for Daxe
 #
-# $Id: daxeopen.pm,v 1.9 2023/08/23 22:21:05 raeburn Exp $
+# $Id: daxeopen.pm,v 1.10 2023/08/23 22:25:48 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -42,7 +42,7 @@
 use Apache::pre_xml;
 use Apache::html_to_xml;
 use Apache::post_xml;
-
+use Apache::lonlocal;
 
 sub handler {
     my $request = shift;
@@ -62,13 +62,12 @@
 
 sub convert_problem {
     my ($uri, $request) = @_;
-    
     if ($uri =~ m{^/priv/([^/]+)/([^/]+)/}) {
         my ($domain, $user) = ($1, $2);
         my ($uname, $udom) = ($env{'user.name'}, $env{'user.domain'});
         if (!defined $uname || !defined $udom || $domain ne $udom || $user ne $uname) {
             $request->content_type('text/plain');
-            $request->print("Forbidden URI: $uri");
+            $request->print(&mt('Forbidden URI: [_1]',$uri));
             $request->status(403);
             return OK;
         }
@@ -95,7 +94,7 @@
         return OK;
     } catch {
         $request->content_type('text/plain');
-        $request->print("convert failed for $file: $_");
+        $request->print(&mt('convert failed for [_1]:',$file)." $_");
         $request->status(406);
         return OK;
     };
@@ -111,7 +110,7 @@
         $res .= "<directory name=\"res\"/>\n";
     } elsif ($uri !~ /^\/(priv|res)\//) {
         $request->content_type('text/plain');
-        $request->print("Not found: $uri");
+        $request->print(&mt('Not found: [_1]',$uri));
         $request->status(404);
         return OK;
     } elsif ($uri =~ m{^/res/}) {
@@ -119,12 +118,12 @@
 	my ($listref, $listerror) = &Apache::lonnet::dirlist($uri);
 	if ($listerror) {
             $request->content_type('text/plain');
-            $request->print("listing error: $listerror");
+            $request->print(&mt('listing error: [_1]',$listerror));
             $request->status(406);
             return OK;
 	} elsif ($uri =~ m{^/res/[^/]+/$} && scalar(@{$listref}) == 0) {
             $request->content_type('text/plain');
-            $request->print("Not found: $uri");
+            $request->print(&mt('Not found: [_1]',$uri));
             $request->status(404);
             return OK;
 	}
@@ -167,7 +166,7 @@
         my $udom = $env{'user.domain'};
         if (!defined $udom) {
             $request->content_type('text/plain');
-            $request->print("Forbidden URI: $uri");
+            $request->print(&mt('Forbidden URI: [_1]',$uri));
             $request->status(403);
             return OK;
         }
@@ -178,7 +177,7 @@
         my ($uname, $udom) = ($env{'user.name'}, $env{'user.domain'});
         if (!defined $uname || !defined $udom || $domain ne $udom) {
             $request->content_type('text/plain');
-            $request->print("Forbidden URI: $uri");
+            $request->print(&mt('Forbidden URI: [_1]',$uri));
             $request->status(403);
             return OK;
         }
@@ -189,14 +188,14 @@
         my ($uname, $udom) = ($env{'user.name'}, $env{'user.domain'});
         if (!defined $uname || !defined $udom || $domain ne $udom || $user ne $uname) {
             $request->content_type('text/plain');
-            $request->print("Forbidden URI: $uri");
+            $request->print(&mt('Forbidden URI: [_1]',$uri));
             $request->status(403);
             return OK;
         }
         my $dirpath = &Apache::lonnet::filelocation('', $uri);
         if (! -e $dirpath) {
             $request->content_type('text/plain');
-            $request->print("Not found: $uri");
+            $request->print(&mt('Not found: [_1]',$uri));
             $request->status(404);
             return OK;
         }
@@ -207,7 +206,7 @@
             closedir($dir);
         } else {
             $request->content_type('text/plain');
-            $request->print("Error opening directory: $dirpath");
+            $request->print(&mt('Error opening directory: [_1]',$dirpath));
             $request->status(403);
             return OK;
         }
@@ -238,7 +237,7 @@
         }
     } else {
         $request->content_type('text/plain');
-        $request->print("Not found: $uri");
+        $request->print(&mt('Not found: [_1]',$uri));
         $request->status(404);
         return OK;
     }




More information about the LON-CAPA-cvs mailing list