Skip to content

Add multi-language authoring support (Web changes) - #2859

Merged
NatSquared merged 4 commits into
DEP-234-authoring-language-switchingfrom
DEP-234/web
Jun 2, 2026
Merged

Add multi-language authoring support (Web changes)#2859
NatSquared merged 4 commits into
DEP-234-authoring-language-switchingfrom
DEP-234/web

Conversation

@NatSquared

Copy link
Copy Markdown
Collaborator

Issue #: 🎟️ DEP-234

Description of changes:

  • Feature Multi-language authoring support
    • Authoring now supports engagement-level multilingual content across sections with translation-aware loading and save paths.
    • In multilingual engagements, the language selector reflects all languages configured during setup and supports switching between authoring languages while preserving page context.
    • Improved language switching UX in authoring to reduce remount/layout shift: state hydration now avoids clearing forms before translated content arrives, preserves details-tab selection, and keeps scroll position during language changes.
    • Added/expanded translation infrastructure for engagement and widget content (including timeline, image, contact, and related widget translation resources), plus supporting migrations and tests.
    • Publishing behavior aligns with requirements: English required sections can be completed/published independently; incomplete non-English content does not block publishing, and incomplete languages are not exposed on the public view.
    • English-only engagements now keep language controls effectively non-interactive/disabled in authoring contexts where no alternate language is configured.

User Guide update ticket (if applicable):

    • Yes, a user guide update ticket has been created. (Link to ticket)
    • No, a user guide update ticket is not required.

Common component changes:

    • Yes, I have updated CONTRIBUTING.md and the docblocks to document any changes to the common components.
    • No, there are no changes to the common components.

@NatSquared
NatSquared requested a review from jareth-whitney May 20, 2026 00:47
@NatSquared
NatSquared changed the base branch from main to DEP-234-authoring-language-switching May 20, 2026 00:50
@codecov-commenter

codecov-commenter commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.28302% with 792 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (DEP-234-authoring-language-switching@bce589f). Learn more about missing BASE report.

Files with missing lines Patch % Lines
.../create/authoring/useAuthoringSectionCompletion.ts 12.94% 148 Missing ⚠️
...gement/admin/create/authoring/AuthoringSideNav.tsx 6.06% 62 Missing ⚠️
.../components/engagement/admin/view/AuthoringTab.tsx 11.47% 54 Missing ⚠️
...ngagement/form/EngagementWidgets/Timeline/Form.tsx 24.24% 50 Missing ⚠️
...s/engagement/form/EngagementWidgets/Image/Form.tsx 4.44% 43 Missing ⚠️
...gagementWidgets/Events/InPersonEventFormDrawer.tsx 35.18% 35 Missing ⚠️
...agementWidgets/Events/VirtualSessionFormDrawer.tsx 33.96% 35 Missing ⚠️
...nts/engagement/form/EngagementWidgets/Map/Form.tsx 18.42% 31 Missing ⚠️
...nt/form/EngagementWidgets/Events/EventsContext.tsx 23.07% 30 Missing ⚠️
.../src/services/widgetService/EventService/index.tsx 18.91% 30 Missing ⚠️
... and 22 more
Additional details and impacted files
@@                           Coverage Diff                           @@
##             DEP-234-authoring-language-switching    #2859   +/-   ##
=======================================================================
  Coverage                                        ?   72.99%           
=======================================================================
  Files                                           ?      522           
  Lines                                           ?    20672           
  Branches                                        ?     1854           
=======================================================================
  Hits                                            ?    15090           
  Misses                                          ?     5572           
  Partials                                        ?       10           
Flag Coverage Δ
web 59.80% <25.28%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
web/src/apiManager/endpoints/index.ts 100.00% <ø> (ø)
web/src/components/common/Input/RichTextArea.tsx 15.09% <100.00%> (ø)
web/src/components/common/RichTextEditor/index.tsx 21.05% <ø> (ø)
...nt/admin/create/authoring/AuthoringNavElements.tsx 100.00% <100.00%> (ø)
...ponents/engagement/widgets/Poll/PollWidgetView.tsx 88.09% <100.00%> (ø)
web/src/components/layout/SideNav/SideNav.tsx 85.18% <100.00%> (ø)
web/src/components/layout/SideNav/UserGuideNav.tsx 93.75% <ø> (ø)
web/src/models/widget.tsx 100.00% <ø> (ø)
web/src/routes/routes.ts 100.00% <ø> (ø)
...ngagement/admin/create/authoring/AuthoringMore.tsx 81.53% <94.11%> (ø)
... and 31 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jareth-whitney jareth-whitney left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wow, this translation layer is basically its own piece of software. Great job implementing it, I'm excited to try it out once it's merged. Take a look at the following:

  • Code optimization (if else/if to ternary, since it's a boolean condition)
  • Consider setting default language as an env variable
  • Consider disabling language select box if there are no options
  • Verification that details tab label number will always match sequential tab number
  • Language list comparison: should it work out of sequence?
  • Separate reused code into its own function
  • 'Complete section' vs 'Completed section'
  • Some mapping ideas to make code less verbose
  • Lowercasing a static value that is already lowercased 'en'
  • Static english string 'Click here to register', is it falling back to this in all languages?
  • Widget form function sharing
  • timelineTranslation value safety
  • Translating values that should stay the same (email and phone number)
  • Any consequences of changing es target?

UPDATE: `${AppConfig.apiUrl}/widgets/widget_id/events/event_id/item/item_id`,
DELETE: `${AppConfig.apiUrl}/widgets/widget_id/events/event_id`,
SORT: `${AppConfig.apiUrl}/widgets/widget_id/events/sort_index`,
GET_ITEM_TRANSLATION: `${AppConfig.apiUrl}/events/event_id/translations/item/event_item_id/language/language_id`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It could be good to have a method that gets an entire list of file translations.

Comment on lines +41 to +44
if (isSingleLanguage === true) {
languageTypeValue = 'single';
} else if (isSingleLanguage === false) {
languageTypeValue = 'multi';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (isSingleLanguage === true) {
languageTypeValue = 'single';
} else if (isSingleLanguage === false) {
languageTypeValue = 'multi';
languageTypeValue = isSingleValue === true ? 'single' : 'multi';

formState: { errors },
} = useFormContext<EngagementUpdateData>();
const { engagement } = useRouteLoaderData('single-engagement') as EngagementLoaderAdminData;
const { languageCode = 'en' } = useParams();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

English should be a safe fallback, otherwise we could define the default language in env variables.


const handleSelectChange = (event: SelectChangeEvent<string>) => {
if (!isSubmitting) {
if (!isSubmitting && !isSwitchingLanguage && !isEnglishOnly) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Preventing a change if English is the only language is a good move. I wonder if we could make that select box disabled when it's single-language, because it looks kind of clunky when you click on it and nothing is in there.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The select box is already disabled when single-language in this commit (line 584) :)

},
}}
renderValue={() => {
const completed = false; // todo: Replace with real "completed" boolean value once it is available.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yay, glad that todo can finally be removed.

(translation) => translation.widget_image_id === imageWidget.id,
);

const nextTranslations = existingTranslation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm noticing that we're doing similar things for different widget forms. If the functions aren't too different to consolidate, sharing any reused code could help keep things compact.

const timelineTranslation = contentTranslations.timeline_widgets.find(
(t) => t.widget_timeline_id === currentTimelineWidget.id,
);
translateTimelineWidget(currentTimelineWidget, timelineTranslation);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should timelineTranslation be checked before it's used?

language_id: number;
name?: string;
title?: string;
email?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't need to translate email and phone number, we should be able to store those on the main contact entry.

Comment thread web/tsconfig.json

/* Language and Environment */
"target": "es2017" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
"target": "es2023" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are there any consequences to changing the es target from 2017 to 2023?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No; this was to support the .toSorted method from es2023 syntax as suggested by SonarCloud

Comment thread CHANGELOG.MD
- Added/expanded translation infrastructure for engagement and widget content (including timeline, image, contact, and related widget translation resources), plus supporting migrations and tests.
- Publishing behavior aligns with requirements: English required sections can be completed/published independently; incomplete non-English content does not block publishing, and incomplete languages are not exposed on the public view.
- English-only engagements now keep language controls effectively non-interactive/disabled in authoring contexts where no alternate language is configured.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very cool stuff Nat, great job on this ticket.

@sonarqubecloud

sonarqubecloud Bot commented Jun 1, 2026

Copy link
Copy Markdown

@NatSquared
NatSquared merged commit 3b73913 into DEP-234-authoring-language-switching Jun 2, 2026
6 checks passed
@NatSquared
NatSquared deleted the DEP-234/web branch June 2, 2026 23:12
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.

3 participants