Multi-language versions of custom text?

Multi-language versions of custom text?

by J K -
Number of replies: 11

Hi. I have an English language Moodle 2.6 installation which I now need to make available in six different languages. I have installed the language packs for these languages, but cannot see an easy way to provide translated content for the custom message body of the "Is this your first time here"  message for self-enrollment or the Site Summary (custom) Welcome message.

Tagging these messages in HTML for 6 languages would be very tedious and prone to error. Is there an easier way?

Thanks,

JK

Average of ratings: -
In reply to J K

Re: Multi-language versions of custom text?

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hi JK,

The easiest way to provide login instructions in several languages is by using the language customisation feature. Please see the section 'Instructions' in Managing authentication for details.

You can do the same for the self-enrolment welcome message by editing the welcometocoursetext language string.

Average of ratings: Useful (1)
In reply to Helen Foster

Re: Multi-language versions of custom text?

by J K -

Hi, thx for reply! I should have added to my post that I had tried this (and did Purge all caches), but it did not work - see screenshot below.

I have also tried filtering for welcometocoursetext language string, but that returns a lot of results, none of which seems to be the text I want? (screenshot attached).

I had assumed/hoped that it would be this type of approach, but it just doesn't seem to work?


I really appreciate the help on this...


Best, JK

Attachment ManageAuth.PNG
In reply to J K

Re: Multi-language versions of custom text?

by Robert Brenstein -
Unfortunately, the login page instructions are not handled through the language files AFAIK. They are set in the field auth_instructions on the panel Manage Authentications, so you indeed need to use the multilang filter syntax (unless newer Moodle checks the language files for overwrites). The same is true for the field summary (Front page summary) on the Front Page Settings panel.

It is of course possible to implement a little hack and have your Moodle pull those texts from customized language files instead of the database. It is probably a single-line change in the code but it surely requires massaging the language pack.
In reply to Robert Brenstein

Re: Multi-language versions of custom text?

by J K -

Thanks for that - seem unusual that the "Manage Authentication" option doesn't work tho ...

Robert, could you please provide some detail or link re: the suggested "little hack" - this sounds much more manageable than the multilang filter route ?


In reply to J K

Re: Multi-language versions of custom text?

by Robert Brenstein -
Multilang filter works with the field in Manage Authentications. I use that myself. One possible problem might be that the field size is too small to store your text for 6 or whatever languages you have. If that is the case, some if not all languages would display text combined with multiple languages, truncated in some odd place. More likely, there is an error with html tags. If you are using WYSIWYG editor, it probably mangles your input. It is a source of problems for many people using multilang filter and there are some alternative versions of it as the result.

Well, the text from the input field is kept in the database and fetched from there into some variable then displayed after being run through the multilang filter. You need to find the line in code that displays that text and replace it with a line that recalls a string from the current language pack. You can find examples of that in the same function, I am pretty sure. If you have problems locating that, feel free to contact me by email.

Now, the tricky part is to get the strings in the language packs. I presume that you would prefer to be able to use the web interface to edit those strings (as local changes) since that makes things simpler on the long run. Besides, adding new strings to a language pack poses some issues. I would find an existing string that it not used on your site. It does not have to be in the moodle.php file. Just browse through your lang pack to find such a thing. Note its exact name and the name of the lang file it is in. Customize it for your needs in any language you want and recall in the hack above. You can store the reference to it in the admin panel, so it is documented.

This should work. You will just need to transfer this hack when you switch to a new major version of Moodle. If your Moodle is installed from git, you can merge minor updates without loosing your hack.

By the way, a request to move those instructions to language packs was turned down, cf. MDL-4477.
In reply to Robert Brenstein

Re: Multi-language versions of custom text?

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

JK, sorry to hear you've not managed to get the language customization method to work, nor you Robert.

I've just tried editing the default login instructions in two languages on demo.moodle.net and found things working perfectly. (You're welcome to try too, as you can log in to the site as an admin, though you'll have to enable email self-registration.)

I subsequently added a note to Managing authentication though, which I think may be the reason why you found it not working.

Note: The instructions field must be left blank for the above method to work. Custom login instructions in English can be provided by editing the English language pack.

If you previously added text to the instructions field then you'll need to remove it, and if you're using a text editor, check in HTML mode that no br tag is left behind.

The same will apply when adding translations of the welcometocoursetext - the custom welcome message field must be left blank.

Thus, I hope you are now able to provide multi-lang versions of custom text. If the documentation needs clarifying further, please let us know.

In reply to Helen Foster

Re: Multi-language versions of custom text?

by Robert Brenstein -
I suggest that the moderator deletes my previous post, so nobody tries hacking for no good reason. As I said, multilang filter works in the admin panel and as doc clearly states, default instructions can be customized through the language editing interface.
In reply to Helen Foster

Re: Multi-language versions of custom text?

by J K -

Helen/Robert - I really appreciate your invaluable help! I'm almost there...

  • I have sorted the "loginsteps" message. you were correct Helen - I had to delete the message that I had done in English thtough Manage Authentication. All is now good
    • BTW (email-based self enrollment plugin is missing from sandbox)
  • I cannot locate the strings identifier for the site summary page. It does not appear to be "welcometocoursetext" in moodle.php - I have tried that, but it remains blank on populating.
    • for clarity, I have attached a screenshot from the sandbox of exactly the message I wish to be able to manage for translations.
  • I have tried "&strings=1" in the URL to try and identify, but to no avail
  • Any idea how I might progress?
  • Is there a description anywhere of all the fields?


Best regards,

JK



Attachment SS2.PNG
In reply to J K

Re: Multi-language versions of custom text?

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

JK, sorry I misread your initial post when you mentioned self enrolment and a custom welcome message and thought you meant the email which is sent when someone self-enrols in a course (as described in the section 'Sending a welcome message to new users' in the documentation Self enrolment).

For the area you highlight in the screenshot, there is no default text. Thus the only way here is to use the Multi-language content filter as you originally thought, and as Robert has confirmed.

In reply to Helen Foster

Re: Multi-language versions of custom text?

by J K -

OK - Thanks for that Helen. Any chance that this could be considered for a future fix?  It really is a gap in the who translation programme and I can't imagine I'm the only one who has had this problem....


In reply to Helen Foster

Re: Multi-language versions of custom text?

by Ken St. John -

Helen - you are a genius. Do you know how many people are searching for the issue regarding the "Is this your first time here?" message and its removal? Crazy hacks and theories all treating a symptom instead of the issue which you so eloquently cited. If you ever type anything into the authentication block dedicated to enabling a custom login message with the text editor and then remove it, it actually leaves a break code behind <br>. This remnant is ONLY VISIBLE by switching to HTML mode (<> symbol). Deleting it restores the login panel to its pristine condition - i.e. no "Is this the first time ..." message. I intend to go on a quest and supply this real solution to the posts wherever I can find them. Thanks!