michael-milette / moodle-filter_filtercodes

FilterCodes filter for Moodle enables content creators to easily customize and personalize course and site content using plain text tags (no HTML). For premium support, contact us at https://www.tngconsulting.ca/contact
https://moodle.org/plugins/filter_filtercodes
GNU General Public License v3.0
30 stars 42 forks source link

Make the lang tag support Moodle's multilang filter #266

Closed wilenius closed 9 months ago

wilenius commented 10 months ago

Prerequisites

Feature Request - The User Story

As a teacher, I want to have an easier way to create multi-language content in Moodle. If the langx-tag would add the property class="multilang" to the language span tag, then the created tags would be compatible with the Multi-language content filter, which hides the span tags that do not match the selected language of the user. For more info on Multi-language content filter, see https://docs.moodle.org/402/en/Multi-language_content_filter.

Screenshots / Mock-ups

No response

Alterative you have considered

No response

Additional information

No response

Planning on submitting a solution in a pull request (PR)?

Maybe

Code of Conduct

michael-milette commented 10 months ago

Hello @wilenius ,

The purpose of this tag is not to filter content based on language but to insert text that is in a different language than the page text. For example, if I am viewing a page written in English but want to insert a French or Spanish word, you would wrap the text in a set of {langx}{/langx} tags and specify the language of that text so that a screen reader can read it correctly.

If you are looking for a plain text alternative to the multilang span tags but want to stick with that filter, a new tag might be in order. Alternatively, you could use the multilang2 filter with its {mlang XX}{mlang} plain text tags.

Let me know what you think about this.

Best regards,

Michael Milette

michael-milette commented 9 months ago

Hi @wilenius ,

You asked for it, you got it! I just added a set of {multilang xx}...{/multilang} tags to FilterCodes. All it does is convert:

{multilang xx}...{/multilang} to <span lang="xx" class="multilang">...</span>

It therefore depends on Moodle's Multi-Language Content filter being enabled and positioned below FilterCodes in Filter Management so that it then processes its tags.

Please note that this feature is currently only available in the version of FilterCodes available here on GitHub. I would appreciate it very much if you would be so kind as to try it out and get back to me to let me know if it works for you.

If it works for you, this feature will be included in the upcoming release of FilterCodes on Moodle.org within the next few weeks.

Best regards,

Michael

wilenius commented 9 months ago

Brilliant! Let me test it on our development server and get back to you.

And re the original lang tag functionality, makes complete sense, and a handy feature too.

wilenius commented 9 months ago

Just gave it a go, and it works nicely. One can add multiple paragraphs of multilang content too, as long as the multilang tags are back-to-back, e.g.:

{multilang fi}Finnish
<h5>heading</h5>{/multilang}{multilang en}english
<h5>heading</h5>
{/multilang}{multilang sv}swedish
<p>paragraph</p>
{/multilang}

So it works just like the span tags, but they are much easier for the users.

michael-milette commented 9 months ago

Hi @wilenius ,

Thanks for the suggestion and the feedback. I really appreciate you testing it.

Best regards,

Michael