Language customisation
Note: This page describes how to change words or phrases in Moodle 2.0 onwards. For details of the process in versions prior to 2.0, see Language editing.
Location: Site administration > Language > Language customization
Words or phrases (in any language) used on the site may be easily changed using the language customization feature. For example, you may want to change the word "Course" to "Unit". The process consists of 4 steps:
- Check-out the strings
- Filter the strings you wish to customize
- Customize the strings
- Save and check-in the strings
Quick instructions for the impatient
- Go to the Site administration > Language> Language customization page.
- Pick the language to customize from the pull down list.
- Click the "Check out strings to translator" button. This make time to process.
- Click or Ctrl+Click to select files on the "Filter strings" interface. Notice files are grouped. For example, you will find the lesson strings under "mod" and moodle.php under core.
- After selecting the file(s), it is possible to use "string must contain" and other filters. For example, look at only string text that has "teacher" the file(s) you selected.
- Click "Save changes and continue editing" if you want to pick another filter or PHP file(s) to edit.
- Click "Save and check in string into files" to save all changes you have made.
- Tip: Do not see any string changes? Did you remember to use the "Save and check in string into files" button? Did you refresh your browser so it is not looking at a cached page? Did you edit the language file that is actually being used in your site, course or by the user?
Background
Moodle is translated into many languages - see [1] for their list and the translation completion status. The translations are distributed in so called language packages (or just lang packs) that are maintained by kind volunteers, community contributors and Moodle partners. Please read the page Translation first to understand how the whole localization machinery works.
Moodle site administrators can customize any language pack to fit their individual needs (for example to use the term "Unit" instead of "Course"). You are discouraged from direct editing the files coming as a part official language pack. Such changes would be silently overwritten during the next upgrade. Instead, you should create a local language pack that holds all your changes from the official pack.
Local language packs have the same structure as the official ones. They are saved in your Moodle data directory in moodledata/lang/xx_local/ folder where 'xx' is the code of the language. You have to have the official language pack installed before you can customize it. Local language pack should contain just strings you have customized - you should not copy whole official language packs.
When displaying a string, Moodle first looks if a local customization of it exists in moodledata/lang/xx_local/component_file.php. If so, it is used. If not, the string from the official language pack is used (eventually, if the string has not been translated yet, the original English version is displayed). Please note that the strings are cached for better performance so you have to purge Moodle caches after you modify a file in your xx_local pack (caches are purged automatically if you use the tool described below).
Using Language customization tool
Moodle comes with a tool that allows you to edit your local language pack via web interface. This tool is available for the site administrators via block Settings > Site administration > Language > Language customization. Please refer to the following workflow diagram.
Check out strings into translator
At the Language customization first page, select a language to customize and press the button 'Check out string into translator'. During the checkout, Moodle loads the language strings from PHP files into its database. The language customization tool works with this database so the files in your xx_local pack are not touched unless your proceed to the final step of this workflow. If the xx_local language pack does not exist yet, Moodle automatically creates an empty one for you.
- Tip: There is currently a problem with "execution time". If you get the "Fatal error: Maximum execution time of 180 seconds exceeded" message, you will have to press the button 'Check out string into translator' several times to get the operation completed. See forum discussion.
Filter the strings you want to customize
After the checkout, use the filter form provided to find strings you want to customize for your site. The following filter options are available:
- Show strings of these components - if you know which component defines the string you look for (it is a second parameter of the get_string() function), choose it here. Eventually, select all options to search across all components.
- Customized only - check this field to display only those strings that are already present in your xx_local pack.
- Help only' - check this field to display only help tooltips, that is the texts used when clicking the yellow question mark icon. Started in Moodle 2.0, help string identifiers must end with _help suffix.
- Modified only - displays only the strings that are modified in the current session. Note the difference between 'customized string' and 'modified string' here. We use the term 'customized' for strings that are saved on disk in your xx_local pack directory. While the term 'modified' represents the changes you have done since the last checkout. Customized strings (already saved in a file) are highlighted with green. Modified strings (not saved in a file yet) are highlighted with blue. You may want to use this option to overview your current work before you check it in.
- Only strings containing - insert a phrase that must appear in the string, either the English or the translated. For example, if you put a word 'student' here, you will get only those strings that mention this word. This can be effectively used for mass search and replace to change the terminology you use in your Moodle site.
- String identifier - if you know the string identifier (it is the first parameter of the get_string() function), type it here. For example, the names of activity modules are defined in strings 'modulename'.
Use any combination of filter settings to get the required set of strings and press the button 'Show strings'. We believe that the filter is powerful part of the whole tool and with clever settings it will allow you to find the required strings effectively.
Input your own translation
The strings that pass all the conditions defined in the filter are displayed in a table. To replace the standard translation, put your own into the field in the last column 'Local customization'. Do not forget to save the text you input via 'Save and continue editing' button.
If you want to delete your current customization, just delete the content of the input field and save the translator form. The modifications that are going to remove a customized string are highlighted in red.
Saving your work into files
Repeat the last two steps as needed to find all the strings you want to change. When you are ready to save your work into files in xx_local language pack, press 'Save and check in strings into files' button.
Writing the modifications into files
During the checkin, the contents of the translator database are dumped into files in moodledata/lang/xx_local/ directory. Note this operation removes this directory first and then re-creates it with the actual data. Therefore it is reasonable to not to touch the files directly after you have checked out them into the translator.
See also
- Language editing - for versions of Moodle prior to 2.0