Commit 7f9b6945 authored by Robert Lyon's avatar Robert Lyon

Bug 1708567: Avoid error when checking string_exists

We need to avoid the sprintf() error if lang string expects extra args.

We can do this by supplying function check_string rather than
format_string

behatnotneeded

Change-Id: Ibfc2d9a552f2d87b2f5f762bab2ff2ec76a73dca
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent f502ca15
......@@ -286,14 +286,22 @@ function ensure_internal_plugins_exist() {
/**
* Check to see whether a language string is present in the
* lang files.
* lang files. when checking the lang string we don't care about extra arguments so we use
* the _return_string_unchanged rather than format_langstring function.
*
* @param string $identifier
* @param string $section
* @return boolean
*/
function string_exists($identifier, $section = 'mahara') {
return get_string($identifier, $section) !== '[[' . $identifier . '/' . $section . ']]';
// Because we don't need to perform parameter replacement to test if string exists
// we can use a simple pass-through for the $replacefunc argument.
$string = get_string_location($identifier, $section, array(), '_return_string_unchanged');
return $string !== '[[' . $identifier . '/' . $section . ']]';
}
function _return_string_unchanged($string, $args, $lang='en.utf8') {
return $string;
}
function get_string($identifier, $section='mahara') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment