Moodle
  1. Moodle
  2. MDL-23514

Allow admin to define the language to use in links for documentation pages

    Details

    • Testing Instructions:
      Hide
      • With a clean Moodle install in english language, add at least one more language to it.
      • Create a new user and change it's language from english to the other one you have installed.
      • Make sure this user has "moodle/site:doclinks" allowed.
      • Go to Site Administration -> Appearance -> Moodle Docs and set "Language for docs" to english.
        ( Sign in as the user and go to "My Home". See that the "Moodle Docs for this page" link at the bottom of the page points to english version instead of the one in user's language.
      Show
      With a clean Moodle install in english language, add at least one more language to it. Create a new user and change it's language from english to the other one you have installed. Make sure this user has "moodle/site:doclinks" allowed. Go to Site Administration -> Appearance -> Moodle Docs and set "Language for docs" to english. ( Sign in as the user and go to "My Home". See that the "Moodle Docs for this page" link at the bottom of the page points to english version instead of the one in user's language.
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE
    • Pull 2.5 Branch:
      wip-mdl-23514-m25
    • Pull 2.6 Branch:
      wip-mdl-23514-m26
    • Pull Master Branch:
      MDL-23514-master
    • Rank:
      6168

      Description

      There are two major reasons an admin would like to user force a language to docs:

      1. I am using an non standard language pack (let's say pt_br_my-institution-version), and would like to use it's parent language for docs, but it seems this is not how moodle works right now
      2. I think the wiki on my language has almost no documentation and i think that a reasonable part of his/her users can read the english version or maybe copy and parte it on an automatic translator so in the end it would be better to direct them to the english version

      I know that new features are not welcome in 1.9 anymore, but i didn't have the 2.0 code right now. I will port it to 2.0 in the next days.

      Hope you like.

      =)

      1. mdl23514.diff
        3 kB
        Daniel Neis
      2. mdl23514-2.0.diff
        3 kB
        Daniel Neis

        Activity

        Hide
        Koen Roggemans added a comment -

        added a few watchers

        Show
        Koen Roggemans added a comment - added a few watchers
        Hide
        Eloy Lafuente (stronk7) added a comment -

        Well, patch doesn't seem correct as far as it forces to have $CFG->doclang always.

        IMO it should be:

        1) CFG->doclang: admin setting with no/list_of_langs
        2) In weblib apply for CFG->doclang with fallback to current language.

        But I like it. Simple and both 1) and 2) uses above seem quite reasonable.

        Ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Well, patch doesn't seem correct as far as it forces to have $CFG->doclang always. IMO it should be: 1) CFG->doclang: admin setting with no/list_of_langs 2) In weblib apply for CFG->doclang with fallback to current language. But I like it. Simple and both 1) and 2) uses above seem quite reasonable. Ciao
        Hide
        Daniel Neis added a comment -

        I preferred to add CFG->doclang to be used always, instead of always do an if, because when you update your moodle, the system will ask you to set this doclang, using your current language as default.
        I really think it is best to force user to configure it one time than to do an extra IF everytime this doc_link function is called.

        Happy you liked.

        Show
        Daniel Neis added a comment - I preferred to add CFG->doclang to be used always, instead of always do an if, because when you update your moodle, the system will ask you to set this doclang, using your current language as default. I really think it is best to force user to configure it one time than to do an extra IF everytime this doc_link function is called. Happy you liked.
        Hide
        Daniel Neis added a comment -

        Hello,

        there is the patch for 2.0.
        I have reconsidered the comments from Eloy and it really makes sense to leave a "force no" option in this config, because the admin could want not to force the language, and have them redirected to their respective language (in a multi-language site, for example).

        So, this patch for 2.0 acts just like that, if the CFG->doclang is not set or is empty, is fallback to current_language.

        Thanks,
        Daniel

        Show
        Daniel Neis added a comment - Hello, there is the patch for 2.0. I have reconsidered the comments from Eloy and it really makes sense to leave a "force no" option in this config, because the admin could want not to force the language, and have them redirected to their respective language (in a multi-language site, for example). So, this patch for 2.0 acts just like that, if the CFG->doclang is not set or is empty, is fallback to current_language. Thanks, Daniel
        Hide
        Eloy Lafuente (stronk7) added a comment -

        +1 (thanks Daniel)

        Show
        Eloy Lafuente (stronk7) added a comment - +1 (thanks Daniel)
        Hide
        Daniel Neis added a comment -

        Hello,

        i've updated the patch to work on 2.2:
        https://github.com/danielneis/moodle/tree/MDL-23514-v22

        and on 2.3:
        https://github.com/danielneis/moodle/tree/MDL-23514-v23

        Hope you like,
        Daniel

        Show
        Daniel Neis added a comment - Hello, i've updated the patch to work on 2.2: https://github.com/danielneis/moodle/tree/MDL-23514-v22 and on 2.3: https://github.com/danielneis/moodle/tree/MDL-23514-v23 Hope you like, Daniel
        Hide
        Daniel Neis added a comment -

        Hello,

        i've rebased the branch to latest MOODLE_23_STABLE.

        Regards,
        Daniel

        Show
        Daniel Neis added a comment - Hello, i've rebased the branch to latest MOODLE_23_STABLE. Regards, Daniel
        Hide
        Daniel Neis added a comment -

        Hello,

        I've updated the patch to MOODLE_25_STABLE.

        Kind regards,
        Daniel

        Show
        Daniel Neis added a comment - Hello, I've updated the patch to MOODLE_25_STABLE. Kind regards, Daniel
        Hide
        Rajesh Taneja added a comment -

        Thanks for the patch Daniel,

        Patch looks good, although you might want to consider few things before it gets to integration:

        1. You don't have to check for isset and isempty. I think !empty should be fine here
        2. With this patch, $CFG->doclang is only valid for custom docs(When $CFG->docroot is defined), IMO it should be valid for either case. For example http://docs.moodle.org/25/en/Main_page and http://docs.moodle.org/25/fr/Main_page works.
        Show
        Rajesh Taneja added a comment - Thanks for the patch Daniel, Patch looks good, although you might want to consider few things before it gets to integration: You don't have to check for isset and isempty. I think !empty should be fine here With this patch, $CFG->doclang is only valid for custom docs(When $CFG->docroot is defined), IMO it should be valid for either case. For example http://docs.moodle.org/25/en/Main_page and http://docs.moodle.org/25/fr/Main_page works.
        Hide
        Daniel Neis added a comment -

        Hello,

        i've rebased the patch considering the issues you note.
        Thanks for the review.

        Kind regards,
        Daniel

        Show
        Daniel Neis added a comment - Hello, i've rebased the patch considering the issues you note. Thanks for the review. Kind regards, Daniel
        Hide
        Rajesh Taneja added a comment -

        Thanks for updating this Daniel.

        Can you please modify commit comment to start with MDL-23514 (Commit_cheat_sheet) and update testing instructions, before this gets to integration.

        Also, as this is an enhancement, would you mind creating master branch for this patch, as this is master only issue.

        Show
        Rajesh Taneja added a comment - Thanks for updating this Daniel. Can you please modify commit comment to start with MDL-23514 ( Commit_cheat_sheet ) and update testing instructions, before this gets to integration. Also, as this is an enhancement, would you mind creating master branch for this patch, as this is master only issue.
        Hide
        Daniel Neis added a comment -

        Hello, i've modified the commit and created a branch for master:

        https://github.com/danielneis/moodle/tree/MDL-23514-master

        hope you like.

        regards,
        Daniel

        Show
        Daniel Neis added a comment - Hello, i've modified the commit and created a branch for master: https://github.com/danielneis/moodle/tree/MDL-23514-master hope you like. regards, Daniel
        Hide
        Michael de Raadt added a comment -

        Thanks for that, Daniel.

        Show
        Michael de Raadt added a comment - Thanks for that, Daniel.
        Hide
        Daniel Neis added a comment -

        Hello,

        please take a look at this patch. It is a trivial one that we are using here in Universidade Federal de Santa Catarina since some years ago...

        Kind regards,
        Daniel

        Show
        Daniel Neis added a comment - Hello, please take a look at this patch. It is a trivial one that we are using here in Universidade Federal de Santa Catarina since some years ago... Kind regards, Daniel
        Hide
        Rajesh Taneja added a comment -

        Thanks Daniel,

        Patch looks spot-on, pushing for integration.

        I have cheery-picked your commit on 26 and 25.

        Show
        Rajesh Taneja added a comment - Thanks Daniel, Patch looks spot-on, pushing for integration. I have cheery-picked your commit on 26 and 25.
        Hide
        Eloy Lafuente (stronk7) added a comment -

        The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

        TIA and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
        Hide
        CiBoT added a comment -

        Moving this issue to current integration cycle, will be reviewed soon. Thanks for the hard work!

        Show
        CiBoT added a comment - Moving this issue to current integration cycle, will be reviewed soon. Thanks for the hard work!
        Hide
        Damyon Wiese added a comment -

        Thanks Daniel,

        This has been integrated to master only as it is an improvement. If you think it really should be backported, you can follow our process for requesting a non-bug fix backport:

        http://docs.moodle.org/dev/Integration_Review#Process_for_requesting_a_non_bug-fix_backport

        This is a nice improvement, thanks!

        Show
        Damyon Wiese added a comment - Thanks Daniel, This has been integrated to master only as it is an improvement. If you think it really should be backported, you can follow our process for requesting a non-bug fix backport: http://docs.moodle.org/dev/Integration_Review#Process_for_requesting_a_non_bug-fix_backport This is a nice improvement, thanks!
        Hide
        David Monllaó added a comment -

        It passes, tested only in master

        Show
        David Monllaó added a comment - It passes, tested only in master
        Hide
        Eloy Lafuente (stronk7) added a comment -

        I claim to be a simple individual
        liable to err like any other fellow mortal.
        I own, however, that I have humility enough
        to confess my errors and to retrace my steps.

        Mahatma Gandhi

        Your awesome code has met upstream, closing, thanks!

        Show
        Eloy Lafuente (stronk7) added a comment - I claim to be a simple individual liable to err like any other fellow mortal. I own, however, that I have humility enough to confess my errors and to retrace my steps. Mahatma Gandhi Your awesome code has met upstream, closing, thanks!

          People

          • Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: