andrewhancox / moodle-filter_translations

8 stars 8 forks source link

No inline translation icons : in Lesson Activity #131

Open gemguardian opened 2 years ago

gemguardian commented 2 years ago

@rjnl and @jgramp In the Moodle introduction course and introduction gamification. we don't see the "in-line translation" icons.

We can use the missing on this page, we can do the translation, but will NOT be visable on the lesson activity.

image

rjnl commented 2 years ago

@andrewhancox Seems like cachingmode is causing this.

We have some lessons translated and now inline translation icon is not visible in lessons any more.

On testing I found that when cachingmode = Request, inline translation icons are shown in lessons. But when cachingmode = Application, inline translations are no longer shown. When cachingmode = Session, then some lesson pages have inline translation icons if you had inline translations enabled. Other pages will not show the inline translation icons.

Initially we had cachingmode set to Request, so lesson pages were translated using inline translations. Now that we have switched to cachingmode = Application, we are seeing this issue.

Here is a screenshot of a lesson page when cachingmode=Request.

image

jgramp commented 2 years ago

Any ideas on a fix for this @rjnl ?

rjnl commented 2 years ago

Current workaround is to set filter_translations | cachingmode to Request.

andrewhancox commented 2 years ago

Again - are you definitely running the latest build with the fixes to the caching code? There should be no caching applied when you’re in editing mode.

On 4 Jul 2022, at 01:44, Rajneel Totaram @.***> wrote:

Current workaround is to set filter_translations | cachingmode to Request.

— Reply to this email directly, view it on GitHub https://github.com/andrewhancox/moodle-filter_translations/issues/131#issuecomment-1173213445, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJEYMS7DDSWL6DZYSVFODLVSIXWLANCNFSM5Z7KL7KA. You are receiving this because you were mentioned.

rjnl commented 2 years ago

Yes, I tested this again with the latest code.

Set cachingmode=Application, purged all caches. Turned inline translation on and went over lesson pages => inline translation icons are visible in the lesson content. Turned inline translation off and went over lesson pages => inline translation icons are not visible in the lesson content. Turned inline translation on and went over lesson pages => inline translation icons are visible in the lesson content. Turned inline translation off and cleared all cache and then went over lesson pages

Now turned inline translation on and went over the same lesson pages => inline translation icons are not visible in the lesson content.

rjnl commented 2 years ago

This is where problem seems to lie, when $skipcapabilitycheck param is true: https://github.com/andrewhancox/moodle-filter_translations/blob/b97c39adb3a36b322a245da3e5f233e4b6a0cf15/filter.php#L87

Is the $skipcapabilitycheck flag really necessary in function checkinlinestranslation()?

Couldn't this line https://github.com/andrewhancox/moodle-filter_translations/blob/b97c39adb3a36b322a245da3e5f233e4b6a0cf15/filter.php#L235

be

if (!isset($has_capability)) {?

andrewhancox commented 2 years ago

I've just pushed a fix that handles this and issue #135 There was an issue with detecting in-line translation status for non site admin translators with caching enabled. I've also added some PHP Docs to the relevant function.

@rjnl In answer to your question, the filter can sometimes be run very early in the page lifecycle, before things like contexts are properly set up.