Sensei: Course blocks are not being translated

Created on 18 Jan 2021  路  7Comments  路  Source: Automattic/sensei


Last week I started creating a new course in version 3.6.1 and there is a lot to like about the new presentation and using blocks in that.

In working with both Sensei LMS and Sensei LMS with WC paid course we noticed a few issues:

  1. whenever a lesson was saved, the lesson order in the course was being reshuffled, so after 10 times reordering the lessons back manually I decided had add custom code to force it back to the intended order. I'm not sure what is causing it, so I will at a later time investigate some more and come back on it.
  2. The Dutch translation in Sensei LMS with WC Paid Courses is still bugged ( see issue #3177 ), was missing about 400 strings and loco translate wasn't able to override the translation since it uses a filter to hardcode what file to use (I had to add custom code to override that, so updating the plugin wouldn't overwrite the changes).
  3. The new blocks on the course page aren't being translated, like the rest of sensei LMS (the subject of this issue).
  4. I had to restyle the ol and ul lists since this version has different html and no styling was applied by either sensei of the theme to these html elements. The earlier customization didn't apply in the new page and needed to be changed.

When I looked in the code I saw that the title of the "Take Course" button goes through, __() but the default value isn't and the "Contact Teacher" button text isn't at all. I haven't checked the course outline block, but it is also presenting in the English language.

I wanted to try wrapping the "Contact Teacher" strings in __() (also in the dist folder) but wasn't able to get it translated that way. But it is not good when in a Dutch nationalized WordPress install the blocks aren't translatable, not to speak about systems that run in multiple languages. All sensei elements, including the course outline and woocommerce purchase course button remain in English, so it seems Sensei LMS isn't translating any of them.

I found that I can manually change the button texts, but that broke the buttons layout on the frontend in my genesis child theme (although it worked in twentytwentyone, but there sensei styling changed the button styling in the demo footer too). That can of course be fixed with css, but it means adding customization work, where it shouldn't be necessary. And dynamically generated buttons will not be translatable that way, so they surely need to be translatable via a .mo file.

Steps to Reproduce

  1. Setup wordpress and set the language to the Dutch language (or any non-english language)
  2. Make sure there is a translation (.mo) file for that language, containing all translatable strings.
  3. Add a course, leaving everything like it is.
  4. Look at the sensei blocks and see they are all in the English language.

What I Expected

I expected the blocks to be in the language of the WordPress installation and the output to be internationalized.

What Happened Instead

All sensei buttons and other blocks in the default course post_type template remain in the English language and don't seem to be translatable by a .mo file. The 'Contact Teacher' button on the lesson page is localized, but all sensei buttons (blocks) on the course page don't appear to be.

PHP / WordPress / Sensei LMS version

php v7.4.x and v8.0.0
sensei v3.6.1
wp v5.6

Browser / OS version

Firefox dev version
Windows 10

Screenshot / Video

Context / Source

[Type] Bug

All 7 comments

whenever a lesson was saved, the lesson order in the course was being reshuffled

Do you know if you have some kind of object caching done by the hosting provider, or by a plugin?

@yscik
Sorry, I don't know about that. We have use wp-rocket for caching and for handling the scripts and css. And we use phastpress to convert the jpg images to webp format. I know wordpress itself performs caching too, but the details of that I don't know.

The website that had the problem runs on a WPO starter plan at Bigscoots. I could ask them if they have setup something like that. Is there anything specific you need to know? I dont have access to the setup myself, so I would have to ask.

In dealing with the problem, I have solved it first by filtering the get_metadata call, but that only fixed the course page and not the pagination within the lessons. So now I just use update_metadata to update all lessons before usage. It's a crude fix, but for now it was the only thing I could think of. Basically I had to hardcode the database outside of sensei LMS to fix it. It means running 47 meta updates that I rather remove.

@yscik Bigscoots support says: By default, the only object caching that we can provide is with the Redis instance, but you are not using it currently.

So we have no server setup right now for object caching outside the caching that wp-rocket adds to core wordpress.

I opened issue #3921 for the lesson order bug, since this one was mainly for the translation issue. My analyses of what I found in the code, about why the lesson order is changed, is described there.

reported in 3687642-zen; reports both "Take Course" and "Complete Purchase" translation issues.

3707563-zen

Fixed in #3919

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cycomarcooo picture cycomarcooo  路  5Comments

gaurav1984 picture gaurav1984  路  4Comments

merkushin picture merkushin  路  3Comments

donnapep picture donnapep  路  5Comments

richardmtl picture richardmtl  路  5Comments