I would like to change the word 'student' to 'pupil' across the whole of our Moodle site. The language customisation editor shows almost 400 strings that contain 'student'. After reading the language customisation docs and various forum posts I've come to the conclusion that I have to replace 'student' with 'pupil' in each one of the strings individually.
My plan is to copy the strings into a spreadsheet, replace the word in the standard text column and then copy / paste the back into the local customisation fields.
Before I set out on this task I'd like to ask whether there is a better / faster / less error prone (manual copy/paste) method anyone has devised and would be happy to share with the Moodle community
Yes, if you want to change 'student' to 'pupil' in the entire site, then you have to make those over 400 changes.
However, I caution against doing this. The reason is that you will change the word in the site administration documentation, and that may lead to errors when instructions are followed - e.g. Moodle expects a string 'student' and someone enters 'pupil' instead. I'm not certain about that, but the possibility exists.
An argument against the above position is that the word 'student' is changed in the strings for other languages and that does not have adverse effects.
Changing all the strings is a big job, and will require a lot of extra work when you upgrade to later versions; you will need to do the entire process again. I would use Role Renaming in the Course Settings area. That's much easier and safer.
I'm in agreement with Floyd that the best place to change 'student' to 'pupil' is via the role renaming section in the course settings. Also, there is most likely no need to change it everywhere it appears in the admin settings.
If you change it using Language customization though, you don't need to worry about upgrading, as all your customizations will be saved and will still be there when you upgrade.
Thanks for the correction on my comment about language file customization. I should have read the documentation!
So Christoph, consider this if you want to change all the strings and live dangerously. (I still hold to my original suggestion that you make changes in the course role renaming section).
- Changes to the language file are stored in the moodledata/lang directory . These changes are applied to the standard Moodle language file cache after it is loaded.
- Try making a few string changes to the standard English language moodle.php file using the language customization tool. Then look at moodledata/lang/en_local/moodle.php (assuming you have access to your site installation).
- Notice the pattern for changes in the above file. Using a powerful text editor, such as Vi/Vim, you can likely do some fast string changes to the standard moodle.php language file, then delete any lines you did not change, and store the changes in moodledata/lang/en_local/moodle.php.
I'll add a disclaimer:
- I tried it with a couple strings, but did not do extensive testing.
- I take no responsibility for any damages or mess-ups that happen when you do this.
- As always, you should do extensive testing on a backup site before applying changes to a production system.
- Before making any database or moodledata changes to a production system, you should make backups of those files and directories.
- If Moodle is running when you create the .../en_local/moodle.php file, you will need to clear the cache to see your changes.
As Floyd explained, customized strings are stored in the _local folders for each language pack, in the php files with the same names as originals. Only the changed strings (when changing thru web interface) are put into the local files. One could use a global search through lang files to identify the strings that need to be changed and copy them manually to local files to speed things up. However, global change still won't work because "student" is part of the name of many strings and those should not be changed unless fancy GREPing is used to apply changes only after the equal sign. One could also automate this by writing a script that scans original language files, finds student in the content of strings, copies them to _local files and replaces student with pupil only on the content side.
Floyd, and Helen and Robert,
you all for going to the trouble to consider my question and even
trying out your suggestions to see what the consequences are. It's much
appreciated. Robert is correct, I was setting out to replace the word 'student' with 'pupil' wherever it appears on the site because that is the word we use in our school.
Also, if I make changes to moodledata/lang/en_local/moodle.php don't I have to tell the database about those changes? That's why I think I will make changes only through the language customisation tool even if it takes longer.
I will experiment on my development site and see what happens.
If you modify the en_local files directly at the file system, you have to purge caches from the Moodle administration UI to force Moodle to reload them. The language customization tool does this for you once you write the changes to the disk via it.
Thanks David for clearing it up, all questions answered.
To clarify your surprise about functions expecting string 'student': If you look at the raw language files, you will see lines with
$string['stringname‘] = 'stringtext';
When customizing strings, you are to edit only the stringtext and not the stringname. Stringnames are hard coded in the Moodle code. This is normal. The program needs to know the reference to a specific string. The thing is that some stringnames contain "student" (for example, 'defaultcoursestudent') so when editing a language file directly, one has to watch to change only stringtexts. This was with regards to Floyd's suggestion to use vim or similar editor.
You do not need to tell database about the changes to files. Moodle loads the language files as needed. You will only need to clear caches (on the server as well as on your local computer) to see the changes right away.
Robert, thanks for your reply. Your illustration has cleared up my remaining uncertainty and helped my to fully understand your and Floyd's earlier reply.
Somewhat ironically I recently changed, via the language customisation tool, the word "pupil" (actually "elev" because our Moodle uses the Swedish language pack) into the word "student", moving in exactly the opposite direction to Christoph.
I judged that I didn't need to change every occurrence of the term because a lot of them occurred in little used help files that the students would never see, and even the teachers would rarely see.
I've informed the staff that if they find the word "pupil" in a context that irritates them they can contact me and I'll change it directly.
This saved me a lot of work! If you have helpful teachers you could adopt the same strategy.
When it comes to $string['stringname'] and 'stringtext' it is even clearer how it works with a non-English language pack - the string name is still in English ('defaultcoursestudent') but the users see the term "Lärande". So leave the string names alone!
I like your idea, Keith. Let's see how I get on with using a text editor and not changing string names on a small sample. Thanks for your reply.
Perhaps rather heavy duty for you but you can give it a shot after exhausting all other alternatives. This is what we use for changing the string 'course' in Moodle. Perhaps it is one of the most used strings. Here is the recipe which can be used in similar cases:
- For lower case search use as it occurs in the middle of the string and might be used as an object property and variable:
- For upper case, it will occur mostly at the start of the string and
has minimal chance of being used as an object property and variable:
- Please note that besides uppercase and lowercase, multiple
occurrences of the word 'course' will require running search / replace
multiple times. Note the use of the following in the search pattern:
- groups and back-reference inside the search pattern itself;
- negation operation inside the character class i.e. square brackets
- The replacement pattern would be:
- Please note that both in notepad++ and Netbeans, back-references in the search pattern work with a backslash '\' but in the replacement pattern, a '$' is required.
Please type carefully. Had provided the patterns as text but Mathjax ends up rendering some part in mathematical notation and hence providing the search and replacement strings in the text file.
Please use these after thorough testing and at your own risk.
This thread is over a year old, but does Moodle 3.0 enable a more efficient change of a single word like "course" ?
Also, has this regex been tested on a Moodle 3.0 installation ?
Thanks, i am curious about this subject and very new to Moodle.
Ok, thanks David. We are still evaluating the amount of work in order to rename all/most instances of courses into workshops across several languages.
Hello Mary, actually i wanted to rename the french version of course (cours) to activity (activité) to be precise.
I do realize there will be problems. I am trying to see how doable such an undertaking is, especially since we plan to offer our Moodle in a minimum of 3 languages: French, English and Spanish.
I am also trying to see if by doing greps on the source .php files to identify where the bulk of these words are located if there isn't a more efficient way, like doing a new language pack specific to our project for example. I am still trying to identify the most efficient way of doing this besides rewriting manually 2000 strings in each language using the built-in GUI to manage the language pack.
So far i couldn't find a magic bullet, no computerized way to easily implement something like this. I will also remember your workshop example and search also for possible collisions. I don't want to end up with strings like "This workshop workshop is full"
Thanks Mary for your clairvoyant output, the more i dig into this word change the further down it goes, i feel like Alice.