Repository navigation
tiny_teamsmeeting: fix result.php always rendering in English, add missing language strings - #3522
Lai Wei (weilai-irl) wants to merge 4 commits into
Conversation
result.php runs with NO_MOODLE_COOKIES so it never has a real session, and $USER is never populated with the callback token's user. Every get_string() call in the success/details screen therefore fell back to the site's default language regardless of what the user had selected when they opened the dialog. Embed the resolved current_language() in the signed callback token (generate()) and use it to force_current_language() in result.php, rather than relying on the user's mdl_user.lang profile default, which is routinely overridden per-session (e.g. by the language menu) and does not reflect what the user actually saw.
…app-supported languages The Polish translation was missing several strings added since the plugin's dialog was rewritten (iframe_add_link, iframe_meeting_details, iframe_new_window_label, teamsmeeting:add, tiny_edit_modal_title, and the privacy:metadata:tiny_teamsmeeting block), had iframe_go_to_meeting left untranslated, and carried six obsolete keys from the old dialog-based UI that no longer exist in the English source. Also add lang/<code>/tiny_teamsmeeting.php for every language the Microsoft Teams meetings app (msteams-app-lms-meetings) supports, so the plugin's own UI and the app's UI are never showing two different languages: ar, bg, cs, cy, da, de, es, es_mx, fi, fr, fr_ca, he, is, it, ja, ko, nb, nl, nn, pt, pt_br, ru, sv, th, tr, zh_cn, zh_tw. Each file has exact key parity with the English source.
There was a problem hiding this comment.
🟡 Changes recommended
The new PHPUnit test currently asserts a non-standard language code ('xx') which is likely not installed/accepted by current_language() in typical Moodle test environments, risking failing or flaky CI.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR fixes the TinyMCE Teams Meeting plugin’s callback/result screen always rendering in the site default language (because result.php runs with NO_MOODLE_COOKIES and has no real session). It does so by embedding the resolved current_language() into the signed callback token and forcing that language in result.php, and it expands language-pack coverage so the plugin UI can match the Meetings app UI.
Changes:
- Embed the effective language (
current_language()) into the signed token payload and expose it viatoken::validate_lang(). - Force the token’s language in
result.phpto ensureget_string()uses the same language the user saw when opening the dialog. - Add/refresh
tiny_teamsmeetinglanguage packs (new packs for many languages; update Polish pack).
File summaries
| File | Description |
|---|---|
| lib/editor/tiny/plugins/teamsmeeting/classes/token.php | Add language segment to signed token payload and new validate_lang() helper. |
| lib/editor/tiny/plugins/teamsmeeting/result.php | Force current language based on validated token language for cookie-less iframe callback flow. |
| lib/editor/tiny/plugins/teamsmeeting/tests/token_test.php | Add unit tests for the new language-in-token behavior and backward compatibility. |
| lib/editor/tiny/plugins/teamsmeeting/lang/pl/tiny_teamsmeeting.php | Update Polish strings: add missing keys and remove obsolete ones. |
| lib/editor/tiny/plugins/teamsmeeting/lang/ar/tiny_teamsmeeting.php | Add Arabic translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/bg/tiny_teamsmeeting.php | Add Bulgarian translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/cs/tiny_teamsmeeting.php | Add Czech translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/cy/tiny_teamsmeeting.php | Add Welsh translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/da/tiny_teamsmeeting.php | Add Danish translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/de/tiny_teamsmeeting.php | Add German translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/es/tiny_teamsmeeting.php | Add Spanish translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/es_mx/tiny_teamsmeeting.php | Add Spanish (Mexico) translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/fi/tiny_teamsmeeting.php | Add Finnish translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/fr/tiny_teamsmeeting.php | Add French translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/fr_ca/tiny_teamsmeeting.php | Add French (Canada) translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/he/tiny_teamsmeeting.php | Add Hebrew translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/is/tiny_teamsmeeting.php | Add Icelandic translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/it/tiny_teamsmeeting.php | Add Italian translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/ja/tiny_teamsmeeting.php | Add Japanese translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/ko/tiny_teamsmeeting.php | Add Korean translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/nb/tiny_teamsmeeting.php | Add Norwegian Bokmål translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/nl/tiny_teamsmeeting.php | Add Dutch translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/nn/tiny_teamsmeeting.php | Add Norwegian Nynorsk translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/pt/tiny_teamsmeeting.php | Add Portuguese translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/pt_br/tiny_teamsmeeting.php | Add Portuguese (Brazil) translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/ru/tiny_teamsmeeting.php | Add Russian translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/sv/tiny_teamsmeeting.php | Add Swedish translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/th/tiny_teamsmeeting.php | Add Thai translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/tr/tiny_teamsmeeting.php | Add Turkish translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/zh_cn/tiny_teamsmeeting.php | Add Simplified Chinese translation file with key parity to English. |
| lib/editor/tiny/plugins/teamsmeeting/lang/zh_tw/tiny_teamsmeeting.php | Add Traditional Chinese translation file with key parity to English. |
Review details
- Files reviewed: 31/31 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…decoding test_validate_lang_returns_the_language_active_when_the_token_was_issued set the test user's lang via create_user(), which runs it through PARAM_LANG cleaning and silently falls back to the site default for any pack not installed on the test site - failing in CI. Set it directly on $USER after setUser() instead, bypassing both that and the equivalent cleaning in \core\session\manager::set_user(). token::verify() also accepted an unbounded-length token and ran ctype_xdigit()/hex2bin()/preg_match() - all proportional to input size - on it before any authentication check (result.php runs with NO_MOODLE_COOKIES). Add a generous MAX_LENGTH guard, checked via strlen() first, to reject oversized input cheaply; real tokens never approach it.
… and edit flow The meeting dialog's own locale param (sent to the external Teams app) was computed from $SESSION->lang/$USER->lang only, never consulting a course-forced language. Use current_language() instead, which already resolves that correctly on the real course page. The edit-existing-meeting AJAX endpoint generates a fresh callback token via token::generate(), which also calls current_language() - but that endpoint runs inside Moodle's generic AJAX dispatcher, where $PAGE->course is always the frontpage course, so a course-forced language can never be seen there regardless of which course the meeting actually belongs to. token::generate() now accepts an optional language override, and get_meeting_details::execute() resolves the correct language explicitly against the meeting's own stored context and passes it through.
/tiny_teamsmeeting.php for every language the Microsoft Teams meetings app (msteams-app-lms-meetings) supports, so the plugin's own UI and the app's UI are never showing two different languages: ar, bg, cs, cy, da, de, es, es_mx, fi, fr, fr_ca, he, is, it, ja, ko, nb, nl, nn, pt, pt_br, ru, sv, th, tr, zh_cn, zh_tw. Each file has exact key parity with the English source.