$temp->add(new admin_setting_configcheckbox('xmlstrictheaders', get_string('xmlstrictheaders', 'admin'), get_string('configxmlstrictheaders', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('debugsmtp', get_string('debugsmtp', 'admin'), get_string('configdebugsmtp', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('perfdebug', get_string('perfdebug', 'admin'), get_string('configperfdebug', 'admin'), '7', '15', '7'));
+$temp->add(new admin_setting_configcheckbox('debugstringids', get_string('debugstringids', 'admin'), get_string('configdebugstringids', 'admin'), 0));
$ADMIN->add('server', $temp);
$string['configstatsruntimedays'] = 'Specify the maximum number of days processed in each stats execution. When stats are up-to-date, only one day will be processed, so adjust this value depending of your server load, reducing it if shorter cron executions are needed.';
$string['configstatsruntimestart'] = 'What time should the cronjob that does the stats processing <b>start</b>? Please specify different times if there are multiple Moodles on one physical server.';
$string['configstatsuserthreshold'] = 'If you enter a non-zero, non numeric value here, for ranking courses, courses with less than this number of enrolled users (all roles) will be ignored';
+$string['configdebugstringids'] = 'This option is designed to help translators. It it shows the language file and string id beside each string that is output. (Note that after you change this setting, the new setting will not take effect on the screen that says \'Changes saved\', but it will after that.)';
$string['configstripalltitletags'] = 'Uncheck this setting to allow HTML tags in activity and resource names.';
$string['configsupportemail'] = 'This email address will be published to users of this site as the one to email when they need general help (for example, when new users create their own accounts). If this email is left blank then no such helpful email address is supplied.';
$string['configsupportname'] = 'This is the name of a person or other entity offering general help via the support email or web address.';
$string['stickyblocksduplicatenotice'] = 'If any block you add here is already present in a particular page, it will result in a duplicate.<br />Only the pinned block will be non-editable, the duplicate will still be editable.';
$string['stickyblocksmymoodle'] = 'My Moodle';
$string['stickyblockspagetype'] = 'Page type to configure';
+$string['debugstringids'] = 'Show origin of languages strings';
$string['stripalltitletags'] = 'Remove HTML tags from all activity names';
$string['supportemail'] = 'Support email';
$string['supportname'] = 'Support name';
private $installstrings = NULL;
private $parentlangfile = 'langconfig.php';
private $logtofile = false;
+ private $showstringsource = false;
private static $singletoninstance = NULL;
/**
public static function instance() {
if (is_null(self::$singletoninstance)) {
global $CFG;
- self::$singletoninstance = new self($CFG->dirroot, $CFG->dataroot, isset($CFG->running_installer));
+ self::$singletoninstance = new self($CFG->dirroot, $CFG->dataroot,
+ isset($CFG->running_installer), !empty($CFG->debugstringids));
// Uncomment the followign line to log every call to get_string
// to a file in $CFG->dataroot/temp/getstringlog/...
// self::$singletoninstance->start_logging();
/**
* string_manager construct method to instatiate this instance
*
- * @param string $dirroot root directory path
- * @param string $dataroot Path to the data root
- * @param string $admin path to the admin directory
- * @param bool $runninginstaller
+ * @param string $dirroot root directory path.
+ * @param string $dataroot Path to the data root.
+ * @param string $admin path to the admin directory.
+ * @param boolean $runninginstaller Set to true if we are in the installer.
+ * @param boolean $showstringsource add debug info to each string before it is
+ * returned, to say where it came from.
*/
- protected function __construct($dirroot, $dataroot, $runninginstaller) {
+ protected function __construct($dirroot, $dataroot, $runninginstaller, $showstringsource = false) {
$this->dirroot = $dirroot;
$this->corelocations = array(
$dirroot . '/lang/' => '',
$this->installstrings = array_map('trim', $stringnames);
$this->parentlangfile = 'installer.php';
}
+ $this->showstringsource = $showstringsource;
}
/**
$file = $location . $lang . $suffix . '/' . $module . '.php';
$result = $this->get_string_from_file($identifier, $file, $a);
if ($result !== false) {
+ if ($this->showstringsource) {
+ $result = $this->add_source_info($result, $module, $identifier, $file);
+ }
return $result;
}
}
return '[[' . $identifier . ']]'; // Last resort.
}
+
+ /**
+ * Add debug information about where this string came from.
+ */
+ protected function add_source_info($string, $module, $identifier, $file) {
+ // This should not start with '[' or we will confuse code that checks for
+ // missing language strings.
+ // It is a good idea to bracked the entire string. Sometimes on string
+ // is put inside another (For example, Default: No on the admin strings.
+ // The bracketing makes that clear.
+ return '{' . $string . ' ' . $module . '/' . $identifier . '}';
+ }
}
/**