From: nfreear Date: Wed, 21 Feb 2007 10:42:50 +0000 (+0000) Subject: Followup fix for Bug MDL-8507 "Local language pack-name can appear in language code" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2ab4e4b87b0462c8e3e8e332cf2397d9f398e568;p=moodle.git Followup fix for Bug MDL-8507 "Local language pack-name can appear in language code" --- diff --git a/backup/restorelib.php b/backup/restorelib.php index 90c913d647..57a4aeffbe 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -6361,9 +6361,8 @@ $stylesheetshtml .= ''."\n"; } ///Accessibility: added the 'lang' attribute to $direction, used in theme tag. - $language = str_replace('_utf8','',$CFG->lang); - $languagehtml = ''; - $languagehtml .= ' lang="'.$language.'" xml:lang="'.$language.'"'; + $languagehtml = get_html_lang($dir=true); + //Write the header in the new logging file fwrite ($restorelog_file," "); @@ -6743,4 +6742,4 @@ fclose($restorelog); } } -?> +?> \ No newline at end of file diff --git a/lib/weblib.php b/lib/weblib.php index f35afdace6..a09d3f91e6 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1948,6 +1948,26 @@ function highlightfast($needle, $haystack) { return (join('', $parts)); } +/** + * Return a string containing 'lang', xml:lang and optionally 'dir' HTML attributes. + * Internationalisation, for print_header and backup/restorelib. + * @param $dir Default false. + * @return string Attributes. + */ +function get_html_lang($dir = false) { + $direction = ''; + if ($dir) { + if (get_string('thisdirection') == 'rtl') { + $direction = ' dir="rtl"'; + } else { + $direction = ' dir="ltr"'; + } + } + //Accessibility: added the 'lang' attribute to $direction, used in theme tag. + $language = str_replace('_', '-', str_replace('_utf8', '', current_language())); + return ($direction.' lang="'.$language.'" xml:lang="'.$language.'"'); +} + /// STANDARD WEB PAGE PARTS /////////////////////////////////////////////////// @@ -2082,14 +2102,8 @@ function print_header ($title='', $heading='', $navigation='', $focus='', @header('Content-type: text/html; charset=utf-8'); } - if ( get_string('thisdirection') == 'rtl' ) { - $direction = ' dir="rtl"'; - } else { - $direction = ' dir="ltr"'; - } //Accessibility: added the 'lang' attribute to $direction, used in theme tag. - $language = str_replace('_', '-', str_replace('_utf8', '', current_language())); - $direction .= ' lang="'.$language.'" xml:lang="'.$language.'"'; + $direction = get_html_lang($dir=true); if ($cache) { // Allow caching on "back" (but not on normal clicks) @header('Cache-Control: private, pre-check=0, post-check=0, max-age=0'); @@ -5674,4 +5688,4 @@ function frametarget() { } // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140: -?> +?> \ No newline at end of file