translate feed page

This commit is contained in:
Aarni Halinen
2021-04-01 18:09:59 +03:00
parent 9bec3f1e0a
commit feaaa981bd
+15 -4
View File
@@ -6,6 +6,7 @@ import Post from "@models/Feed";
import { TextSection } from "@components/index";
import MarkdownStyles from "@views/common/MarkdownStyles";
import LoadingView from "@views/common/LoadingView";
import i18nNext from "../../i18n";
interface FeedPageViewProps {
post?: Post;
@@ -32,17 +33,27 @@ const Content = styled(MarkdownStyles)`
const FeedPageView: React.FC<FeedPageViewProps> = ({ post }) => {
if (!post) return <LoadingView />;
const { language } = i18nNext.i18n;
const isFi = language === "fi";
const {
title, description, content,
} = {
title: isFi ? post.title_fi : post.title_en,
description: isFi ? post.description_fi : post.description_en,
content: isFi ? post.content_fi : post.content_en,
};
return (
<StyledTextSection>
<h1>
{post.title_fi}
{title}
<p>
{post.description_fi}
{description}
</p>
{post.image && (
<Image
src={post.image}
alt={post.title_fi}
alt={title}
objectFit="scale-down"
layout="responsive"
width={16}
@@ -51,7 +62,7 @@ const FeedPageView: React.FC<FeedPageViewProps> = ({ post }) => {
)}
</h1>
<div>
<Content source={post.content_fi} escapeHtml={false} />
<Content source={content} escapeHtml={false} />
</div>
</StyledTextSection>
);