🌐 Replaced hardcoded text to use translation

This commit is contained in:
Tagaishi
2023-08-09 22:16:57 +02:00
parent ffa850b081
commit 9b2fecdfcb
24 changed files with 148 additions and 81 deletions

View File

@@ -11,7 +11,6 @@ import {
IconSun,
} from '@tabler/icons-react';
import { useTranslation } from 'next-i18next';
import { useElementSize } from '@mantine/hooks';
interface WeatherIconProps {
code: number;
@@ -25,8 +24,7 @@ interface WeatherIconProps {
*/
export const WeatherIcon = ({ code, size=50 }: WeatherIconProps) => {
const { t } = useTranslation('modules/weather');
const { width, ref } = useElementSize();
const { icon: Icon, name } =
weatherDefinitions.find((wd) => wd.codes.includes(code)) ?? unknownWeather;

View File

@@ -4,7 +4,6 @@ import {
IconArrowDownRight,
IconArrowUpRight,
IconCloudRain,
IconCurrentLocation,
IconMapPin,
} from '@tabler/icons-react';
import { api } from '~/utils/api';
@@ -12,6 +11,7 @@ import { api } from '~/utils/api';
import { defineWidget } from '../helper';
import { IWidget } from '../widgets';
import { WeatherIcon } from './WeatherIcon';
import { useTranslation } from 'react-i18next';
const definition = defineWidget({
id: 'weather',
@@ -52,6 +52,7 @@ interface WeatherTileProps {
function WeatherTile({ widget }: WeatherTileProps) {
const { data: weather, isLoading, isError } = api.weather.at.useQuery(widget.properties.location);
const { width, ref } = useElementSize();
const { t } = useTranslation('modules/weather');
if (isLoading) {
return (
@@ -77,7 +78,7 @@ function WeatherTile({ widget }: WeatherTileProps) {
if (isError) {
return (
<Center>
<Text weight={500}>An error occured</Text>
<Text weight={500}>{t('error')}</Text>
</Center>
);
}