Skip to content

Commit 5e07c76

Browse files
authored
fix: [CHTC-121] fix course home page missing translations (#65)
* fix: [CHTC-121] fix course home page missing translations * fix: [CHTC-121] correct the comments
1 parent 8356505 commit 5e07c76

File tree

3 files changed

+47
-9
lines changed

3 files changed

+47
-9
lines changed

src/instructor-toolbar/InstructorToolbar.jsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
22
import PropTypes from 'prop-types';
33
import { getConfig } from '@edx/frontend-platform';
44

5+
import { FormattedMessage } from '@edx/frontend-platform/i18n';
56
import { ALERT_TYPES, AlertList } from '../generic/user-messages';
67
import Alert from '../generic/user-messages/Alert';
78
import MasqueradeWidget from './masquerade-widget';
@@ -75,17 +76,23 @@ const InstructorToolbar = (props) => {
7576
{(urlStudio || urlInsights) && (
7677
<>
7778
<hr className="border-light" />
78-
<span className="mr-2 mt-1 col-form-label">View course in:</span>
79+
<span className="mr-2 mt-1 col-form-label">
80+
<FormattedMessage id="instructorToolbar.viewCourseIn.label" defaultMessage="View course in:" />
81+
</span>
7982
</>
8083
)}
8184
{urlStudio && (
8285
<span className="mx-1 my-1">
83-
<a className="btn btn-inverse-outline-primary" href={urlStudio}>Studio</a>
86+
<a className="btn btn-inverse-outline-primary" href={urlStudio}>
87+
<FormattedMessage id="instructorToolbar.studio.link" defaultMessage="Studio" />
88+
</a>
8489
</span>
8590
)}
8691
{urlInsights && (
8792
<span className="mx-1 my-1">
88-
<a className="btn btn-inverse-outline-primary" href={urlInsights}>Insights</a>
93+
<a className="btn btn-inverse-outline-primary" href={urlInsights}>
94+
<FormattedMessage id="instructorToolbar.insights.link" defaultMessage="Insights" />
95+
</a>
8996
</span>
9097
)}
9198
</div>

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class MasqueradeWidget extends Component {
2121
this.courseId = props.courseId;
2222
this.state = {
2323
autoFocus: false,
24-
masquerade: 'Staff',
24+
masquerade: this.props.intl.formatMessage(messages.staffLabel),
2525
options: [],
2626
shouldShowUserNameInput: false,
2727
masqueradeUsername: null,
@@ -36,7 +36,7 @@ class MasqueradeWidget extends Component {
3636
// This was explicitly denied by the backend;
3737
// assume it's disabled/unavailable.
3838
// eslint-disable-next-line no-console
39-
this.onError('Unable to get masquerade options');
39+
this.onError(this.props.intl.formatMessage(messages.optionsError));
4040
}
4141
}).catch((response) => {
4242
// There's not much we can do to recover;
@@ -71,7 +71,7 @@ class MasqueradeWidget extends Component {
7171
toggle(show) {
7272
this.setState(prevState => ({
7373
autoFocus: true,
74-
masquerade: 'Specific Student...',
74+
masquerade: this.props.intl.formatMessage(messages.specificStudentLabel),
7575
shouldShowUserNameInput: show === undefined ? !prevState.shouldShowUserNameInput : show,
7676
}));
7777
}
@@ -96,14 +96,14 @@ class MasqueradeWidget extends Component {
9696
if (active.userName) {
9797
this.setState({
9898
autoFocus: false,
99-
masquerade: 'Specific Student...',
99+
masquerade: this.props.intl.formatMessage(messages.specificStudentLabel),
100100
masqueradeUsername: active.userName,
101101
shouldShowUserNameInput: true,
102102
});
103103
} else if (active.groupName) {
104104
this.setState({ masquerade: active.groupName });
105105
} else if (active.role === 'student') {
106-
this.setState({ masquerade: 'Learner' });
106+
this.setState({ masquerade: this.props.intl.formatMessage(messages.learnerLabel) });
107107
}
108108
return options;
109109
}
@@ -117,10 +117,11 @@ class MasqueradeWidget extends Component {
117117
masqueradeUsername,
118118
} = this.state;
119119
const specificLearnerInputText = this.props.intl.formatMessage(messages.placeholder);
120+
const viewThisCourseAsText = this.props.intl.formatMessage(messages.viewThisCourseAsLabel);
120121
return (
121122
<div className="flex-grow-1">
122123
<div className="row">
123-
<span className="col-auto col-form-label pl-3">View this course as:</span>
124+
<span className="col-auto col-form-label pl-3">{viewThisCourseAsText}</span>
124125
<Dropdown className="flex-shrink-1 mx-1">
125126
<Dropdown.Toggle id="masquerade-widget-toggle" variant="inverse-outline-primary">
126127
{masquerade}

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,36 @@ const messages = defineMessages({
1616
defaultMessage: 'Masquerade as this user',
1717
description: 'Label for the masquerade user input',
1818
},
19+
viewThisCourseAsLabel: {
20+
id: 'masquerade-widget.viewThisCourseAs.label',
21+
defaultMessage: 'View this course as:',
22+
description: 'Label for masquerade dropdown in the instructor toolbar',
23+
},
24+
staffLabel: {
25+
id: 'masquerade-widget.role.staff',
26+
defaultMessage: 'Staff',
27+
description: 'Masquerade dropdown selected label for Staff role',
28+
},
29+
learnerLabel: {
30+
id: 'masquerade-widget.role.learner',
31+
defaultMessage: 'Learner',
32+
description: 'Masquerade dropdown selected label for Learner role',
33+
},
34+
specificStudentLabel: {
35+
id: 'masquerade-widget.role.specificStudent',
36+
defaultMessage: 'Specific Student...',
37+
description: 'Masquerade dropdown selected label when viewing specific student',
38+
},
39+
myCertificateLabel: {
40+
id: 'masquerade-widget.role.myCertificate',
41+
defaultMessage: 'My certificate',
42+
description: 'Masquerade dropdown label for the certificate view option',
43+
},
44+
optionsError: {
45+
id: 'masquerade-widget.options.error',
46+
defaultMessage: 'Unable to get masquerade options',
47+
description: 'Error shown when fetching masquerade options fails',
48+
},
1949
});
2050

2151
export default messages;

0 commit comments

Comments
 (0)