Skip to content

Commit

Permalink
fix: untranslatable strings in Instructor Toolbar #1193 (#1505)
Browse files Browse the repository at this point in the history
  • Loading branch information
jciasenza authored Oct 29, 2024
1 parent 64f92de commit 2d1f893
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/instructor-toolbar/InstructorToolbar.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { getConfig } from '@edx/frontend-platform';
import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n';

import { ALERT_TYPES, AlertList } from '../generic/user-messages';
import Alert from '../generic/user-messages/Alert';
import MasqueradeWidget from './masquerade-widget';
import messages from './messages';
import { useAccessExpirationMasqueradeBanner } from '../alerts/access-expiration-alert';
import { useCourseStartMasqueradeBanner } from '../alerts/course-start-alert';

Expand Down Expand Up @@ -61,7 +63,7 @@ const InstructorToolbar = (props) => {
const urlInsights = getInsightsUrl(courseId);
const urlStudio = getStudioUrl(courseId, unitId);
const [masqueradeErrorMessage, showMasqueradeError] = useState(null);

const { formatMessage } = useIntl();
const accessExpirationMasqueradeBanner = useAccessExpirationMasqueradeBanner(courseId, tab);
const courseStartDateMasqueradeBanner = useCourseStartMasqueradeBanner(courseId, tab);

Expand All @@ -75,17 +77,17 @@ const InstructorToolbar = (props) => {
{(urlStudio || urlInsights) && (
<>
<hr className="border-light" />
<span className="mr-2 mt-1 col-form-label">View course in:</span>
<span className="mr-2 mt-1 col-form-label"><FormattedMessage {...messages.titleViewCourseIn} /></span>
</>
)}
{urlStudio && (
<span className="mx-1 my-1">
<a className="btn btn-inverse-outline-primary" href={urlStudio}>Studio</a>
<a className="btn btn-inverse-outline-primary" href={urlStudio}>{formatMessage(messages.titleStudio)}</a>
</span>
)}
{urlInsights && (
<span className="mx-1 my-1">
<a className="btn btn-inverse-outline-primary" href={urlInsights}>Insights</a>
<a className="btn btn-inverse-outline-primary" href={urlInsights}>{formatMessage(messages.titleInsights)}</a>
</span>
)}
</div>
Expand Down
7 changes: 3 additions & 4 deletions src/instructor-toolbar/masquerade-widget/MasqueradeWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import React, {
Component,
} from 'react';
import PropTypes from 'prop-types';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { injectIntl, intlShape, FormattedMessage } from '@edx/frontend-platform/i18n';
import { Dropdown } from '@openedx/paragon';

import { UserMessagesContext } from '../../generic/user-messages';

import MasqueradeUserNameInput from './MasqueradeUserNameInput';
import MasqueradeWidgetOption from './MasqueradeWidgetOption';
import {
Expand All @@ -21,7 +20,7 @@ class MasqueradeWidget extends Component {
this.courseId = props.courseId;
this.state = {
autoFocus: false,
masquerade: 'Staff',
masquerade: this.props.intl.formatMessage(messages.titleStaff),
active: {},
available: [],
shouldShowUserNameInput: false,
Expand Down Expand Up @@ -128,7 +127,7 @@ class MasqueradeWidget extends Component {
return (
<div className="flex-grow-1">
<div className="row">
<span className="col-auto col-form-label pl-3">View this course as:</span>
<span className="col-auto col-form-label pl-3"><FormattedMessage {...messages.titleViewAs} /></span>
<Dropdown className="flex-shrink-1 mx-1">
<Dropdown.Toggle id="masquerade-widget-toggle" variant="inverse-outline-primary">
{masquerade}
Expand Down
10 changes: 10 additions & 0 deletions src/instructor-toolbar/masquerade-widget/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ const messages = defineMessages({
defaultMessage: 'Masquerade as this user',
description: 'Label for the masquerade user input',
},
titleViewAs: {
id: 'instructor.toolbar.view.as',
defaultMessage: 'View this course as:',
description: 'Button to view this course as',
},
titleStaff: {
id: 'instructor.toolbar.staff',
defaultMessage: 'Staff',
description: 'Button Staff',
},
});

export default messages;
21 changes: 21 additions & 0 deletions src/instructor-toolbar/messages.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { defineMessages } from '@edx/frontend-platform/i18n';

const messages = defineMessages({
titleViewCourseIn: {
id: 'instructor.toolbar.view.course',
defaultMessage: 'View course in:',
description: 'Button to view the course in the studio',
},
titleStudio: {
id: 'instructor.toolbar.studio',
defaultMessage: 'Studio',
description: 'Button to view in studio',
},
titleInsights: {
id: 'instructor.toolbar.insights',
defaultMessage: 'Insights',
description: 'Button Insights',
},
});

export default messages;

0 comments on commit 2d1f893

Please sign in to comment.