Change a language string without using the 'Language customisation'

Change a language string without using the 'Language customisation'

by Anthony M -
Number of replies: 2

Hi all,

In MoodleCloud there Language customisation is dissabled (.../admin/tool/customlang/index.php) ...




In boost theme in Moodle 4, I wonder if there is any way to change a string by using the next two tools at the same time...

- 'Custom HTML' (.../admin/settings.php?section=additionalhtml)

- 'Custom css' (.../admin/settings.php?section=themesettingboost#theme_boost_advanced)


Somthing similar to what is done by Bob Gilmore with the ' back to top' button here: https://moodle.org/mod/forum/discuss.php?d=433574#p1745834


I need to change the 'My Courses' text...



Thanks!


Average of ratings: -
In reply to Anthony M

Re: Change a language string without using the 'Language customisation'

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
I don't think you can unless the additional HTML section allows JavaScript, which I doubt it would.
In reply to Anthony M

Re: Change a language string without using the 'Language customisation'

by Bob Gilmore -
Picture of Particularly helpful Moodlers

This is freaking ugly and I'm not sure I recommend it but it does work. There may be a tonne of issues with this, including naming collisions, so use at your own risk.

Basically, shrink the font size down to 0 to 'hide' the content, then use the :after pseudo-class to insert new content and reset that contents font size.

/* Set font sizes to 0 to hide strings */
.nav-item[data-key="mycourses"] a, .page-mycourses header h1 { font-size: 0 }

/* Reset font sizes for :after */
.nav-item[data-key="mycourses"] a:after { font-size: 15px; }
.page-mycourses header h1:after { font-size: 30px; }

/* Change the string */
.nav-item[data-key="mycourses"] a:after, .page-mycourses header h1:after { content: "New Course String"; }

Ive had to reset the font size back to 15px / 30px manually, so you will need to tweak this value for each string you need to change (e.g. the link vs heading have different sizes).

You'll need to do this (or something similar) to target each "My Courses" string you want to change.  Use your web browsers element inspector to see what classes / data keys / id's etc are to select them with CSS.

Unrelated: Moodle, what's with using an h2 class on an h1 element? 

Average of ratings: Useful (2)