Skip to content

Add multi-language authoring support (API changes) - #2857

Merged
NatSquared merged 5 commits into
DEP-234-authoring-language-switchingfrom
DEP-234/api-changes
Jun 1, 2026
Merged

Add multi-language authoring support (API changes)#2857
NatSquared merged 5 commits into
DEP-234-authoring-language-switchingfrom
DEP-234/api-changes

Conversation

@NatSquared

Copy link
Copy Markdown
Collaborator

Issue #: 🎟️ DEP-234

Description of changes:
Updated the DEP API to add support for:

  • Bulk translation updates/fetching
  • Full widget translation
  • Added tests to ensure functionality
    in anticipation of frontend changes for DEP-234

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 19, 2026 20:12
@codecov-commenter

codecov-commenter commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.07989% with 239 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.88%. Comparing base (475ae73) to head (5d7c69f).

Files with missing lines Patch % Lines
api/src/api/services/widget_translation_service.py 65.12% 68 Missing ⚠️
api/src/api/resources/contact_translation.py 42.16% 48 Missing ⚠️
...pi/src/api/services/contact_translation_service.py 37.50% 25 Missing ⚠️
api/src/api/models/contact_translation.py 56.75% 16 Missing ⚠️
api/src/api/resources/widget_image_translation.py 44.82% 16 Missing ⚠️
...c/api/services/widget_image_translation_service.py 41.66% 14 Missing ⚠️
api/src/api/services/engagement_service.py 81.96% 11 Missing ⚠️
...src/api/services/engagement_details_tab_service.py 23.07% 10 Missing ⚠️
api/src/api/models/widget_translation.py 78.37% 8 Missing ⚠️
...rc/api/resources/engagement_content_translation.py 86.66% 8 Missing ⚠️
... and 4 more
Additional details and impacted files
@@                           Coverage Diff                            @@
##           DEP-234-authoring-language-switching    #2857      +/-   ##
========================================================================
- Coverage                                 75.17%   74.88%   -0.29%     
========================================================================
  Files                                       517      527      +10     
  Lines                                     20067    20696     +629     
  Branches                                   1723     1723              
========================================================================
+ Hits                                      15085    15499     +414     
- Misses                                     4973     5188     +215     
  Partials                                      9        9              
Flag Coverage Δ
api 84.24% <67.07%> (-1.08%) ⬇️

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

Files with missing lines Coverage Δ
api/src/api/constants/widget.py 100.00% <ø> (ø)
api/src/api/models/__init__.py 100.00% <100.00%> (ø)
api/src/api/models/engagement.py 80.00% <ø> (-1.09%) ⬇️
api/src/api/models/engagement_translation.py 97.26% <100.00%> (+0.33%) ⬆️
api/src/api/models/widget_image_translation.py 100.00% <100.00%> (ø)
api/src/api/models/widget_timeline_translation.py 100.00% <100.00%> (ø)
api/src/api/resources/__init__.py 100.00% <100.00%> (ø)
api/src/api/resources/engagement_translation.py 98.91% <100.00%> (+0.01%) ⬆️
api/src/api/schemas/contact_translation_schema.py 100.00% <100.00%> (ø)
api/src/api/schemas/engagement.py 96.07% <100.00%> (-0.65%) ⬇️
... and 18 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.

Great job implementing a complex piece! Nothing blocking, just check out the following:

  • Translation of email and phone_number, is it necessary?
  • Definition of default language code, should it be defined in env variables?
  • Questions regarding image translations, is it just for the alt tag?

batch_op.drop_column('subscribe_section_description')
batch_op.drop_column('subscribe_section_heading')
batch_op.drop_column('feedback_body')
batch_op.drop_column('feedback_heading')

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 that is a very complex migration. It looks like we're decoupling some of the english strings from the engagement, which I guess makes sense. English is a language like any other, so we can treat the english strings with equal importance and structure.

batch_op.drop_column('subscribe_consent_message')
batch_op.drop_column('subscribe_section_description')
batch_op.drop_column('subscribe_section_heading')
batch_op.drop_column('feedback_body')

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.

Thanks for creating tables for other translations other than the engagement.


WHO_IS_LISTENING = 1
DOCUMENTS = 2
SUBSCRIBE = 4

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.

Oops I must have missed that one, thanks for removing it.

)
name = db.Column(db.String(50), nullable=True)
title = db.Column(db.String(50), nullable=True)
email = db.Column(db.String(50), nullable=True)

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 seems like we shouldn't need to translate email or phone_number but perhaps this is just an organization thing.

'widget_documents_id', 'language_id',
unique=True,
postgresql_where=text('widget_documents_id IS NOT NULL'),
),

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.

The indexes are a nice touch and should save us from conflicting data.


@api.route('/')
class WidgetImageTranslationResource(Resource):
"""Resource for creating widget image translations."""

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.

What do we need to change about the widget image? Is it the alt tag?

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.

yes; the alt text should be translatable for accessibility in other languages

subscribe_consent_message = fields.Str(data_key='subscribe_consent_message')
sponsor_name = fields.Str(data_key='sponsor_name')
more_engagements_heading = fields.Str(data_key='more_engagements_heading')
languages = fields.List(fields.Str(), data_key='languages', load_only=True)

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.

Nice, so the languages are stored within the engagement now. That was one issue before, I believe they were being stored by tenant.

"""Engagement management service."""

otherdateformat = '%Y-%m-%d'
default_language_code = 'en'

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.

Don't we have an env variable for this?

@sonarqubecloud

sonarqubecloud Bot commented Jun 1, 2026

Copy link
Copy Markdown

@NatSquared
NatSquared merged commit bce589f into DEP-234-authoring-language-switching Jun 1, 2026
6 checks passed
@NatSquared
NatSquared deleted the DEP-234/api-changes branch June 1, 2026 19:14
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