Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register blocks to make translations available in the editor #7643

Merged
merged 4 commits into from
Jul 30, 2024

Conversation

merkushin
Copy link
Member

@merkushin merkushin commented Jul 25, 2024

Part of #6351

Some blocks appeared to be untranslated in the editor. Eventually, the investigation gave us an answer: we need to register these blocks in the admin on the backend. We need to be specificn and register even those blocks that don't make much sense on the backend (as they are nested blocks).

Proposed Changes

  • Register blocks to make their translations available in the editor.

Testing Instructions

  1. Switch the website language from English to another one.
  2. Update translations (Dashboard → Updates).
  3. Create a course, open it in the editor.
  4. Open the block inserter and make sure all Sensei LMS blocks (shipped with Sensei LMS plugin!) are translated.
  5. Open Document Overview and check all Sensei blocks are translated (including nested blocks).
  6. Create a lesson and open it in the editor.
  7. Repeat step 4: Open the block inserter and make sure all Sensei LMS blocks (shipped with Sensei LMS plugin!) are translated.
  8. Add a quiz.
  9. Add a question with description, answers, feedback.
  10. Open Document Overview and check all Sensei blocks are translated (including nested blocks).
  11. Publish the course with the lesson.
  12. Go to the course and check all inserted blocks that are supposed to be visible are visible.
  13. Go to the lesson and check all inserted blocks that are supposed to be visible are visible.

Deprecated Code

  • Sensei_Block_Quiz_Question::render_quiz_question—replaced with Sensei_Block_Quiz_Question::render_empty_string

Pre-Merge Checklist

  • PR title and description contain sufficient detail and accurately describe the changes
  • Acceptance criteria is met
  • Decisions are publicly documented
  • Adheres to coding standards (PHP, JavaScript, CSS, HTML)
  • All strings are translatable (without concatenation, handles plurals)
  • Follows our naming conventions (P6rkRX-4oA-p2)
  • Hooks (p6rkRX-1uS-p2) and functions are documented
  • New UIs are responsive and use a mobile-first approach
  • New UIs match the designs
  • Different user privileges (admin, teacher, subscriber) are tested as appropriate
  • Legacy courses (course without blocks) are tested
  • Code is tested on the minimum supported PHP and WordPress versions
  • User interface changes have been tested on the latest versions of Chrome, Firefox and Safari
  • "Needs Documentation" label is added if this change requires updates to documentation
  • Known issues are created as new GitHub issues

@merkushin merkushin added Deprecation This change introduces a deprecation. No Changelog labels Jul 25, 2024
@merkushin merkushin added this to the 4.24.2 milestone Jul 25, 2024
@merkushin merkushin requested a review from a team July 25, 2024 06:24
@merkushin merkushin self-assigned this Jul 25, 2024
Copy link

Test the previous changes of this PR with WordPress Playground.

Copy link

Test the previous changes of this PR with WordPress Playground.

Copy link

Test the previous changes of this PR with WordPress Playground.

Copy link

Test the previous changes of this PR with WordPress Playground.

Copy link

Test the previous changes of this PR with WordPress Playground.

@m1r0 m1r0 requested review from m1r0 and removed request for a team July 26, 2024 12:41
m1r0
m1r0 previously approved these changes Jul 26, 2024
Copy link
Member

@m1r0 m1r0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as described - all blocks are translated! 🎉

@@ -22,21 +22,53 @@ public function __construct() {
Sensei_Blocks::register_sensei_block(
'sensei-lms/quiz-question',
[
'render_callback' => [ $this, 'render_quiz_question' ],
'render_callback' => [ $this, 'render_empty_string' ],
Copy link
Contributor

@Imran92 Imran92 Jul 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought, do you think it's possible to use the __return_empty_string WP function here instead of creating a new function?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks @Imran92!
Updated here: 65b05b6

@merkushin merkushin linked an issue Jul 28, 2024 that may be closed by this pull request
Copy link

Test the previous changes of this PR with WordPress Playground.

m1r0
m1r0 previously approved these changes Jul 29, 2024
Copy link

Test the previous changes of this PR with WordPress Playground.

@merkushin merkushin merged commit 8d78f98 into trunk Jul 30, 2024
23 checks passed
@merkushin merkushin deleted the fix/blocks-translation branch July 30, 2024 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecation This change introduces a deprecation. No Changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some texts are not translated
3 participants