Skip to content

Conversation

@jomcarvajal
Copy link
Contributor

@jomcarvajal jomcarvajal commented Dec 24, 2025

@TomWoodward TomWoodward temporarily deployed to rex-web-core-1455-vb36xzfvxvug December 24, 2025 13:59 Inactive
@TomWoodward TomWoodward temporarily deployed to rex-web-core-1455-vb36xzfvxvug December 24, 2025 14:09 Inactive
@TomWoodward TomWoodward temporarily deployed to rex-web-core-1455-vb36xzfvxvug December 24, 2025 14:26 Inactive
@TomWoodward TomWoodward temporarily deployed to rex-web-core-1455-vb36xzfvxvug December 24, 2025 14:58 Inactive
@TomWoodward TomWoodward temporarily deployed to rex-web-core-1455-vb36xzfvxvug December 24, 2025 15:10 Inactive
@TomWoodward TomWoodward temporarily deployed to rex-web-core-1455-vb36xzfvxvug December 24, 2025 15:41 Inactive
@jomcarvajal jomcarvajal marked this pull request as ready for review December 24, 2025 15:54
@jomcarvajal jomcarvajal requested a review from a team as a code owner December 24, 2025 15:54
@jomcarvajal jomcarvajal requested a review from Dantemss December 24, 2025 15:54
@Dantemss Dantemss requested a review from Copilot January 5, 2026 12:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds missing translations for "Content Warning" text across English, Spanish, and Polish locales. The changes implement internationalization support by introducing a new translation key i18n:content-warning:heading:aria-label and updating the LoginGate and ContentWarning components to use translated text instead of hardcoded English strings.

  • Added translation key i18n:content-warning:heading:aria-label to all three language files (en, es, pl)
  • Updated createIntl function to support optional message overrides for testing purposes
  • Modified LoginGate and ContentWarning components to use the internationalization API
  • Updated corresponding test files to accommodate the internationalization changes

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/app/messages/en/messages.json Added English translation "Content Warning" for the new translation key
src/app/messages/es/messages.json Added Spanish translation "Advertencia de contenido" for the new translation key
src/app/messages/pl/messages.json Added Polish translation "Ostrzeżenie o treści" for the new translation key
src/app/messages/createIntl.ts Enhanced to accept optional newMessages parameter for test message overrides
src/app/content/components/LoginGate.tsx Replaced hardcoded "Content Warning" string with internationalized version using useIntl
src/app/content/components/ContentWarning.tsx Replaced hardcoded "Content warning" string with internationalized version using useIntl
src/app/content/components/LoginGate.spec.tsx Updated test to mock useIntl and added IntlProvider setup
src/app/content/components/ContentWarning.spec.tsx Updated tests to mock useIntl and added IntlProvider setup
src/app/content/highlights/components/Highlights.spec.tsx Updated tests to use new newMessages parameter of createIntl function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<>
{children}
<Modal heading='Content Warning'>
<Modal heading={intl.formatMessage({ id: 'i18n:content-warning:heading:aria-label' })}>
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The Modal component's heading prop is passed to FormattedMessage which expects a translation key, not a translated string. Passing intl.formatMessage({ id: 'i18n:content-warning:heading:aria-label' }) will cause the Modal to treat the translated text as a key and attempt to translate it again. Instead, pass the translation key directly: heading='i18n:content-warning:heading:aria-label' and remove the useIntl hook usage.

Copilot uses AI. Check for mistakes.
import { useSelector } from 'react-redux';
import styled from 'styled-components/macro';
import ModalWithScrollLock from '../../components/Modal';
import { useIntl } from 'react-intl';
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The useIntl import is no longer needed since the Modal component expects the translation key directly, not a pre-translated string. Remove this import.

Copilot uses AI. Check for mistakes.
book,
children,
}: React.PropsWithChildren<{ book: Book }>) {
const intl = useIntl();
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The intl variable initialized with useIntl() is no longer needed since the Modal component expects the translation key directly. Remove this line.

Copilot uses AI. Check for mistakes.
}

export default memoize(async(loc: string) => {
export default memoize(async(loc: string, newMessages?: Record<string, string>) => {
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The memoize function from lodash/fp only uses the first argument as the cache key by default. This means calls like createIntl('en') and createIntl('en', { 'key': 'value' }) will return the same cached intl instance, ignoring the newMessages parameter on subsequent calls. If newMessages is intended to be different across calls with the same locale, consider using a custom resolver for memoization or not memoizing when newMessages is provided.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

newMessages are only meant for tests, right? Maybe call them testMessages or testOverrides.

You can use the memoize function from @openstax/ts-utils to avoid the quirk of lodash's only caching based on the first argument.

Comment on lines +11 to +16
jest.mock('react-intl', () => ({
...jest.requireActual('react-intl'),
useIntl: () => ({
formatMessage: ({ id }: any) => id,
}),
}));
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The mock for useIntl makes the actual createIntl and RawIntlProvider usage in the test ineffective. Since useIntl is mocked to simply return the id, the intl instance created on line 25 is not used by the component. Consider either removing the mock to test with real translations, or removing the createIntl and RawIntlProvider setup since they're not being utilized.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

I don't quite get what copilot means here but maybe it's related to what it said about the modal component in the first few comments.

Comment on lines +10 to +15
jest.mock('react-intl', () => ({
...jest.requireActual('react-intl'),
useIntl: () => ({
formatMessage: ({ id }: any) => id,
}),
}));
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

The mock for useIntl makes the actual createIntl and RawIntlProvider usage in these tests ineffective. Since useIntl is mocked to simply return the id, the intl instances created in the tests are not used by the components. Consider either removing the mock to test with real translations, or removing the createIntl and RawIntlProvider setup since they're not being utilized.

Copilot uses AI. Check for mistakes.
"i18n:toolbar:textresizer:button:increase:aria-label": "Zwiększ rozmiar tekstu",
"i18n:toolbar:textresizer:popup:heading": "Rozmiar tekstu"
"i18n:toolbar:textresizer:popup:heading": "Rozmiar tekstu",
"i18n:content-warning:heading:aria-label": "Ostrzeżenie o treści"
Copy link
Member

Choose a reason for hiding this comment

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

This translation should probably be confirmed by our contact at Katalyst

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.

4 participants