dualcube / moodle-theme_crisp

A Crisp Bootstrap Theme for Moodle
0 stars 3 forks source link

Text not processed through Moodle filters #2

Open michael-milette opened 9 years ago

michael-milette commented 9 years ago

As I run multilingual sites, I was pleased to see that you have included a dropdown to select from a list of languages.

However, when I view the site using the crisp theme, I notice that the site name is not processed through the Moodle filters. As a result, multilingual strings that get filtered in other themes do not in crisp on Moodle 2.7. Here is the problematic line from layout/header.php:

 <a class="brand" href="<?php echo $CFG->wwwroot;?>"><?php echo $SITE->fullname; ?></a>

The solution is to wrap $SITE->fullname in a format_string() function as follows:

 <a class="brand" href="<?php echo $CFG->wwwroot;?>"><?php echo format_string($SITE->fullname); ?></a>

I haven't fully tested your theme however you may be wise to check around to see if there are other places that should also be but are not processed through either format_string() for short strings and format_text() for longer text.

Best regards,

 Michael Milette
parthajeet commented 9 years ago

Hello Michael,

We have fixed the mentioned issue. Kindly let me know your thoughts.

Thanks and Regards, parthaJeet~

michael-milette commented 9 years ago

Hi pathaJeet,

I think you may have misunderstood how language works in Moodle.

get_string() functions retrieve information from Moodle language files. Since the information is supposed to be coming from a file already contains the correct language, there is no need to process this information though Moodle filters.

What needs to be processed through the format_string() or format_text() functions is configuration information that has been entered in Moodle's settings pages. As previously mentioned, the site's fullname is one such example. Other examples include but are not limited to course names and descriptions, course module names and descriptions, date and time, and other stuff like that which is typically entered by non-students. Student entered information should not be processed through Moodle filters unless you have a very good reason to do so.

I noticed that you also have some hard coded text in your theme. These strings will appear in English regardless of the language Moodle is in and should therefore always be avoided. Instead, you should retrieve language strings defined in Moodle language files using the get_string() function.

By using language files instead of hard coded strings, anyone will be able to easily take your plugin's language file and translate it into their favourite language and hopefully submit it through Moodle's AMOS system.

Let me know if you have any questions and I will do my best to provide you with an answer.

Best regard,

 Michael
parthajeet commented 9 years ago

Hello Michael,

Thanks, yes actually there are some hard coded text in the theme. We will replace the text with the language files in our next update.

Thanks a lot for the support and information.

Regards, parthaJeet~