🌐 Fix the flags for internalization

This commit is contained in:
ajnart
2022-08-25 12:28:43 +02:00
parent ad0b1e4e46
commit bc7ca43c08
5 changed files with 14 additions and 17 deletions

View File

@@ -49,6 +49,7 @@
"axios": "^0.27.2", "axios": "^0.27.2",
"consola": "^2.15.3", "consola": "^2.15.3",
"cookies-next": "^2.1.1", "cookies-next": "^2.1.1",
"country-flag-icons": "^1.5.5",
"dayjs": "^1.11.5", "dayjs": "^1.11.5",
"dockerode": "^3.3.2", "dockerode": "^3.3.2",
"embla-carousel-react": "^7.0.0", "embla-carousel-react": "^7.0.0",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -1,5 +1,6 @@
import { Group, Image, Select, Stack, Text } from '@mantine/core'; import { Group, Select, Stack, Text } from '@mantine/core';
import { showNotification } from '@mantine/notifications'; import { showNotification } from '@mantine/notifications';
import getUnicodeFlagIcon from 'country-flag-icons/unicode';
import { forwardRef, useState } from 'react'; import { forwardRef, useState } from 'react';
import { useTranslation } from 'next-i18next'; import { useTranslation } from 'next-i18next';
@@ -20,7 +21,7 @@ export default function LanguageSwitch() {
? locales.map((localeItem) => ({ ? locales.map((localeItem) => ({
value: localeItem, value: localeItem,
label: getLanguageByCode(localeItem).originalName, label: getLanguageByCode(localeItem).originalName,
image: `imgs/flags/${localeItem}.png`, icon: getUnicodeFlagIcon(localeItem),
language: getLanguageByCode(localeItem), language: getLanguageByCode(localeItem),
})) }))
: []; : [];
@@ -56,20 +57,7 @@ export default function LanguageSwitch() {
return ( return (
<Stack> <Stack>
<Select <Select
icon={ icon={<Text>{getUnicodeFlagIcon(selectedLanguage as string)}</Text>}
<Image
width={30}
height={18}
src={`/imgs/flags/${selectedLanguage}.png`}
alt="country flag"
styles={{
root: {
borderRadius: 1.5,
overflow: 'hidden',
},
}}
/>
}
label={t('label')} label={t('label')}
data={data} data={data}
itemComponent={SelectItem} itemComponent={SelectItem}
@@ -99,7 +87,7 @@ const SelectItem = forwardRef<HTMLDivElement, ItemProps>(
({ language, image, ...others }: ItemProps, ref) => ( ({ language, image, ...others }: ItemProps, ref) => (
<div ref={ref} {...others}> <div ref={ref} {...others}>
<Group noWrap> <Group noWrap>
<Image src={image} width={30} height={20} radius="xs" /> <Text>{getUnicodeFlagIcon(language.originalName as string)}</Text>
<div> <div>
<Text size="sm"> <Text size="sm">

View File

@@ -3145,6 +3145,13 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"country-flag-icons@npm:^1.5.5":
version: 1.5.5
resolution: "country-flag-icons@npm:1.5.5"
checksum: 367f38330a7f0f94836c7859575e1ae75655a04e2104ba060de75827d82bd84413fd7752c9166efa93123eb0d1dd1db1658ef22683511dcfa1c16f2caffe892d
languageName: node
linkType: hard
"cpu-features@npm:~0.0.4": "cpu-features@npm:~0.0.4":
version: 0.0.4 version: 0.0.4
resolution: "cpu-features@npm:0.0.4" resolution: "cpu-features@npm:0.0.4"
@@ -4743,6 +4750,7 @@ __metadata:
axios: ^0.27.2 axios: ^0.27.2
consola: ^2.15.3 consola: ^2.15.3
cookies-next: ^2.1.1 cookies-next: ^2.1.1
country-flag-icons: ^1.5.5
dayjs: ^1.11.5 dayjs: ^1.11.5
dockerode: ^3.3.2 dockerode: ^3.3.2
embla-carousel-react: ^7.0.0 embla-carousel-react: ^7.0.0