Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some more i18n #33

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/admin/AdminSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { useTranslation } from "react-i18next";
import Link from "next/link";

const groups = {
Allmänt: [
general: [
{
title: "admin:news.self",
url: "/admin/news",
Expand All @@ -34,7 +34,7 @@ const groups = {
icon: Calendar,
},
],
};
} as const;

export function AdminSidebar() {
const { t } = useTranslation();
Expand All @@ -48,7 +48,7 @@ export function AdminSidebar() {
<SidebarGroup>
<SidebarGroupLabel asChild>
<CollapsibleTrigger>
{group}
{t(group)}
<ChevronDown className="ml-auto transition-transform group-data-[state=open]/collapsible:rotate-180" />
</CollapsibleTrigger>
</SidebarGroupLabel>
Expand Down
8 changes: 5 additions & 3 deletions src/app/admin/events/EventsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {

import { AdminChooseCouncil } from "@/widgets/AdminChooseCouncil";
import { AdminChooseDates } from "@/widgets/AdminChooseDates";
import { useTranslation } from "react-i18next";

const eventsSchema = z.object({
title_sv: z.string().min(2),
Expand Down Expand Up @@ -48,6 +49,7 @@ const eventsSchema = z.object({
export default function EventsForm() {
const [open, setOpen] = useState(false);
const [submitEnabled, setSubmitEnabled] = useState(true);
const { t } = useTranslation();

const eventsForm = useForm<z.infer<typeof eventsSchema>>({
resolver: zodResolver(eventsSchema),
Expand Down Expand Up @@ -127,7 +129,7 @@ export default function EventsForm() {
setSubmitEnabled(true);
}}
>
Skapa event
{t("events.create")}
</Button>

<Dialog open={open} onOpenChange={setOpen}>
Expand Down Expand Up @@ -238,14 +240,14 @@ export default function EventsForm() {

<div className="space-x-2 lg:col-span-2 lg:grid-cols-subgrid">
<Button variant="outline" className="w-32 min-w-fit">
Förhandsgranska
{t("preview")}
</Button>
<Button
type="submit"
disabled={!submitEnabled}
className="w-32 min-w-fit"
>
Publicera
{t("publish")}
</Button>
</div>
</form>
Expand Down
4 changes: 3 additions & 1 deletion src/app/admin/news/NewsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
getAllNewsQueryKey,
} from "@/api/@tanstack/react-query.gen";
import { Plus } from "lucide-react";
import { useTranslation } from "react-i18next";

const newsSchema = z.object({
title_sv: z.string().min(2),
Expand All @@ -39,6 +40,7 @@ export default function NewsForm() {
const newsForm = useForm<z.infer<typeof newsSchema>>({
resolver: zodResolver(newsSchema),
});
const { t } = useTranslation("admin");

const createNews = useMutation({
...createNewsMutation(),
Expand Down Expand Up @@ -78,7 +80,7 @@ export default function NewsForm() {
}}
>
<Plus />
Skapa nyhet
{t("news.create")}
</Button>

<Dialog open={open} onOpenChange={setOpen}>
Expand Down
11 changes: 8 additions & 3 deletions src/locales/en/admin.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"title": "Admin page",
"general": "General",
"news": {
"self": "News",
"page_title": "Administrate news"
"page_title": "Administrate news",
"create": "Create news article"
},
"events": {
"self": "Events"
}
"self": "Events",
"create": "Create event"
},
"preview": "Preview",
"publish": "Publish"
}
11 changes: 8 additions & 3 deletions src/locales/sv/admin.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"title": "Adminsida",
"general": "Allmänt",
"news": {
"self": "Nyheter",
"page_title": "Administrera nyheter"
"page_title": "Administrera nyheter",
"create": "Skapa nyhet"
},
"events": {
"self": "Evenemang"
}
"self": "Evenemang",
"create": "Skapa event"
},
"preview": "Förhandsgranska",
"publish": "Publicera"
}