Skip to content

Commit 2d1f893

Browse files
authored
fix: untranslatable strings in Instructor Toolbar #1193 (#1505)
1 parent 64f92de commit 2d1f893

File tree

4 files changed

+40
-8
lines changed

4 files changed

+40
-8
lines changed

src/instructor-toolbar/InstructorToolbar.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import React, { useEffect, useState } from 'react';
22
import PropTypes from 'prop-types';
33
import { getConfig } from '@edx/frontend-platform';
4+
import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
45

56
import { ALERT_TYPES, AlertList } from '../generic/user-messages';
67
import Alert from '../generic/user-messages/Alert';
78
import MasqueradeWidget from './masquerade-widget';
9+
import messages from './messages';
810
import { useAccessExpirationMasqueradeBanner } from '../alerts/access-expiration-alert';
911
import { useCourseStartMasqueradeBanner } from '../alerts/course-start-alert';
1012

@@ -61,7 +63,7 @@ const InstructorToolbar = (props) => {
6163
const urlInsights = getInsightsUrl(courseId);
6264
const urlStudio = getStudioUrl(courseId, unitId);
6365
const [masqueradeErrorMessage, showMasqueradeError] = useState(null);
64-
66+
const { formatMessage } = useIntl();
6567
const accessExpirationMasqueradeBanner = useAccessExpirationMasqueradeBanner(courseId, tab);
6668
const courseStartDateMasqueradeBanner = useCourseStartMasqueradeBanner(courseId, tab);
6769

@@ -75,17 +77,17 @@ const InstructorToolbar = (props) => {
7577
{(urlStudio || urlInsights) && (
7678
<>
7779
<hr className="border-light" />
78-
<span className="mr-2 mt-1 col-form-label">View course in:</span>
80+
<span className="mr-2 mt-1 col-form-label"><FormattedMessage {...messages.titleViewCourseIn} /></span>
7981
</>
8082
)}
8183
{urlStudio && (
8284
<span className="mx-1 my-1">
83-
<a className="btn btn-inverse-outline-primary" href={urlStudio}>Studio</a>
85+
<a className="btn btn-inverse-outline-primary" href={urlStudio}>{formatMessage(messages.titleStudio)}</a>
8486
</span>
8587
)}
8688
{urlInsights && (
8789
<span className="mx-1 my-1">
88-
<a className="btn btn-inverse-outline-primary" href={urlInsights}>Insights</a>
90+
<a className="btn btn-inverse-outline-primary" href={urlInsights}>{formatMessage(messages.titleInsights)}</a>
8991
</span>
9092
)}
9193
</div>

src/instructor-toolbar/masquerade-widget/MasqueradeWidget.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import React, {
22
Component,
33
} from 'react';
44
import PropTypes from 'prop-types';
5-
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
5+
import { injectIntl, intlShape, FormattedMessage } from '@edx/frontend-platform/i18n';
66
import { Dropdown } from '@openedx/paragon';
77

88
import { UserMessagesContext } from '../../generic/user-messages';
9-
109
import MasqueradeUserNameInput from './MasqueradeUserNameInput';
1110
import MasqueradeWidgetOption from './MasqueradeWidgetOption';
1211
import {
@@ -21,7 +20,7 @@ class MasqueradeWidget extends Component {
2120
this.courseId = props.courseId;
2221
this.state = {
2322
autoFocus: false,
24-
masquerade: 'Staff',
23+
masquerade: this.props.intl.formatMessage(messages.titleStaff),
2524
active: {},
2625
available: [],
2726
shouldShowUserNameInput: false,
@@ -128,7 +127,7 @@ class MasqueradeWidget extends Component {
128127
return (
129128
<div className="flex-grow-1">
130129
<div className="row">
131-
<span className="col-auto col-form-label pl-3">View this course as:</span>
130+
<span className="col-auto col-form-label pl-3"><FormattedMessage {...messages.titleViewAs} /></span>
132131
<Dropdown className="flex-shrink-1 mx-1">
133132
<Dropdown.Toggle id="masquerade-widget-toggle" variant="inverse-outline-primary">
134133
{masquerade}

src/instructor-toolbar/masquerade-widget/messages.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ const messages = defineMessages({
1616
defaultMessage: 'Masquerade as this user',
1717
description: 'Label for the masquerade user input',
1818
},
19+
titleViewAs: {
20+
id: 'instructor.toolbar.view.as',
21+
defaultMessage: 'View this course as:',
22+
description: 'Button to view this course as',
23+
},
24+
titleStaff: {
25+
id: 'instructor.toolbar.staff',
26+
defaultMessage: 'Staff',
27+
description: 'Button Staff',
28+
},
1929
});
2030

2131
export default messages;

src/instructor-toolbar/messages.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { defineMessages } from '@edx/frontend-platform/i18n';
2+
3+
const messages = defineMessages({
4+
titleViewCourseIn: {
5+
id: 'instructor.toolbar.view.course',
6+
defaultMessage: 'View course in:',
7+
description: 'Button to view the course in the studio',
8+
},
9+
titleStudio: {
10+
id: 'instructor.toolbar.studio',
11+
defaultMessage: 'Studio',
12+
description: 'Button to view in studio',
13+
},
14+
titleInsights: {
15+
id: 'instructor.toolbar.insights',
16+
defaultMessage: 'Insights',
17+
description: 'Button Insights',
18+
},
19+
});
20+
21+
export default messages;

0 commit comments

Comments
 (0)