MDL-10797 Merged lang strings into lang/en_utf8/admin.php and error.php

This commit is contained in:
nicolasconnault 2007-08-13 08:58:37 +00:00
parent f6eb15ade1
commit 98240e51a6
5 changed files with 57 additions and 63 deletions

View file

@ -6,7 +6,7 @@
require_once('../config.php'); require_once('../config.php');
require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/adminlib.php');
admin_externalpage_setup('langedit'); admin_externalpage_setup('langedit');
$context = get_context_instance(CONTEXT_SYSTEM, SITEID); $context = get_context_instance(CONTEXT_SYSTEM, SITEID);
@ -32,20 +32,20 @@
} else { } else {
$SESSION->langtranslateintolocal = $uselocal; $SESSION->langtranslateintolocal = $uselocal;
} }
if (!has_capability('moodle/site:langeditmaster', $context, $USER->id, false)) { if (!has_capability('moodle/site:langeditmaster', $context, $USER->id, false)) {
// Force using _local // Force using _local
$uselocal = 1; $uselocal = 1;
} }
if (!has_capability('moodle/site:langeditmaster', $context, $USER->id, false) && (!$uselocal)) { if (!has_capability('moodle/site:langeditmaster', $context, $USER->id, false) && (!$uselocal)) {
print_error('cannoteditmasterlang'); print_error('cannoteditmasterlang');
} }
if ((!has_capability('moodle/site:langeditlocal', $context, $USER->id, false)) && ($uselocal)) { if ((!has_capability('moodle/site:langeditlocal', $context, $USER->id, false)) && ($uselocal)) {
print_error('cannotcustomizelocallang'); print_error('cannotcustomizelocallang');
} }
$strlanguage = get_string("language"); $strlanguage = get_string("language");
$strcurrentlanguage = get_string("currentlanguage"); $strcurrentlanguage = get_string("currentlanguage");
$strmissingstrings = get_string("missingstrings"); $strmissingstrings = get_string("missingstrings");
@ -61,20 +61,9 @@
$strfilecreated = get_string('filecreated', 'admin'); $strfilecreated = get_string('filecreated', 'admin');
$strprev = get_string('previous'); $strprev = get_string('previous');
$strnext = get_string('next'); $strnext = get_string('next');
$strlocalstringcustomization = 'Local string customization'; // TODO / FIXME $strlocalstringcustomization = get_string('localstringcustomization', 'admin');
$strlangpackmaintaining = 'Language pack maintaining'; // TODO / FIXME $strlangpackmaintaining = get_string('langpackmaintaining', 'admin');
$strnomissingstrings = 'No missing strings'; // TODO / FIXME $strnomissingstrings = get_string('nomissingstrings', 'admin');
// TODO / FIXME add into en_utf8/error.php
$string['cannoteditmasterlang'] = 'You do not have permission to edit master language package. This
permission is controlled by the capability "moodle/site:langeditmaster". Set this capability
to allow you to edit master language packages in case you are the maintainer of a package.';
$string['cannotcustomizelocallang'] = 'You do not have permission to customize the strings translation.
This permission is controlled by the capability "moodle/site:langeditlocal". Set this capability
to allow you to edit local language packages in case you want to modify translations for your site.';
// TODO/FIXME add into en_utf8/admin.php:
// $string['numberofmissingstrings'] = 'Number of missing strings: $a';
$currentlang = current_language(); $currentlang = current_language();
@ -112,13 +101,13 @@
$activated = array('usemaster'); $activated = array('usemaster');
} }
if (has_capability('moodle/site:langeditlocal', $context, $USER->id, false)) { if (has_capability('moodle/site:langeditlocal', $context, $USER->id, false)) {
$firstrow[] = new tabobject('uselocal', $firstrow[] = new tabobject('uselocal',
$CFG->wwwroot."/admin/lang.php?mode=$mode&currentfile=$currentfile&uselocal=1", $CFG->wwwroot."/admin/lang.php?mode=$mode&currentfile=$currentfile&uselocal=1",
$strlocalstringcustomization ); $strlocalstringcustomization );
} }
if (has_capability('moodle/site:langeditmaster', $context, $USER->id, false)) { if (has_capability('moodle/site:langeditmaster', $context, $USER->id, false)) {
$firstrow[] = new tabobject('usemaster', $firstrow[] = new tabobject('usemaster',
$CFG->wwwroot."/admin/lang.php?mode=$mode&currentfile=$currentfile&uselocal=0", $CFG->wwwroot."/admin/lang.php?mode=$mode&currentfile=$currentfile&uselocal=0",
$strlangpackmaintaining ); $strlangpackmaintaining );
} }
$secondrow[] = new tabobject('missing', $CFG->wwwroot.'/admin/lang.php?mode=missing', $strmissingstrings ); $secondrow[] = new tabobject('missing', $CFG->wwwroot.'/admin/lang.php?mode=missing', $strmissingstrings );
@ -128,7 +117,7 @@
$secondrow[] = new tabobject('langdoc', $CFG->wwwroot.'/admin/langdoc.php', $stredithelpdocs ); $secondrow[] = new tabobject('langdoc', $CFG->wwwroot.'/admin/langdoc.php', $stredithelpdocs );
$tabs = array($firstrow, $secondrow); $tabs = array($firstrow, $secondrow);
print_tabs($tabs, $currenttab, $inactive, $activated); print_tabs($tabs, $currenttab, $inactive, $activated);
if (!$mode) { if (!$mode) {
print_box_start(); print_box_start();
@ -177,10 +166,10 @@
foreach ($stringfiles as $file) { foreach ($stringfiles as $file) {
unset($string); unset($string);
include("$enlangdir/$file"); include("$enlangdir/$file");
$enstring = $string; $enstring = $string;
ksort($enstring); ksort($enstring);
unset($string); unset($string);
if (file_exists("$langdir/$file")) { if (file_exists("$langdir/$file")) {
@ -194,7 +183,7 @@
} }
$missingcounter = 0; $missingcounter = 0;
$first = true; $first = true;
foreach ($enstring as $key => $value) { foreach ($enstring as $key => $value) {
if (empty($string[$key]) and $string[$key] != "0") { //bug fix 4735 mits if (empty($string[$key]) and $string[$key] != "0") { //bug fix 4735 mits
@ -227,7 +216,7 @@
$o .= '</pre><hr />'; $o .= '</pre><hr />';
} }
} }
if ($m <> '') { if ($m <> '') {
print_box($m, 'filenames'); print_box($m, 'filenames');
} }
@ -236,7 +225,7 @@
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) { if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/help", "CVS")) {
error("Could not find English language help files!"); error("Could not find English language help files!");
} }
foreach ($files as $filekey => $file) { // check all the help files. foreach ($files as $filekey => $file) { // check all the help files.
if (!file_exists("$langdir/help/$file")) { if (!file_exists("$langdir/help/$file")) {
echo "<p><font color=\"red\">".get_string("filemissing", "", "$langdir/help/$file")."</font></p>"; echo "<p><font color=\"red\">".get_string("filemissing", "", "$langdir/help/$file")."</font></p>";
@ -244,7 +233,7 @@
continue; continue;
} }
} }
if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) { if (! $files = get_directory_list("$CFG->dirroot/lang/en_utf8/docs", "CVS")) {
error("Could not find English language docs files!"); error("Could not find English language docs files!");
} }
@ -255,7 +244,7 @@
continue; continue;
} }
} }
if (!empty($somethingfound)) { if (!empty($somethingfound)) {
print_continue("lang.php"); print_continue("lang.php");
} else { } else {
@ -263,7 +252,7 @@
} }
} else if ($mode == "compare") { } else if ($mode == "compare") {
if (!file_exists($langbase) ){ if (!file_exists($langbase) ){
if (!lang_make_directory($langbase) ){ if (!lang_make_directory($langbase) ){
error('ERROR: Could not create base lang directory ' . $langbase); error('ERROR: Could not create base lang directory ' . $langbase);
@ -271,7 +260,7 @@
echo '<div class="notifysuccess">Created directory '. echo '<div class="notifysuccess">Created directory '.
$langbase .'</div>'."<br />\n"; $langbase .'</div>'."<br />\n";
} }
} }
if (!$uselocal && !file_exists($langdir)) { if (!$uselocal && !file_exists($langdir)) {
if (!lang_make_directory($langdir)) { if (!lang_make_directory($langdir)) {
error('ERROR: Could not create directory '.$langdir); error('ERROR: Could not create directory '.$langdir);
@ -290,19 +279,19 @@
$locallangdir .'</div>'."<br />\n"; $locallangdir .'</div>'."<br />\n";
} }
} }
if (isset($_POST['currentfile'])){ // Save a file if (isset($_POST['currentfile'])){ // Save a file
if (!confirm_sesskey()) { if (!confirm_sesskey()) {
error(get_string('confirmsesskeybad', 'error')); error(get_string('confirmsesskeybad', 'error'));
} }
$newstrings = array(); $newstrings = array();
foreach ($_POST as $postkey => $postval) { foreach ($_POST as $postkey => $postval) {
$stringkey = lang_file_string_key($postkey); $stringkey = lang_file_string_key($postkey);
$newstrings[$stringkey] = $postval; $newstrings[$stringkey] = $postval;
} }
unset($newstrings['currentfile']); unset($newstrings['currentfile']);
if ($uselocal) { if ($uselocal) {
@ -315,17 +304,17 @@
unset($string); unset($string);
$saveinto = $locallangdir; $saveinto = $locallangdir;
} else { } else {
$packstring = array(); $packstring = array();
$saveinto = $langdir; $saveinto = $langdir;
} }
if (lang_save_file($saveinto, $currentfile, $newstrings, $uselocal, $packstring)) { if (lang_save_file($saveinto, $currentfile, $newstrings, $uselocal, $packstring)) {
notify(get_string("changessaved")." ($saveinto/$currentfile)", "green"); notify(get_string("changessaved")." ($saveinto/$currentfile)", "green");
} else { } else {
error("Could not save the file '$saveinto/$currentfile'!", "lang.php?mode=compare&amp;currentfile=$currentfile"); error("Could not save the file '$saveinto/$currentfile'!", "lang.php?mode=compare&amp;currentfile=$currentfile");
} }
unset($packstring); unset($packstring);
} }
print_box_start('generalbox editstrings'); print_box_start('generalbox editstrings');
$menufiles = array(); $menufiles = array();
@ -343,7 +332,7 @@
helpbutton('langswitchstorage', $strfilestoredinhelp, 'moodle'); helpbutton('langswitchstorage', $strfilestoredinhelp, 'moodle');
echo '</div>'; echo '</div>';
print_box_end(); print_box_end();
if ($currentfile <> '') { if ($currentfile <> '') {
$saveto = $uselocal ? $locallangdir : $langdir; $saveto = $uselocal ? $locallangdir : $langdir;
error_reporting(0); error_reporting(0);
@ -365,11 +354,11 @@
echo "<p><font size=\"1\">".get_string("makeeditable", "", "$saveto/$currentfile")."</font></p>"; echo "<p><font size=\"1\">".get_string("makeeditable", "", "$saveto/$currentfile")."</font></p>";
} }
error_reporting($CFG->debug); error_reporting($CFG->debug);
$o = ''; // stores the HTML output to be echo-ed $o = ''; // stores the HTML output to be echo-ed
unset($string); unset($string);
include("$enlangdir/$currentfile"); include("$enlangdir/$currentfile");
$enstring = $string; $enstring = $string;
if ($currentlang != 'en' and $currentfile == 'moodle.php') { if ($currentlang != 'en' and $currentfile == 'moodle.php') {
$enstring['thislanguage'] = "<< TRANSLATORS: Specify the name of your language here. If possible use Unicode Numeric Character References >>"; $enstring['thislanguage'] = "<< TRANSLATORS: Specify the name of your language here. If possible use Unicode Numeric Character References >>";
$enstring['thischarset'] = "<< TRANSLATORS: Charset encoding - always use utf-8 >>"; $enstring['thischarset'] = "<< TRANSLATORS: Charset encoding - always use utf-8 >>";
@ -383,7 +372,7 @@
@include("$locallangdir/$currentfile"); @include("$locallangdir/$currentfile");
$localstring = isset($string) ? $string : array(); $localstring = isset($string) ? $string : array();
unset($string); unset($string);
@include("$langdir/$currentfile"); @include("$langdir/$currentfile");
if ($editable) { if ($editable) {
@ -401,7 +390,7 @@
$o .= '<br />&nbsp;</td></tr>'; $o .= '<br />&nbsp;</td></tr>';
} }
$envalue = nl2br(htmlspecialchars($envalue)); $envalue = nl2br(htmlspecialchars($envalue));
$envalue = preg_replace('/(\$a\-\&gt;[a-zA-Z0-9]*|\$a)/', '<b>$0</b>', $envalue); // Make variables bold. $envalue = preg_replace('/(\$a\-\&gt;[a-zA-Z0-9]*|\$a)/', '<b>$0</b>', $envalue); // Make variables bold.
$envalue = str_replace("%%","%",$envalue); $envalue = str_replace("%%","%",$envalue);
$envalue = str_replace("\\","",$envalue); // Delete all slashes $envalue = str_replace("\\","",$envalue); // Delete all slashes
@ -502,7 +491,7 @@
} }
$o .= '</table>'; $o .= '</table>';
if ($editable) { if ($editable) {
$o .= '</div>'; $o .= '</div>';
$o .= '</form>'; $o .= '</form>';
} }
@ -531,7 +520,7 @@
/** /**
* Save language translation file. * Save language translation file.
* *
* Thanks to Petri Asikainen for the original version of code * Thanks to Petri Asikainen for the original version of code
* used to save language files. * used to save language files.
* *
* @uses $CFG * @uses $CFG
@ -542,7 +531,7 @@
* @param bool $local Should *_local version be saved? * @param bool $local Should *_local version be saved?
* @param array $packstrings Array of default langpack strings (needed if $local) * @param array $packstrings Array of default langpack strings (needed if $local)
* @return bool Created successfully? * @return bool Created successfully?
*/ */
function lang_save_file($path, $file, $strings, $local, $packstrings) { function lang_save_file($path, $file, $strings, $local, $packstrings) {
global $CFG, $USER; global $CFG, $USER;
if (LANG_KEEP_ORPHANS) { if (LANG_KEEP_ORPHANS) {
@ -598,7 +587,7 @@ function lang_save_file($path, $file, $strings, $local, $packstrings) {
* *
* These modifications are typically necessary to work with the same string coming from two sources. * These modifications are typically necessary to work with the same string coming from two sources.
* We need to compare the content of these sources and we want to have e.g. "This string\r\n" * We need to compare the content of these sources and we want to have e.g. "This string\r\n"
* to be the same as " This string\n". * to be the same as " This string\n".
* *
* @param string $value Original string from the file * @param string $value Original string from the file
* @return string Fixed value * @return string Fixed value
@ -698,7 +687,7 @@ function lang_file_string_key($keyfromform) {
* @todo Seems the function does not work with negative $start together with $length being set * @todo Seems the function does not work with negative $start together with $length being set
*/ */
function lang_xhtml_save_substr($str, $start, $length = NULL) { function lang_xhtml_save_substr($str, $start, $length = NULL) {
if ($length === 0) { if ($length === 0) {
//stop wasting our time ;) //stop wasting our time ;)
return ""; return "";
} }
@ -728,7 +717,7 @@ function lang_xhtml_save_substr($str, $start, $length = NULL) {
//calculate start position //calculate start position
if ($start >= 0) { if ($start >= 0) {
$real_start = $chars[$start][1]; $real_start = $chars[$start][1];
} else { } else {
//start'th character from the end of string //start'th character from the end of string
$start = max($start,-$html_length); $start = max($start,-$html_length);
$real_start = $chars[$html_length+$start][1]; $real_start = $chars[$html_length+$start][1];
@ -737,16 +726,16 @@ function lang_xhtml_save_substr($str, $start, $length = NULL) {
if (!isset($length)) { if (!isset($length)) {
// no $length argument passed, return all remaining characters // no $length argument passed, return all remaining characters
return substr($str, $real_start); return substr($str, $real_start);
} elseif ($length > 0) { } elseif ($length > 0) {
// copy $length chars // copy $length chars
if ($start+$length >= $html_length) { if ($start+$length >= $html_length) {
// return all remaining characters // return all remaining characters
return substr($str, $real_start); return substr($str, $real_start);
} else { } else {
//return $length characters //return $length characters
return substr($str, $real_start, $chars[max($start,0)+$length][1] - $real_start); return substr($str, $real_start, $chars[max($start,0)+$length][1] - $real_start);
} }
} else { } else {
//negative $length. Omit $length characters from end //negative $length. Omit $length characters from end
return substr($str, $real_start, $chars[$html_length+$length][1] - $real_start); return substr($str, $real_start, $chars[$html_length+$length][1] - $real_start);
} }
@ -755,10 +744,10 @@ function lang_xhtml_save_substr($str, $start, $length = NULL) {
/** /**
* Finds all English string files in the standard lang/en_utf8 location. * Finds all English string files in the standard lang/en_utf8 location.
* *
* The English version of the file may be found in * The English version of the file may be found in
* $CFG->dirroot/lang/en_utf8/filename * $CFG->dirroot/lang/en_utf8/filename
* The localised version of the found file should be saved into * The localised version of the found file should be saved into
* $CFG->dataroot/lang/current_lang[_local]/filename * $CFG->dataroot/lang/current_lang[_local]/filename
* where "filename" is returned as a part of the file record. * where "filename" is returned as a part of the file record.
* *
* @return array Array of a file information. Compatible format with {@link lang_extra_locations()} * @return array Array of a file information. Compatible format with {@link lang_extra_locations()}
@ -787,13 +776,13 @@ function lang_standard_locations() {
/** /**
* Finds all English string files in non-standard location. * Finds all English string files in non-standard location.
* *
* Searches for lang/en_utf8/*.php in various types of plugins (blocks, database presets, question types, * Searches for lang/en_utf8/*.php in various types of plugins (blocks, database presets, question types,
* 3rd party modules etc.) and returns an array of found files details. * 3rd party modules etc.) and returns an array of found files details.
* *
* The English version of the file may be found in * The English version of the file may be found in
* $CFG->dirroot/location/plugin/lang/en_utf8/filename * $CFG->dirroot/location/plugin/lang/en_utf8/filename
* The localised version of the found file should be saved into * The localised version of the found file should be saved into
* $CFG->dataroot/lang/current_lang[_local]/prefix_plugin.php * $CFG->dataroot/lang/current_lang[_local]/prefix_plugin.php
* where "location", "plugin", "prefix" and "filename" are returned as a part of the file record. * where "location", "plugin", "prefix" and "filename" are returned as a part of the file record.
* *
* @return array Array of a file information. Compatible format with {@link lang_standard_locations()} * @return array Array of a file information. Compatible format with {@link lang_standard_locations()}

View file

@ -364,6 +364,7 @@ $string['langimportsuccess'] = 'Language pack successfully upgraded';
$string['langlist'] = 'Languages on language menu'; $string['langlist'] = 'Languages on language menu';
$string['langmenu'] = 'Display language menu'; $string['langmenu'] = 'Display language menu';
$string['langnoeditenglish'] = 'Can\'t overwrite the base english language pack. Please switch lang directory to make local changes'; $string['langnoeditenglish'] = 'Can\'t overwrite the base english language pack. Please switch lang directory to make local changes';
$string['langpackmaintaining'] = 'Language pack maintaining';
$string['langpackremoved'] = 'Language pack was uninstalled'; $string['langpackremoved'] = 'Language pack was uninstalled';
$string['langpacks'] = 'Language packs'; $string['langpacks'] = 'Language packs';
$string['langpackupdated'] = 'Language pack $a was successfully installed'; $string['langpackupdated'] = 'Language pack $a was successfully installed';
@ -373,6 +374,7 @@ $string['latexpreamble'] = 'LaTeX preamble';
$string['latexsettings'] = 'LaTeX renderer Settings'; $string['latexsettings'] = 'LaTeX renderer Settings';
$string['latinexcelexport'] = 'Excel encoding'; $string['latinexcelexport'] = 'Excel encoding';
$string['localetext'] = 'Sitewide locale'; $string['localetext'] = 'Sitewide locale';
$string['localstringcustomization'] = 'Local string customization';
$string['location'] = 'Location'; $string['location'] = 'Location';
$string['locationsettings'] = 'Location settings'; $string['locationsettings'] = 'Location settings';
$string['log'] = 'Logs'; $string['log'] = 'Logs';
@ -422,6 +424,7 @@ $string['mysql416required'] = 'MySQL 4.1.16 is the minimum version required for
$string['nobookmarksforuser'] = 'You do not have any bookmarks.'; $string['nobookmarksforuser'] = 'You do not have any bookmarks.';
$string['nodefaultuserrolelists'] = 'Don\'t return all default role users'; $string['nodefaultuserrolelists'] = 'Don\'t return all default role users';
$string['nolangupdateneeded'] = 'All your language packs are up to date, no update is needed'; $string['nolangupdateneeded'] = 'All your language packs are up to date, no update is needed';
$string['nomissingstrings'] = 'No missing strings';
$string['nonewsettings'] = 'No new settings were added during this upgrade.'; $string['nonewsettings'] = 'No new settings were added during this upgrade.';
$string['nonexistentbookmark'] = 'The bookmark you requested does not exist.'; $string['nonexistentbookmark'] = 'The bookmark you requested does not exist.';
$string['nonmetacoursesyncroleids'] = 'Roles that are not synchronised to metacourses'; $string['nonmetacoursesyncroleids'] = 'Roles that are not synchronised to metacourses';
@ -431,6 +434,7 @@ $string['notifications'] = 'Notifications';
$string['notifyloginfailures'] = 'Email login failures to'; $string['notifyloginfailures'] = 'Email login failures to';
$string['notifyloginthreshold'] = 'Threshold for email notifications'; $string['notifyloginthreshold'] = 'Threshold for email notifications';
$string['notloggedinroleid'] = 'Role for visitors'; $string['notloggedinroleid'] = 'Role for visitors';
$string['numberofmissingstrings'] = 'Number of missing strings: $a';
$string['opensslrecommended'] = 'Installing the optional OpenSSL library is highly recommended -- it enables Moodle Networking functionality.'; $string['opensslrecommended'] = 'Installing the optional OpenSSL library is highly recommended -- it enables Moodle Networking functionality.';
$string['opentogoogle'] = 'Open to Google'; $string['opentogoogle'] = 'Open to Google';
$string['optionalmaintenancemessage'] = 'Optional maintenance messsage'; $string['optionalmaintenancemessage'] = 'Optional maintenance messsage';

View file

@ -5,8 +5,10 @@
$string['adminprimarynoedit'] = 'The primary admin cannot be edited by others'; $string['adminprimarynoedit'] = 'The primary admin cannot be edited by others';
$string['cannotcreatelangdir'] = 'Cannot create lang dir.'; $string['cannotcreatelangdir'] = 'Cannot create lang dir.';
$string['cannotcreatetempdir'] = 'Cannot create temp dir.'; $string['cannotcreatetempdir'] = 'Cannot create temp dir.';
$string['cannotcustomizelocallang'] = 'You do not have permission to customize the strings translation. This permission is controlled by the capability "moodle/site:langeditlocal". Set this capability to allow you to edit local language packages in case you want to modify translations for your site.';
$string['cannotdownloadcomponents'] = 'Cannot download components.'; $string['cannotdownloadcomponents'] = 'Cannot download components.';
$string['cannotdownloadzipfile'] = 'Cannot download ZIP file.'; $string['cannotdownloadzipfile'] = 'Cannot download ZIP file.';
$string['cannoteditmasterlang'] = 'You do not have permission to edit master language package. This permission is controlled by the capability "moodle/site:langeditmaster". Set this capability to allow you to edit master language packages in case you are the maintainer of a package.';
$string['cannotfindcomponent'] = 'Cannot find component.'; $string['cannotfindcomponent'] = 'Cannot find component.';
$string['cannotsavemd5file'] = 'Cannot save md5 file.'; $string['cannotsavemd5file'] = 'Cannot save md5 file.';
$string['cannotsavezipfile'] = 'Cannot save ZIP file.'; $string['cannotsavezipfile'] = 'Cannot save ZIP file.';

View file

@ -576,5 +576,4 @@ class grade_grade extends grade_object {
} }
} }
?> ?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 B

After

Width:  |  Height:  |  Size: 130 B

Before After
Before After