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

Support multi-language content in custom menu

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.4
    • Component/s: Accessibility
    • Labels:
      None
    • Testing Instructions:
      Hide
      • Install another language pack to the site (for example Czech - Čeština "cs")
      • Enable multi/language filter (content filtering is enough)
      • Go to Site administration > Appearance > Themes > Theme settings and define the custom menu using a multi-lang syntax (see my comments below for some example using the English/Czech variants of the menu)
      • TEST: make sure that when switching the language, you get relevant custom menu displayed
      Show
      Install another language pack to the site (for example Czech - Čeština "cs") Enable multi/language filter (content filtering is enough) Go to Site administration > Appearance > Themes > Theme settings and define the custom menu using a multi-lang syntax (see my comments below for some example using the English/Czech variants of the menu) TEST: make sure that when switching the language, you get relevant custom menu displayed
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-27073_multilang-custommenu

      Description

      When we are using the new "custommenuitems", we should have the possibility to create the menu for different languages, since we are able to localize everything else.

      1) We could use a notation like this:

      [en-US:Moodle community;pt-PT:Comunidade Moodle]|http://moodle.org
      -[en-US:Moodle free support;pt-PT:Suporte gratuito do Moodle]|http://moodle.org/support
      -[en-US:Moodle development;pt-PT:Desenvolvimento do Moodle]|http://moodle.org/development

      by adding in /lib/outputcomponents.php (around line 2386) something like:
      if (!array_key_exists(0, $bits) || empty($bits[0]))

      { // Every item must have a name to be valid continue; }

      else {
      $bits[0] = ltrim($bits[0],'-');

      + $languages = explode(';', $bits[0]); // pt:nome;en:name|url|title|sort
      + if (array_key_exists(0, $languages)) {
      + foreach ($languages as $language)

      { + $menulang = explode(':', $language); + if ($menulang[0] == current_language() ) + $bits[0] = $menulang[1]; + }

      + }

      2) or using the multilang plugin by adding in /lib/outputcomponents.php (around line 2372) something like:
      public static function convert_text_to_menu_nodes($text) {
      + $text = format_text($text, $format=FORMAT_MARKDOWN, $options=NULL, $courseid=NULL);

      With this line we could use the following syntax to the custommenu text:
      <span lang="en" class="multilang">
      Home|http://moodleurl
      -blah|blahlink
      </span>
      <span lang="pt" class="multilang">
      Início|http://moodleurl
      -blah|blahlink
      </span>

        Attachments

        1. custommenu_without_titles_code.jpg
          171 kB
          Anna Bánsághi
        2. custommenu_without_titles.jpg
          8 kB
          Anna Bánsághi
        3. menu-italian.jpg
          46 kB
          Mary Evans
        4. menu-span.jpg
          210 kB
          Mary Evans

          Issue Links

            Activity

              People

              Assignee:
              mudrd8mz David Mudrák (@mudrd8mz)
              Reporter:
              rodolfo.matos Rodolfo Matos
              Integrator:
              Eloy Lafuente (stronk7)
              Tester:
              Marina Glancy
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
              Votes:
              6 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                1/Aug/11