Skip to content

Commit

Permalink
Merge pull request #1647 from lumi-tip/development-lumi-7862
Browse files Browse the repository at this point in the history
✨ adding traslation to title and desc of modules
  • Loading branch information
alesanchezr authored Oct 22, 2024
2 parents 4eb3712 + 626fd3d commit 303526a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/common/components/Timeline.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React, {
useEffect, memo, useState,
} from 'react';
import PropTypes from 'prop-types';
import { useRouter } from 'next/router';
import {
Box,
Flex,
useColorModeValue,
} from '@chakra-ui/react';
import PropTypes from 'prop-types';
import useTranslation from 'next-translate/useTranslation';
import { languageFix } from '../../utils';
import useStyle from '../hooks/useStyle';
import Icon from './Icon';
import Text from './Text';
Expand Down Expand Up @@ -126,7 +127,7 @@ function Timeline({
return (
<>
<Flex width={width} marginBottom="1.5rem">
<Text size="l" fontWeight="900" color={fontColor1}>{title && title.toUpperCase()}</Text>
<Text size="l" fontWeight="900" color={fontColor1}>{title && languageFix(title, lang).toUpperCase()}</Text>
{technologies.length >= 1 && (
<Text
size="l"
Expand Down
9 changes: 5 additions & 4 deletions src/js_modules/moduleMap/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ import {
} from '@chakra-ui/react';
import useTranslation from 'next-translate/useTranslation';
import PropTypes from 'prop-types';
import { reportDatalayer } from '../../utils/requests';
import { languageFix } from '../../utils';
import Text from '../../common/components/Text';
import Module from './module';
import useModuleHandler from '../../common/hooks/useModuleHandler';
import useCohortHandler from '../../common/hooks/useCohortHandler';
import Icon from '../../common/components/Icon';
import { reportDatalayer } from '../../utils/requests';

function ModuleMap({
index, slug, modules, filteredModules,
title, description, cohortData, filteredModulesByPending,
showPendingTasks, searchValue, existsActivities,
}) {
const { t } = useTranslation('dashboard');
const { t, lang } = useTranslation('dashboard');
const { startDay } = useModuleHandler();
const { state } = useCohortHandler();
const { taskCohortNull } = state;
Expand Down Expand Up @@ -67,7 +68,7 @@ function ModuleMap({
>
<Box margin="14px 0" display="flex" alignItems="center" justifyContent="space-between" gridGap="15px">
<Heading as="h2" fontSize="22px">
{title}
{languageFix(title, lang)}
</Heading>
<Heading
as="span"
Expand All @@ -81,7 +82,7 @@ function ModuleMap({
</Heading>
</Box>
<Text margin="0 0 22px 0px" color={useColorModeValue('#606060', 'white')} size="md">
{description}
{languageFix(description, lang)}
</Text>

{isAvailableToSync() && (
Expand Down
11 changes: 6 additions & 5 deletions src/js_modules/syllabus/GuidedExperienceSidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import {
} from '@chakra-ui/react';
import PropTypes from 'prop-types';
import useTranslation from 'next-translate/useTranslation';
import Heading from '../../common/components/Heading';
import { languageFix } from '../../utils';
import { Config, getSlideProps } from './config';
import Heading from '../../common/components/Heading';
import Timeline from '../../common/components/Timeline';
import NextChakraLink from '../../common/components/NextChakraLink';
import Text from '../../common/components/Text';
Expand All @@ -20,7 +21,7 @@ import useCohortHandler from '../../common/hooks/useCohortHandler';
import useStyle from '../../common/hooks/useStyle';

function GuidedExperienceSidebar({ onClickAssignment, isOpen, onToggle, currentModuleIndex, handleStartDay, grantSyllabusAccess }) {
const { t } = useTranslation('syllabus');
const { t, lang } = useTranslation('syllabus');
const [moduleLoading, setModuleLoading] = useState(false);
const { state } = useCohortHandler();
const { cohortSession, sortedAssignments } = state;
Expand Down Expand Up @@ -129,7 +130,7 @@ function GuidedExperienceSidebar({ onClickAssignment, isOpen, onToggle, currentM
</Text>
<br />
<Text as="span" mt="8px">
{prevModule.label}
{languageFix(prevModule.label, lang)}
</Text>
</span>
</Button>
Expand All @@ -151,7 +152,7 @@ function GuidedExperienceSidebar({ onClickAssignment, isOpen, onToggle, currentM
<>
{currentModule.label && (
<Heading mb="16px" size="18px" fontWeight="400">
{currentModule.label.toUpperCase()}
{languageFix(currentModule.label, lang).toUpperCase()}
</Heading>
)}
<Timeline
Expand Down Expand Up @@ -183,7 +184,7 @@ function GuidedExperienceSidebar({ onClickAssignment, isOpen, onToggle, currentM
</Text>
<br />
<Text as="span" color={hexColor.blueDefault} mt="8px">
{nextModule.label}
{languageFix(nextModule.label, lang)}
</Text>
</span>
<Icon icon="arrowLeft" style={{ transform: 'rotate(180deg)' }} color={hexColor.blueDefault} />
Expand Down
4 changes: 3 additions & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ function decodeBase64(encoded) {
return decoded;
}

const languageFix = (text, lan) => text[lan] || text.us || text;

export {
isWindow, assetTypeValues, HAVE_SESSION, slugify, unSlugify, unSlugifyCapitalize, location,
isPlural, getStorageItem, includesToLowerCase, getExtensionName,
Expand All @@ -429,5 +431,5 @@ export {
sortToNearestTodayDate, isNumber, isDateMoreThanAnyDaysAgo, getQueryString, isValidDate,
createArray, url, lengthOfString, syncInterval, getBrowserSize, calculateDifferenceDays, intervalToHours, capitalizeFirstLetter,
adjustNumberBeetwenMinMax, getDiscountedPrice, formatPrice, cleanObject, slugToTitle, decodeBase64,
removeSessionStorageItem,
removeSessionStorageItem, languageFix,
};

0 comments on commit 303526a

Please sign in to comment.