mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
New languages system - get_string() in moodlelib.
This commit is contained in:
parent
be2e8c2ede
commit
1180c6dc56
@ -1,17 +0,0 @@
|
||||
<P ALIGN=CENTER><B>Uploading a picture</B></P>
|
||||
|
||||
<P>You can upload a picture from your computer to this server, and this picture will be used in various places to represent you.
|
||||
<P>For this reason, the best images to use are a close-up of your face, but you can use any image you like.
|
||||
<P>The picture must be in JPG or PNG format (ie the names will usually end in .jpg or .png).
|
||||
<P>You can get a picture file using one of four methods:
|
||||
|
||||
<OL>
|
||||
<LI>Using a digital camera, your photos will most likely already be on your computer in the right format.
|
||||
<LI>You can use a scanner to scan a printed photograph. Make sure you save it as JPG or PNG format.
|
||||
<LI>If you're artistic, you might draw a picture using a paint program.
|
||||
<LI>Lastly, you can "steal" images from the web. <A TARGET=google HREF="http://images.google.com/">http://images.google.com</A> is a superb place to search for images. Once you find one, you can "right-click" on them with the mouse and choose "Save this image..." from the menu (different computers may vary slightly).
|
||||
</OL>
|
||||
|
||||
<P>To upload the image, click the "Browse" button on this editing page, and select the image from your hard disk.
|
||||
<P>Then click "Update my Profile" at the bottom - the image file will be cropped to a square and resized down to 100x100 pixels.
|
||||
<P>When you are taken back to your profile page, the image might not appear to have changed. If this is so, just use the "Reload" button in your browser.
|
@ -1,41 +0,0 @@
|
||||
<P ALIGN=CENTER><B>Help on writing text</B></P>
|
||||
|
||||
Writing text in Moodle works pretty much the way you would expect, but you also have the ability to include "smilies", "URL addresses" and some HTML tags in your text.
|
||||
|
||||
<P><B>Smilies (emoticons)</B></P>
|
||||
<UL>
|
||||
<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5>
|
||||
<TR><TH>Name <TH>Picture <TH>You type</TR>
|
||||
<TR><TD>smile <TD ALIGN=CENTER><img ALT=smile SRC="<?=$CFG->wwwroot?>/pix/s/smiley.gif"><TD ALIGN=CENTER> :-) </TD></TR>
|
||||
<TR><TD>sad <TD ALIGN=CENTER><img ALT=sad SRC="<?=$CFG->wwwroot?>/pix/s/sad.gif"><TD ALIGN=CENTER> :-( </TD></TR>
|
||||
<TR><TD>grin <TD ALIGN=CENTER><img ALT=grin SRC="<?=$CFG->wwwroot?>/pix/s/biggrin.gif"><TD ALIGN=CENTER> :-D </TD></TR>
|
||||
<TR><TD>wink <TD ALIGN=CENTER><img ALT=wink SRC="<?=$CFG->wwwroot?>/pix/s/wink.gif"><TD ALIGN=CENTER> ;-) </TD></TR>
|
||||
<TR><TD>mixed <TD ALIGN=CENTER><img ALT=mixed SRC="<?=$CFG->wwwroot?>/pix/s/mixed.gif"><TD ALIGN=CENTER> :-/ </TD></TR>
|
||||
<TR><TD>wide-eyed <TD ALIGN=CENTER><img ALT=wide-eyed SRC="<?=$CFG->wwwroot?>/pix/s/wideeyes.gif"><TD ALIGN=CENTER> 8-) </TD></TR>
|
||||
<TR><TD>tongue-out <TD ALIGN=CENTER><img ALT=tongue-out SRC="<?=$CFG->wwwroot?>/pix/s/tongueout.gif"><TD ALIGN=CENTER> :-P </TD></TR>
|
||||
<TR><TD>surprise <TD ALIGN=CENTER><img ALT=surprised SRC="<?=$CFG->wwwroot?>/pix/s/surprise.gif"><TD ALIGN=CENTER> :-o </TD></TR>
|
||||
<TR><TD>cool <TD ALIGN=CENTER><img ALT=cool SRC="<?=$CFG->wwwroot?>/pix/s/cool.gif"><TD ALIGN=CENTER> B-) </TD></TR>
|
||||
</TABLE>
|
||||
</UL>
|
||||
|
||||
<P><B>URLs</B></P>
|
||||
<UL>
|
||||
<P>Any "word" starting with <B>www.</B> or <B>http://</B> will automatically be turned into a clickable link.
|
||||
<P>For example: <A HREF="http://www.yahoo.com">www.yahoo.com</A> or <A HREF="http://curtin.edu">http://curtin.edu</A>
|
||||
</UL>
|
||||
|
||||
<P><B>HTML tags</B></P>
|
||||
<UL>
|
||||
<P>You can use a limited subset of HTML tags to add emphasis to your texts.
|
||||
<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=5>
|
||||
<TR><TH>HTML tags<TH>Produces</TR>
|
||||
<TR><TD><B> bold </B> <TD> <B>bold text</B> </TR>
|
||||
<TR><TD><I> italic </I> <TD> <I>italic text</I> </TR>
|
||||
<TR><TD><U> underline </U> <TD> <U>underlined text</U> </TR>
|
||||
<TR><TD><FONT SIZE=1> small </FONT> <TD> <FONT SIZE=1>small</FONT> </TR>
|
||||
<TR><TD><FONT SIZE=4> large </FONT> <TD> <FONT SIZE=4>large</FONT> </TR>
|
||||
<TR><TD><FONT COLOR=green> example </FONT> <TD> <FONT color=green>example</FONT> </TR>
|
||||
</TABLE>
|
||||
</UL>
|
||||
|
||||
|
12
lang/en/strings.php
Normal file
12
lang/en/strings.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
// Strings for Moodle site
|
||||
|
||||
$string[loggedinas] = "You are logged in as \$a.";
|
||||
|
||||
$string[loggedinnot] = "You are not logged in.";
|
||||
|
||||
$string[login] = "Login";
|
||||
|
||||
$string[logout] = "Logout";
|
||||
|
||||
?>
|
@ -1090,6 +1090,97 @@ function get_directory_list( $rootdir ) {
|
||||
return $dirs;
|
||||
}
|
||||
|
||||
/// STRING TRANSLATION ////////////////////////////////////////
|
||||
|
||||
function get_string($identifier, $module="", $a="", $b="", $c="") {
|
||||
// Return the translated string specified by $identifier as
|
||||
// for $module. Uses the same format files as STphp.
|
||||
// $a, $b and $c are optional variables that may be used
|
||||
// within translation strings
|
||||
|
||||
global $CFG, $USER;
|
||||
|
||||
if (isset($USER->lang)) { // User language can override site language
|
||||
$lang = $USER->lang;
|
||||
} else {
|
||||
$lang = $CFG->lang;
|
||||
}
|
||||
|
||||
if ($module == "" or $module == "moodle") {
|
||||
$langpath = "$CFG->dirroot/lang";
|
||||
} else {
|
||||
$langpath = "$CFG->dirroot/mod/$module/lang";
|
||||
}
|
||||
|
||||
$langfile = "$langpath/$lang/strings.php";
|
||||
|
||||
if (!file_exists($langfile)) { // try English instead
|
||||
$langfile = "$langpath/en/strings.php";
|
||||
if (!file_exists($langfile)) {
|
||||
return "ERROR: No translation file found";
|
||||
}
|
||||
}
|
||||
|
||||
if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) {
|
||||
|
||||
eval($result);
|
||||
return $resultstring;
|
||||
|
||||
} else {
|
||||
if ($lang == "en") {
|
||||
return "ERROR: Translation string '$identifier' is missing!";
|
||||
|
||||
} else { // Try looking in the english file.
|
||||
$langfile = "$langpath/en/strings.php";
|
||||
if (!file_exists($langfile)) {
|
||||
return "ERROR: No translation file found";
|
||||
}
|
||||
if ($result = get_string_from_file($identifier, $langfile, "\$resultstring")) {
|
||||
eval($result);
|
||||
return $resultstring;
|
||||
} else {
|
||||
return "ERROR: Translation string '$identifier' is missing!";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function get_string_variable_list($string) {
|
||||
// This function is only used from get_string_from_file().
|
||||
if (empty ($string))
|
||||
return;
|
||||
|
||||
// Match on all variables in $string
|
||||
$count = preg_match_all("/\\\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/",
|
||||
$string, $matches);
|
||||
|
||||
// Return array of matches ($matches[0] is most useful)
|
||||
return $matches;
|
||||
}
|
||||
|
||||
|
||||
function get_string_from_file($identifier, $langfile, $destination) {
|
||||
// This function is only used from get_string().
|
||||
include ($langfile);
|
||||
|
||||
if (!isset ($string[$identifier])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$value = "sprintf(\"".$string[$identifier]."\");";
|
||||
$variables = get_string_variable_list($value);
|
||||
if (empty($variables[0]))
|
||||
return "$destination = $value";
|
||||
else {
|
||||
foreach ($variables[0] as $variable) {
|
||||
$variablecheck .= "if (!isset ($variable))\n" .
|
||||
"die (\"Variable specified in translation " .
|
||||
"not set.\");\n";
|
||||
}
|
||||
return "$variablecheck $destination = $value";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// ENCRYPTION ////////////////////////////////////////////////
|
||||
|
@ -4,10 +4,11 @@
|
||||
<FONT SIZE=1>
|
||||
<P>
|
||||
<? if ($USER->id) {
|
||||
echo "You are logged in as $USER->firstname $USER->lastname.";
|
||||
echo "(<A HREF=\"$CFG->wwwroot/login/logout.php\">Logout</A>)";
|
||||
echo get_string("loggedinas", "moodle", "$USER->firstname $USER->lastname");
|
||||
echo " (<A HREF=\"$CFG->wwwroot/login/logout.php\">".get_string("logout")."</A>)";
|
||||
} else {
|
||||
echo "You are not logged in. <A HREF=\"$CFG->wwwroot/login/\">Log in here</A>.";
|
||||
echo get_string("loggedinnot", "moodle");
|
||||
echo " (<A HREF=\"$CFG->wwwroot/login/\">".get_string("login")."</A>)";
|
||||
}
|
||||
?>
|
||||
</P>
|
||||
|
@ -4,10 +4,11 @@
|
||||
<FONT SIZE=1>
|
||||
<P>
|
||||
<? if ($USER->id) {
|
||||
echo "You are logged in as $USER->firstname $USER->lastname.";
|
||||
echo "(<A HREF=\"$CFG->wwwroot/login/logout.php\">Logout</A>)";
|
||||
echo get_string("loggedinas", "moodle", "$USER->firstname $USER->lastname");
|
||||
echo " (<A HREF=\"$CFG->wwwroot/login/logout.php\">".get_string("logout")."</A>)";
|
||||
} else {
|
||||
echo "You are not logged in. <A HREF=\"$CFG->wwwroot/login/\">Log in here</A>.";
|
||||
echo get_string("loggedinnot", "moodle");
|
||||
echo " (<A HREF=\"$CFG->wwwroot/login/\">".get_string("login")."</A>)";
|
||||
}
|
||||
?>
|
||||
</P>
|
||||
|
Loading…
x
Reference in New Issue
Block a user