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

Create a cli for batch search and replace of language string customizations

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Development in progress
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.11
    • Fix Version/s: None
    • Component/s: Language
    • Testing Instructions:
      Hide

      Interactive mode
       
      A1) Execute  
      php admin/tool/customlang/cli/batchreplace.php -s='Dashboard' -r='Replacement'
       
      A2) Confirm that there are 61 matches to this search
       
      A3) Enter `a` to stage this match and all later matches in the search
       
      A4) Confirm that the program says there are 7 strings unsafe for replacement
       
      A5) Manually go trough these, since there is no `a` option
       
      A6) The program will prompt the user one more time before saving, if any mistakes are made. Enter `y`
       
      A7) Confirm that program says `Saving...` and `Succesfully replaced strings`
       
      A8) Open site
       
      A9) Confirm that language is english
       
      A10) Confirm that `Dashboard` has been replaced with `Replacement`
       
      A11) Open `admin/tool/customlang/index.php`
       
      A12) Select enlgish language pack
       
      A13) Click `Open language pack for editiing` button
       
      A14) Click `Continue` button
       
      A15) Select all components
       
      A16) Enter `Dashboard` in `Only strings containing` input box
       
      A17) Click `Show strings` button
       
      A18) Confirm that `Local customisation` column contains replaced values
       
       
      Non interactive mode
       
      B1) Execute 
       
      php admin/tool/customlang/cli/batchreplace.php -s='Dashboard' -r='Second Replacement' -n
       
      B2) Confirm that program only outputs the searches found
       
      B3) Execute
       
      php admin/tool/customlang/cli/batchreplace.php -s='Dashboard' -r='Second Replacement' -y
       
      B4) Confirm that program outputs differnce made
       
      B5) Follow steps A7 to A9
       
      B6) Confirm that `Replacement` has been replaced with `Second Replacement`
       
      B7) Follow steps A11 to A18
       
      Regex with non-interactive assume-no
       
      C1) Execute 
       
      php admin/tool/customlang/cli/batchreplace.php -s="/([A-Z])\w+/" -r="Hello" -n --regex
       
      C2) Confirm that program only outputs searches found and highlights words that start with a capital letter.

      Show
      Interactive mode   A1) Execute   php admin/tool/customlang/cli/batchreplace.php -s='Dashboard' -r='Replacement'   A2) Confirm that there are 61 matches to this search   A3) Enter `a` to stage this match and all later matches in the search   A4) Confirm that the program says there are 7 strings unsafe for replacement   A5) Manually go trough these, since there is no `a` option   A6) The program will prompt the user one more time before saving, if any mistakes are made. Enter `y`   A7) Confirm that program says `Saving...` and `Succesfully replaced strings`   A8) Open site   A9) Confirm that language is english   A10) Confirm that `Dashboard` has been replaced with `Replacement`   A11) Open `admin/tool/customlang/index.php`   A12) Select enlgish language pack   A13) Click `Open language pack for editiing` button   A14) Click `Continue` button   A15) Select all components   A16) Enter `Dashboard` in `Only strings containing` input box   A17) Click `Show strings` button   A18) Confirm that `Local customisation` column contains replaced values     Non interactive mode   B1) Execute    php admin/tool/customlang/cli/batchreplace.php -s='Dashboard' -r='Second Replacement' -n   B2) Confirm that program only outputs the searches found   B3) Execute   php admin/tool/customlang/cli/batchreplace.php -s='Dashboard' -r='Second Replacement' -y   B4) Confirm that program outputs differnce made   B5) Follow steps A7 to A9   B6) Confirm that `Replacement` has been replaced with `Second Replacement`   B7) Follow steps A11 to A18   Regex with non-interactive assume-no   C1) Execute    php admin/tool/customlang/cli/batchreplace.php -s="/( [A-Z] )\w+/" -r="Hello" -n --regex   C2) Confirm that program only outputs searches found and highlights words that start with a capital letter.
    • Affected Branches:
      MOODLE_311_STABLE
    • Pull Master Branch:
      mdl-70415-cli-search-and-replace

      Description

      There is a very common requirement to customize a large number of strings. eg 'course' -> 'subject'.

      https://moodle.org/mod/forum/discuss.php?d=354499#

      https://moodle.org/mod/forum/discuss.php?d=272950

      The normal language customization is perfect from a functional point of view but its just clunky to do in bulk and an error prone process.

      Proposing a very simple search and replace script, almost identical in usage to the db replace tool, but it operates on language strings.

      http://moodle.local/admin/tool/replace/

      php admin/tool/replace/cli/replace.php -h

      MVP is a cli. We might do a gui in another tracker.

        Attachments

          Activity

            People

            Assignee:
            brendanheywood Brendan Heywood
            Reporter:
            brendanheywood Brendan Heywood
            Participants:
            Component watchers:
            David Mudrák (@mudrd8mz), Helen Foster, Víctor Déniz Falcón
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated: