Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-33887

Calling $PAGE->requires->xx before require_login() + force language gives javascript language string error

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.3.2
    • 2.2, 2.3
    • Other
    • MOODLE_22_STABLE, MOODLE_23_STABLE
    • MOODLE_23_STABLE
    • w28_MDL-33887_m24_jsstrings
    • Hide

      For developers:
      see description or create a test page with (you need Czech lang pack installed)

      <?php
      require('config.php');
      $PAGE->set_url('/xx.php');
      $PAGE->set_context(null);
      echo $OUTPUT->header();
      $SESSION->lang = 'en';
      $PAGE->requires->string_for_js('course', 'moodle', 1);
      $SESSION->lang = 'cs';
      $PAGE->requires->string_for_js('course', 'moodle', 1);
      echo $OUTPUT->footer();

      Show
      For developers: see description or create a test page with (you need Czech lang pack installed) <?php require('config.php'); $PAGE->set_url('/xx.php'); $PAGE->set_context(null); echo $OUTPUT->header(); $SESSION->lang = 'en'; $PAGE->requires->string_for_js('course', 'moodle', 1); $SESSION->lang = 'cs'; $PAGE->requires->string_for_js('course', 'moodle', 1); echo $OUTPUT->footer();

      If you have a Moodle course with the language forced (e.g. to Deutsch (De)) and the user's own language is set to another language (e.g. to English (En)), then a page with a filepicker element (e.g. the 'Add blog' page of the OU Blog) causes an error.

      This is because the language strings for the filepicker form element javascript (including the 'cancel' string) are loaded before the forced course language is applied, whereas 'init_requirements_data' (also including the 'cancel' string) is called after the force course language is applied. This means that the first one loads, in my case, the English 'Cancel' and the second attempts to load the German 'Abbrechen', causing an exception, as they don't match.

            skodak Petr Skoda
            davosmith Davo Smith
            Sam Hemelryk Sam Hemelryk
            Michael de Raadt Michael de Raadt
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.