Skip to content

Commit

Permalink
fix(i18n): add missing translations for Chinese and Korean
Browse files Browse the repository at this point in the history
- Added missing translation keys for Chinese and Korean locales.
- Updated components to address missing translations in several places.

This ensures improved localization coverage and consistency.
  • Loading branch information
phungmanhcuong committed Dec 18, 2024
1 parent da5a68e commit 2f422e1
Show file tree
Hide file tree
Showing 10 changed files with 3,170 additions and 673 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC, memo } from 'react';
import { defineMessages, FormattedMessage } from 'react-intl';
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
import { DragIndicator } from '@mui/icons-material';
import { Switch, Typography } from '@mui/material';
import equal from 'fast-deep-equal';
Expand All @@ -15,6 +15,7 @@ import Link from 'lib/components/core/Link';
import Note from 'lib/components/core/Note';
import { getAchievementURL } from 'lib/helpers/url-builders';
import { getCourseId } from 'lib/helpers/url-helpers';
import useTranslation from 'lib/hooks/useTranslation';

import AchievementManagementButtons from '../buttons/AchievementManagementButtons';

Expand All @@ -30,6 +31,30 @@ const translations = defineMessages({
id: 'course.achievement.AchievementTable.noAchievement',
defaultMessage: 'No achievement',
},
badge: {
id: 'course.achievement.AchievementTable.badge',
defaultMessage: 'Badge',
},
title: {
id: 'course.achievement.AchievementTable.title',
defaultMessage: 'Title',
},
description: {
id: 'course.achievement.AchievementTable.description',
defaultMessage: 'Description',
},
requirements: {
id: 'course.achievement.AchievementTable.requirements',
defaultMessage: 'Requirements',
},
published: {
id: 'course.achievement.AchievementTable.published',
defaultMessage: 'Published',
},
actions: {
id: 'course.achievement.AchievementTable.actions',
defaultMessage: 'Actions',
},
});

const styles = {
Expand All @@ -42,6 +67,7 @@ const styles = {

const AchievementTable: FC<Props> = (props) => {
const { achievements, permissions, onTogglePublished, isReordering } = props;
const { t } = useTranslation();

if (achievements && achievements.length === 0) {
return (
Expand Down Expand Up @@ -104,7 +130,7 @@ const AchievementTable: FC<Props> = (props) => {
},
{
name: 'badge',
label: 'Badge',
label: t(translations.badge),
options: {
filter: false,
sort: false,
Expand All @@ -128,7 +154,7 @@ const AchievementTable: FC<Props> = (props) => {
},
{
name: 'title',
label: 'Title',
label: t(translations.title),
options: {
filter: false,
sort: false,
Expand All @@ -149,7 +175,7 @@ const AchievementTable: FC<Props> = (props) => {
},
{
name: 'description',
label: 'Description',
label: t(translations.description),
options: {
filter: false,
sort: false,
Expand All @@ -170,7 +196,7 @@ const AchievementTable: FC<Props> = (props) => {
},
{
name: 'conditions',
label: 'Requirements',
label: t(translations.requirements),
options: {
filter: false,
sort: false,
Expand All @@ -194,7 +220,7 @@ const AchievementTable: FC<Props> = (props) => {
if (permissions?.canManage) {
columns.push({
name: 'published',
label: 'Published',
label: t(translations.published),
options: {
filter: false,
sort: false,
Expand All @@ -218,7 +244,7 @@ const AchievementTable: FC<Props> = (props) => {
});
columns.push({
name: 'id',
label: 'Actions',
label: t(translations.actions),
options: {
filter: false,
sort: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const translations = defineMessages({
id: 'course.achievement.AchievementAward.AchievementAwardManager.note',
defaultMessage:
'If an Achievement has conditions associated with it, \
Coursemology will automatically award achievements when the student meets those conditions. ',
Coursemology will automatically award achievements when the student meets those conditions. ',
},
noUser: {
id: 'course.achievement.AchievementAward.AchievementAwardManager.noUser',
Expand Down Expand Up @@ -242,7 +242,7 @@ const AchievementAwardManager: FC<Props> = (props) => {
},
{
name: 'id',
label: 'Obtained Achievement',
label: columnHeadLabelAchievement,
options: {
filter: false,
search: false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FC } from 'react';
import { defineMessages, useIntl } from 'react-intl';
import { Grid } from '@mui/material';
import { green, red } from '@mui/material/colors';
import { TableColumns, TableOptions } from 'types/components/DataTable';
Expand All @@ -12,8 +13,36 @@ interface Props {
selectedUserIds: Set<number>;
}

const translations = defineMessages({
name: {
id: 'course.achievement.AchievementAward.AchievementAwardSummary.name',
defaultMessage: 'Name',
},
userType: {
id: 'course.achievement.AchievementAward.AchievementAwardSummary.userType',
defaultMessage: 'User Type',
},
awardedStudents: {
id: 'course.achievement.AchievementAward.AchievementAwardSummary.awardedStudents',
defaultMessage: 'Awarded Students',
},
revokedStudents: {
id: 'course.achievement.AchievementAward.AchievementAwardSummary.revokedStudents',
defaultMessage: 'Revoked Students',
},
phantomStudent: {
id: 'course.achievement.AchievementAward.AchievementAwardSummary.phantomStudent',
defaultMessage: 'Phantom Student',
},
normalStudent: {
id: 'course.achievement.AchievementAward.AchievementAwardSummary.normalStudent',
defaultMessage: 'Normal Student',
},
});

const AchievementAwardSummary: FC<Props> = (props) => {
const { achievementUsers, initialObtainedUserIds, selectedUserIds } = props;
const { formatMessage: t } = useIntl();

const removedUserIds = new Set(
[...initialObtainedUserIds].filter(
Expand Down Expand Up @@ -57,22 +86,21 @@ const AchievementAwardSummary: FC<Props> = (props) => {
const awardedTableColumns: TableColumns[] = [
{
name: 'name',
label: 'Name',
label: t(translations.name),
options: {
filter: false,
},
},
{
name: 'phantom',
label: 'User Type',
label: t(translations.userType),
options: {
search: false,
customBodyRenderLite: (dataIndex): string => {
const isPhantom = awardedUsers[dataIndex].phantom;
if (isPhantom) {
return 'Phantom Student';
}
return 'Normal Student';
return isPhantom
? t(translations.phantomStudent)
: t(translations.normalStudent);
},
},
},
Expand All @@ -81,22 +109,21 @@ const AchievementAwardSummary: FC<Props> = (props) => {
const removedTableColumns: TableColumns[] = [
{
name: 'name',
label: 'Name',
label: t(translations.name),
options: {
filter: false,
},
},
{
name: 'phantom',
label: 'User Type',
label: t(translations.userType),
options: {
search: false,
customBodyRenderLite: (dataIndex): string => {
const isPhantom = removedUsers[dataIndex].phantom;
if (isPhantom) {
return 'Phantom Student';
}
return 'Normal Student';
return isPhantom
? t(translations.phantomStudent)
: t(translations.normalStudent);
},
},
},
Expand All @@ -109,15 +136,15 @@ const AchievementAwardSummary: FC<Props> = (props) => {
columns={awardedTableColumns}
data={awardedUsers}
options={awardedTableOptions}
title={`Awarded Students (${awardedUsers.length})`}
title={`${t(translations.awardedStudents)} (${awardedUsers.length})`}
/>
</Grid>
<Grid item xs={6}>
<DataTable
columns={removedTableColumns}
data={removedUsers}
options={removedTableOptions}
title={`Revoked Students (${removedUsers.length})`}
title={`${t(translations.revokedStudents)} (${removedUsers.length})`}
/>
</Grid>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
import { FC } from 'react';
import { defineMessages } from 'react-intl';
import { Chip, TableBody, TableCell, TableRow } from '@mui/material';
import palette from 'theme/palette';
import { LogsMainInfo } from 'types/course/assessment/submission/logs';

import TableContainer from 'lib/components/core/layouts/TableContainer';
import Link from 'lib/components/core/Link';
import useTranslation from 'lib/hooks/useTranslation';
import useTranslation, { Descriptor } from 'lib/hooks/useTranslation';

import translations from './translations';

interface Props {
with: LogsMainInfo;
}

const statusTranslations = {
attempting: 'Attempting',
submitted: 'Submitted',
graded: 'Graded, unpublished',
published: 'Graded',
unknown: 'Unknown status, please contact administrator',
};
const statusTranslations = defineMessages({
attempting: {
id: 'course.assessment.submission.pages.LogsIndex.LogsHead.attempting',
defaultMessage: 'Attempting',
},
submitted: {
id: 'course.assessment.submission.pages.LogsIndex.LogsHead.submitted',
defaultMessage: 'Submitted',
},
graded: {
id: 'course.assessment.submission.pages.LogsIndex.LogsHead.graded',
defaultMessage: 'Graded, unpublished',
},
published: {
id: 'course.assessment.submission.pages.LogsIndex.LogsHead.published',
defaultMessage: 'Graded',
},
unknown: {
id: 'course.assessment.submission.pages.LogsIndex.LogsHead.unknown',
defaultMessage: 'Unknown status, please contact administrator',
},
});

const translateStatus: (var1: string) => string = (oldStatus) => {
const translateStatus: (var1: string) => Descriptor = (oldStatus) => {
switch (oldStatus) {
case 'attempting':
return statusTranslations.attempting;
Expand Down Expand Up @@ -66,7 +82,7 @@ const LogsHead: FC<Props> = (props) => {
<TableCell>
<Link to={info.editUrl}>
<Chip
label={translateStatus(info.submissionWorkflowState)}
label={t(translateStatus(info.submissionWorkflowState))}
style={{
width: 100,
backgroundColor:
Expand Down
Loading

0 comments on commit 2f422e1

Please sign in to comment.