Skip to content

Commit

Permalink
Made the language look pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
graacelin authored and eamonma committed Jun 17, 2022
1 parent ad5bcd2 commit b8d87c2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
5 changes: 2 additions & 3 deletions components/preferences/PreferencesApplication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import {
} from "@chakra-ui/react"
import { useTranslation } from "next-i18next"
import React, { Fragment, MouseEvent, useEffect, useRef } from "react"
import { BiVideoPlus } from "react-icons/bi"
import { BsGlobe } from "react-icons/bs"
import { IoLanguage } from "react-icons/io5"
import { FaSchool, FaSun, FaTemperatureHigh } from "react-icons/fa"
import styled from "styled-components"
import { usePreferences } from "../../src/PreferencesContext"
Expand Down Expand Up @@ -189,7 +188,7 @@ const PreferencesApplication = () => {
<FormControl>
<FormLabel mb={4}>
<IconWrapper>
<Icon as={BsGlobe} />
<Icon as={IoLanguage} />
</IconWrapper>
{t("language")}
</FormLabel>
Expand Down
16 changes: 14 additions & 2 deletions components/preferences/_PreferencesLanguage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ const PreferencesLanguage = () => {
<Grid gridTemplateColumns="repeat(3, auto)" {...group} gap={4}>
{options.map((value) => {
const radio = getRadioProps({ value, enterKeyHint: "enter" })
let lang = ''
switch(value) {
case 'en':
lang = "English"
break
case 'fr':
lang = "Français"
break
case 'zh':
lang = "简体中文"
break
}
if (value === router.locale) {
return (
<Box
Expand All @@ -53,15 +65,15 @@ const PreferencesLanguage = () => {
px={3}
py={2}
>
{value}
{lang}
</Box>
)
} else {
return (
<Link href='/' locale={value}>
<button>
<RadioTextCard key={ value }>
{ t(value) }
{ lang }
</RadioTextCard>
</button>
</Link>
Expand Down
3 changes: 2 additions & 1 deletion public/locales/en/preferences.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"scale": "Scale",
"compact": "Compact",
"normal": "Normal",
"tall": "Tall"
"tall": "Tall",
"language": "Language"
}
3 changes: 2 additions & 1 deletion public/locales/fr/preferences.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"scale": "Taille",
"compact": "Compacte",
"normal": "Normale",
"tall": "Grande"
"tall": "Grande",
"language": "Langue"
}
3 changes: 2 additions & 1 deletion public/locales/zh/preferences.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
"scale": "大小",
"compact": "",
"normal": "正常",
"tall": ""
"tall": "",
"language": "语言"
}

0 comments on commit b8d87c2

Please sign in to comment.