being able to select a language from all pages in a site

being able to select a language from all pages in a site

by chris knowles -
Number of replies: 5
hi,
I am involved in a project where we need to have participants be able to select which language they want to see something in at all levels in the course?
This is because we want to test how well the language pack we have been developing is appropriate to all parts of the interaction and some of our participants have more expertise in the language than others, so may need to change languages to verify their interpretations etc.

At the moment, it appears that the box for toggling between languages is only available at the top level of a course, once they get into a subsection the ability to toggle between languages seems to disappear from the upper part of the screen. This may be something to do with how we set it up - but I would like to try and change it if I can.

I can see how to force a language throughout a site/coruse and also how users can set a preference for their default, but it is the ability to be able to change to another language on any page in a course that I cannot find in the interface settings.

can anyone point me in the right direction as to how to make the language selection box appear by default on all screens/pages in a site?
We are running 1.5.3 version.
Average of ratings: -
In reply to chris knowles

Re: being able to select a language from all pages in a site

by Name FName -
Hi! I have the same problem.
HAve U solved it?
Thanx!
In reply to chris knowles

Re: being able to select a language from all pages in a site

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

In the instructions below explain how to add the language menu to all pages, assuming your site uses the "standard" theme

  1. open "theme/standard/header.html" with a text editor
  2. locate the following line
    <?php if ($navigation) { // This is the navigation table with breadcrumbs ?>
  3. replace the above line with the following lines
    <?php if ($navigation) { // This is the navigation bar with breadcrumbs 
        $uri = $_SERVER['REQUEST_URI'];
        if (strpos($uri, '/login/')===false) {
            $uri = preg_replace('/&?lang=\w+/', '', $uri);
            if (strpos($uri, '?')===false) {
                $uri .= '?lang='; // new query string
            } else {
                $uri .= '&lang='; // append to existing query string
            }
            $button .= popup_form(
                $uri, get_list_of_languages(),
                'chooselang', current_language(),
                '', '', '', true
            );
        } ?>

  4. save the modfied file

enjoy!
Gordon

In reply to Gordon Bateson

Re: being able to select a language from all pages in a site

by Name FName -
Thank U very much fo your help, Gordon.
But seems I typed something wrong,could u check it again, please:
Here the original text in "formal_white"-theme:

<?php //Accessibility: breadcrumb trail/navbar now a DIV, not a table.
      if ($navigation) { // This is the navigation bar with breadcrumbs  ?>
    <div class="navbar clearfix">
        <div class="breadcrumb"><?php print_navigation("$navigation"); ?></div>
        <div class="navbutton"><?php echo $button; ?></div>
    </div>
<?php } else if ($heading) { // If no navigation, but a heading, then print a line 
?>



And I change it as U saying:

<?php //Accessibility: breadcrumb trail/navbar now a DIV, not a table.
<?php if ($navigation) { // This is the navigation bar with breadcrumbs
    $uri = $_SERVER['REQUEST_URI'];
    if (strpos($uri, '/login/')===false) {
        $uri = preg_replace('/&?lang=\w+/', '', $uri);
        if (strpos($uri, '?')===false) {
            $uri .= '?lang='; // new query string
        } else {
            $uri ..= '&lang='; // append to existing query string
        }
        $button .= popup_form(
            $uri, get_list_of_languages(),
            'chooselang', current_language(),
            '', '', '', true
        );
    } ?>    <div class="navbar clearfix">
        <div class="breadcrumb"><?php print_navigation("$navigation"); ?></div>
        <div class="navbutton"><?php echo $button; ?></div>
    </div>
<?php } else if ($heading) { // If no navigation, but a heading, then print a line 
?>

After that HTML-page do not shows.
I tried another variant (see below):

<?php if ($navigation) { // This is the navigation bar with breadcrumbs
    $uri = $_SERVER['REQUEST_URI'];
    if (strpos($uri, '/login/')===false) {
        $uri = preg_replace('/&?lang=\w+/', '', $uri);
        if (strpos($uri, '?')===false) {
            $uri .= '?lang='; // new query string
        } else {
            $uri ..= '&lang='; // append to existing query string
        }
        $button .= popup_form(
            $uri, get_list_of_languages(),
            'chooselang', current_language(),
            '', '', '', true
        );
    } ?>    <div class="navbar clearfix">
        <div class="breadcrumb"><?php print_navigation("$navigation"); ?></div>
        <div class="navbutton"><?php echo $button; ?></div>
    </div>
<?php } else if ($heading) { // If no navigation, but a heading, then print a line 
?>

Colu U check it, please if it possible
Great thanx!
In reply to Name FName

Re: being able to select a language from all pages in a site

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
In your first example the following code will cause an error:
<?php //Accessibility: breadcrumb trail/navbar now a DIV, not a table.
<?php if ($navigation) { // This is the navigation bar with breadcrumbs


You need to add "?>" to the end of the first line, like this:
<?php //Accessibility: breadcrumb trail/navbar now a DIV, not a table. ?>
<?php if ($navigation) { // This is the navigation bar with breadcrumbs


Or remove the "<?php" in the second line, like this:
<?php //Accessibility: breadcrumb trail/navbar now a DIV, not a table.
    if ($navigation) { // This is the navigation bar with breadcrumbs

if you get blank pages this means that PHP had an error but error reporting is switched off. In this case, you should try to switch error reporting on using one of the following methods:
  • switch "Debug" to "Yes" on the Moodle Variables page
  • change the error reporting settings in php.ini and restart Apache
Alternatively, you may find the error the Apache error log.
In reply to Gordon Bateson

Re: being able to select a language from all pages in a site

by Name FName -
Thanx! Now it works. Dropdown field is now not near Login-information. Is it possible to move it on a place under logout?