Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛(frontend) fix Enroll now translation #2246

Conversation

igobranco
Copy link
Collaborator

When using an external LMS, the CTA Enroll now on course runs isn't being translated.

Screenshot on french, is still showing the Enroll now on english.
image

After applying this fix and translate it on src/frontend/i18n/locales/fr-FR.json:

"components.SyllabusCourseRun.enroll": {
    "description": "CTA for users who can enroll in the course run or could enroll if they logged in.",
    "message": "S’inscrire maintenant"
  },

image

@igobranco igobranco added the bug label Jan 23, 2024
@igobranco igobranco self-assigned this Jan 23, 2024
@igobranco igobranco force-pushed the igobranco/fix-enroll-now-external-platform branch 3 times, most recently from f1ff478 to b4fb3df Compare January 23, 2024 17:13
When using an external LMS, the CTA Enroll now on course runs
isn't being translated.
@igobranco igobranco force-pushed the igobranco/fix-enroll-now-external-platform branch from b4fb3df to 042d91b Compare January 23, 2024 17:21
Copy link
Member

@jbpenrath jbpenrath left a comment

Choose a reason for hiding this comment

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

Those labels should have been translated by the backend 🤔

ONGOING_OPEN: _("enroll now"),
FUTURE_OPEN: _("enroll now"),

@igobranco
Copy link
Collaborator Author

@jbpenrath I think it doesn't come from backend, but from the frontend.
The CourseState is calculated on the frontend and not on the backend.
So I think it just need to translate the call_to_action Strings from the computeState function:

export const computeState = (courseRun: CourseRun): CourseState => {
if (!courseRun.start || !courseRun.enrollment_start) {
return {
priority: Priority.TO_BE_SCHEDULED,
datetime: null,
call_to_action: null,
text: CourseStateTextEnum.TO_BE_SCHEDULED,
};
}
const now = new Date();
const end = courseRun.end ? new Date(courseRun.end) : MAX_DATE;
const enrollmentEnd = courseRun.enrollment_end ? new Date(courseRun.enrollment_end) : MAX_DATE;
if (new Date(courseRun.start) < now) {
if (end > now) {
if (enrollmentEnd > now) {
return {
priority: Priority.ONGOING_OPEN,
datetime: enrollmentEnd.toISOString(),
call_to_action: 'enroll now',
text: CourseStateTextEnum.ON_GOING,
};
}
return {
priority: Priority.ONGOING_CLOSED,
datetime: null,
call_to_action: null,
text: CourseStateTextEnum.ON_GOING,
};
}
if (new Date(courseRun.enrollment_start) < now && now < enrollmentEnd) {
return {
priority: Priority.ARCHIVED_OPEN,
datetime: enrollmentEnd.toISOString(),
call_to_action: 'study now',
text: CourseStateTextEnum.ARCHIVED,
};
}
return {
priority: Priority.ARCHIVED_CLOSED,
datetime: null,
call_to_action: null,
text: CourseStateTextEnum.ARCHIVED,
};
}
if (new Date(courseRun.enrollment_start) > now) {
return {
priority: Priority.FUTURE_NOT_YET_OPEN,
datetime: courseRun.start,
call_to_action: null,
text: CourseStateTextEnum.STARTING_ON,
};
}
if (enrollmentEnd > now) {
return {
priority: Priority.FUTURE_OPEN,
datetime: courseRun.start,
call_to_action: 'enroll now',
text: CourseStateTextEnum.STARTING_ON,
};
}
return {
priority: Priority.FUTURE_CLOSED,
datetime: courseRun.start,
call_to_action: null,
text: CourseStateTextEnum.ENROLLMENT_CLOSED,
};
};

@igobranco
Copy link
Collaborator Author

Replaced by #2553

@igobranco igobranco closed this Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants