-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lisätty käännöksiä ja logiikkaa eri ohjeille
- Loading branch information
Showing
24 changed files
with
516 additions
and
184 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use client' | ||
|
||
import { Box } from "@mui/material"; | ||
import { Lasku } from "@/app/lib/types"; | ||
import { useTranslations } from "@/app/i18n/useTranslations"; | ||
|
||
const Header = ({lasku}: {lasku: Lasku}) => { | ||
const {t} = useTranslations(); | ||
|
||
return ( | ||
<Box style={{textAlign: 'center'}}> | ||
<h3>{`${lasku.last_name} ${lasku.first_name}`}</h3> | ||
<h1>{t('title')}</h1> | ||
</Box> | ||
) | ||
} | ||
|
||
export default Header; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,28 @@ | ||
'use client' | ||
|
||
import styles from "@/app/page.module.css"; | ||
import { Lasku } from "@/app/lib/types"; | ||
import { useTranslations } from "@/app/i18n/useTranslations"; | ||
|
||
const Maksu = ({lasku, title}: {lasku: Lasku, title: string}) => { | ||
const {t} = useTranslations(); | ||
|
||
const parseDate = (date: string) => { | ||
const [year, month, day] = date.split("-"); | ||
return `${day}.${month}.${year}`; | ||
} | ||
|
||
return ( | ||
<div className={styles.maksu}> | ||
<h4>{title}</h4> | ||
|
||
const Maksu = ({lasku}: {lasku: Lasku}) => { | ||
return <div className={styles.maksu}> | ||
Päätösmaksu<br/> | ||
Tila {lasku.status}<br/> | ||
Määrä {`${lasku.amount}€`}<br/> | ||
Eräpäivä {`${lasku.due_date}`}<br/> | ||
</div> | ||
{t('maksu.tila')} {t(`maksu.tila.${lasku.status}`)}<br/> | ||
{t('maksu.summa')} {`${lasku.amount}€`}<br/> | ||
{lasku.status ? | ||
`${t('maksu.eräpäivä')} ${parseDate(lasku.due_date)}` : | ||
`${t('maksu.maksupäivä')} ${parseDate(lasku.paid_at)}`}<br/> | ||
</div> | ||
) | ||
} | ||
|
||
export default Maksu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use client' | ||
|
||
import FetchBackend from 'i18next-fetch-backend'; | ||
import i18n from 'i18next'; | ||
import { initReactI18next } from 'react-i18next'; | ||
import { backendUrl, isDev } from "@/app/lib/configurations"; | ||
|
||
export const FALLBACK_LOCALE = 'fi'; | ||
export const SUPPORTED_LOCALES = ['en', 'fi', 'sv'] as const; | ||
|
||
export const createLocalization = () => { | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
i18n | ||
.use(FetchBackend) | ||
.use(initReactI18next) | ||
.init({ | ||
debug: isDev, // Set to true to see console logs | ||
backend: { | ||
loadPath: `${backendUrl}/localisation/{{lng}}`, | ||
requestOptions: { | ||
mode: 'no-cors', | ||
} | ||
}, | ||
preload: SUPPORTED_LOCALES, | ||
supportedLngs: SUPPORTED_LOCALES, | ||
fallbackLng: FALLBACK_LOCALE, | ||
lng: FALLBACK_LOCALE, | ||
}) | ||
return i18n; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use client' | ||
|
||
import { I18nextProvider } from "react-i18next"; | ||
import { createLocalization } from "@/app/i18n/localizations"; | ||
|
||
const localizations = createLocalization() | ||
|
||
export default function LocalizationsProvider({ children} : { children: React.ReactNode }) { | ||
return ( | ||
<I18nextProvider i18n={localizations}>{children}</I18nextProvider> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Locale, LocalizedString } from "@/app/lib/types"; | ||
|
||
export function translateLocalizedString( | ||
translated: LocalizedString, | ||
userLanguage: Locale = 'fi', | ||
): string { | ||
const prop = userLanguage as keyof LocalizedString; | ||
const translation = translated[prop]; | ||
if (translation && translation?.trim().length > 0) { | ||
return translated[prop] || ''; | ||
} else if (translated.fi && translated.fi.trim().length > 0) { | ||
return translated.fi; | ||
} else if (translated.en && translated.en.trim().length > 0) { | ||
return translated.en; | ||
} | ||
return translated.sv || ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use client'; | ||
|
||
import { useTranslation } from 'react-i18next'; | ||
import { useCallback } from 'react'; | ||
import { Locale, LocalizedString } from "@/app/lib/types"; | ||
import { translateLocalizedString } from "@/app/i18n/translationUtils"; | ||
|
||
export const useTranslations = () => { | ||
const { t, i18n } = useTranslation(); | ||
const translateEntity = useCallback( | ||
(translateable?: LocalizedString) => { | ||
return translateable | ||
? translateLocalizedString(translateable, i18n.language as Locale) | ||
: ''; | ||
}, | ||
[i18n], | ||
); | ||
|
||
return { t, translateEntity, language: i18n.language as Locale, i18n }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export const backendUrl: string = process.env.MAKSUT_URL || "https://localhost:9000/maksut/api" | ||
export const backendUrl: string = process.env.MAKSUT_URL || "https://localhost:9000/maksut/api" | ||
|
||
export const isDev: boolean = (process.env.DEVELOPMENT === 'true') || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.