Skip to content

tiny_teamsmeeting: fix result.php always rendering in English, add missing language strings - #3518

Open
Lai Wei (weilai-irl) wants to merge 4 commits into
wip-137556-m405from
wip-138069-m405
Open

Lai Wei (weilai-irl) wants to merge 4 commits into
wip-137556-m405from
wip-138069-m405

Conversation

@weilai-irl

Copy link
Copy Markdown
Collaborator
  • 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.
  • 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//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.

Copilot AI lite review requested due to automatic review settings September 15, 2026 15:23
@weilai-irl Lai Wei (weilai-irl) self-assigned this Sep 15, 2026
@weilai-irl Lai Wei (weilai-irl) added this to the 2026-04 milestone Sep 15, 2026
@weilai-irl
Lai Wei (weilai-irl) added this pull request to stack #3519 September 15, 2026 15:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

There is a verified PHP warning bug in validate_lang() for invalid tokens and the new unit test hard-codes a likely-nonexistent language code (xx), making CI failures likely.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR updates the tiny_teamsmeeting TinyMCE plugin callback flow so that the result.php success/details screen renders in the same language the user saw when opening the dialog (despite NO_MOODLE_COOKIES), and expands/aligns plugin language packs to avoid mixed-language UI between Moodle and the Microsoft meetings app.

Changes:

  • Embed current_language() into the signed callback token and apply it in result.php via force_current_language().
  • Add validate_lang() and corresponding PHPUnit coverage for language-carrying (and legacy) tokens.
  • Add/refresh multiple lang/<code>/tiny_teamsmeeting.php packs (and update Polish strings) to match the English key set.
File summaries
File Description
lib/editor/tiny/plugins/teamsmeeting/classes/token.php Adds language segment to token payload and exposes validate_lang() / shared verify().
lib/editor/tiny/plugins/teamsmeeting/result.php Forces current language from the signed token when rendering the callback UI.
lib/editor/tiny/plugins/teamsmeeting/tests/token_test.php Adds tests for language-bearing tokens and legacy/invalid token behavior.
lib/editor/tiny/plugins/teamsmeeting/lang/ar/tiny_teamsmeeting.php Adds Arabic language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/bg/tiny_teamsmeeting.php Adds Bulgarian language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/cs/tiny_teamsmeeting.php Adds Czech language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/cy/tiny_teamsmeeting.php Adds Welsh language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/da/tiny_teamsmeeting.php Adds Danish language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/de/tiny_teamsmeeting.php Adds German language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/es/tiny_teamsmeeting.php Adds Spanish language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/es_mx/tiny_teamsmeeting.php Adds Spanish (Mexico) language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/fi/tiny_teamsmeeting.php Adds Finnish language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/fr/tiny_teamsmeeting.php Adds French language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/fr_ca/tiny_teamsmeeting.php Adds French (Canada) language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/he/tiny_teamsmeeting.php Adds Hebrew language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/is/tiny_teamsmeeting.php Adds Icelandic language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/it/tiny_teamsmeeting.php Adds Italian language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/ja/tiny_teamsmeeting.php Adds Japanese language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/ko/tiny_teamsmeeting.php Adds Korean language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/nb/tiny_teamsmeeting.php Adds Norwegian Bokmål language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/nl/tiny_teamsmeeting.php Adds Dutch language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/nn/tiny_teamsmeeting.php Adds Norwegian Nynorsk language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/pl/tiny_teamsmeeting.php Updates Polish strings (adds missing keys, removes obsolete ones).
lib/editor/tiny/plugins/teamsmeeting/lang/pt/tiny_teamsmeeting.php Adds Portuguese language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/pt_br/tiny_teamsmeeting.php Adds Portuguese (Brazil) language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/ru/tiny_teamsmeeting.php Adds Russian language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/sv/tiny_teamsmeeting.php Adds Swedish language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/th/tiny_teamsmeeting.php Adds Thai language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/tr/tiny_teamsmeeting.php Adds Turkish language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/zh_cn/tiny_teamsmeeting.php Adds Simplified Chinese language strings matching English keys.
lib/editor/tiny/plugins/teamsmeeting/lang/zh_tw/tiny_teamsmeeting.php Adds Traditional Chinese language strings matching English keys.
Review details
  • Files reviewed: 31/31 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/editor/tiny/plugins/teamsmeeting/tests/token_test.php Outdated
Comment thread lib/editor/tiny/plugins/teamsmeeting/classes/token.php
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.
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants