Skip to content

Commit 5653926

Browse files
committed
feat(locale): improved localization linking consistency; inline flags
1 parent 9481951 commit 5653926

15 files changed

Lines changed: 93 additions & 43 deletions

File tree

app/campus-life/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { MapPin, Coffee, Utensils, Wifi, Bus, Bike, Shield } from "lucide-react"
66
import { GradientBlob } from "@/components/ui/GradientBlob";
77
import { useLocale } from "@/components/i18n/LocaleProvider";
88
import { PageSegue } from "@/components/ui/PageSegue";
9+
import { localizePath } from "@/lib/i18n/path-utils";
910

1011
import dormImg1 from "@/public/images/uni/IMG_20251103_130246 (1).webp";
1112
import dormImg2 from "@/public/images/uni/IMG_20251109_094544.webp";
@@ -30,6 +31,7 @@ import beijingMap from "@/public/images/beijing-map.webp";
3031
export default function CampusLifePage() {
3132
const { locale } = useLocale();
3233
const isId = locale === "id";
34+
const communityHref = localizePath("/community", locale);
3335

3436
const facilities = [
3537
{
@@ -415,7 +417,7 @@ export default function CampusLifePage() {
415417
: "Join 400+ Indonesian students and discover the support system that makes BIT feel like home."
416418
}
417419
buttonText={isId ? "Lihat Komunitas" : "Discover the Community"}
418-
buttonHref="/community"
420+
buttonHref={communityHref}
419421
/>
420422
</div>
421423
);

app/community/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { BlurImage } from "@/components/ui/blur-image";
77
import { Users, BookOpen, Briefcase, Heart, Plane, Home } from "lucide-react";
88
import { Button } from "@/components/ui/button";
99
import { useLocale } from "@/components/i18n/LocaleProvider";
10+
import { localizePath } from "@/lib/i18n/path-utils";
1011

1112
import { GradientBlob } from "@/components/ui/GradientBlob";
1213
import { PageSegue } from "@/components/ui/PageSegue";
@@ -168,6 +169,7 @@ function MobileNetworkLogo({ logo }: MobileNetworkLogoProps) {
168169
export default function CommunityPage() {
169170
const { locale } = useLocale();
170171
const isId = locale === "id";
172+
const admissionsHref = localizePath("/admissions", locale);
171173
const networkRef = useRef<HTMLDivElement>(null);
172174
const cursorX = useMotionValue(0);
173175
const cursorY = useMotionValue(0);
@@ -627,7 +629,7 @@ export default function CommunityPage() {
627629
: "Learn about requirements, scholarships, and the application timeline for BIT."
628630
}
629631
buttonText={isId ? "Lihat Info Admisi" : "View Admissions Info"}
630-
buttonHref="/admissions"
632+
buttonHref={admissionsHref}
631633
/>
632634
</div>
633635
);

app/faq/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export default function FAQPage() {
171171
},
172172
{
173173
q: "Can parents visit?",
174-
a: "Yes! However they may not be allowed stay overnight in campus.",
174+
a: "Yes! However, they may not be allowed to stay overnight on campus.",
175175
},
176176
{
177177
q: "What VPN should I use?",

app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Footer } from "@/components/layout/Footer";
77
import { LocaleProvider } from "@/components/i18n/LocaleProvider";
88
import { LanguageNudge } from "@/components/i18n/LanguageNudge";
99
import { LanguagePickerPrompt } from "@/components/i18n/LanguagePickerPrompt";
10-
import { I18nDebugPanel } from "@/components/i18n/I18nDebugPanel";
10+
import { I18nDebugPanel } from "@/components/features/i18n/I18nDebugPanel";
1111
import {
1212
DEFAULT_LOCALE,
1313
LOCALES,

app/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { GradientBlob } from "@/components/ui/GradientBlob";
77
import { PageSegue } from "@/components/ui/PageSegue";
88
import ShinyText from "@/components/ui/ShinyText";
99
import { useLocale } from "@/components/i18n/LocaleProvider";
10+
import { localizePath } from "@/lib/i18n/path-utils";
1011

1112
import heroImg1 from "@/public/images/uni/IMG_20251101_124832167.CCD.webp";
1213
import heroImg2 from "@/public/images/uni/IMG_20250914_190338764.CCD.NIGHT.webp";
@@ -15,7 +16,8 @@ import heroImg4 from "@/public/images/uni/IMG_20251207_121823829.CCD.webp";
1516
import shanghaiImg from "@/public/images/shanghai.webp";
1617

1718
export default function Home() {
18-
const { messages } = useLocale();
19+
const { locale, messages } = useLocale();
20+
const campusLifeHref = localizePath("/campus-life", locale);
1921

2022
const containerVariants = {
2123
hidden: { opacity: 0 },
@@ -295,7 +297,7 @@ export default function Home() {
295297
title={messages.home.segue.title}
296298
description={<>{messages.home.segue.description}</>}
297299
buttonText={messages.home.segue.button}
298-
buttonHref="/campus-life"
300+
buttonHref={campusLifeHref}
299301
/>
300302
</div>
301303
);

app/scholarship-cost/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import { ScholarshipCarousel } from "@/components/features/ScholarshipCarousel";
88
import { PageSegue } from "@/components/ui/PageSegue";
99
import { useLocale } from "@/components/i18n/LocaleProvider";
1010
import { siteContent } from "@/lib/content";
11+
import { localizePath } from "@/lib/i18n/path-utils";
1112

1213
export default function ScholarshipCostPage() {
1314
const { locale } = useLocale();
1415
const isId = locale === "id";
16+
const admissionsHref = localizePath("/admissions", locale);
1517

1618
return (
1719
<div className="relative overflow-hidden min-h-screen pt-32">
@@ -89,7 +91,7 @@ export default function ScholarshipCostPage() {
8991
: "Learn about requirements and the application timeline for BIT."
9092
}
9193
buttonText={isId ? "Lihat Info Admisi" : "View Admissions Info"}
92-
buttonHref="/admissions"
94+
buttonHref={admissionsHref}
9395
/>
9496
</div>
9597
);
File renamed without changes.

components/i18n/FlagIcon.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import IndonesianFlag from "@/public/images/flags/id.svg";
2+
import UnitedStatesFlag from "@/public/images/flags/en-us.svg";
3+
import { type Locale } from "@/lib/i18n/config";
4+
import { cn } from "@/lib/utils";
5+
6+
type FlagIconProps = {
7+
locale: Locale;
8+
className?: string;
9+
title?: string;
10+
};
11+
12+
const FLAG_MAP = {
13+
id: {
14+
component: IndonesianFlag,
15+
viewBox: "0 0 64 48",
16+
},
17+
en: {
18+
component: UnitedStatesFlag,
19+
viewBox: "0 0 64 48",
20+
},
21+
} as const;
22+
23+
export function FlagIcon({ locale, className, title }: FlagIconProps) {
24+
const { component: Flag, viewBox } = FLAG_MAP[locale];
25+
26+
return (
27+
<Flag
28+
className={cn("inline-block", className)}
29+
viewBox={viewBox}
30+
preserveAspectRatio="xMidYMid slice"
31+
role={title ? "img" : "presentation"}
32+
aria-label={title}
33+
aria-hidden={title ? undefined : true}
34+
focusable={false}
35+
/>
36+
);
37+
}

components/i18n/LanguageNudge.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"use client";
22

3-
import Image from "next/image";
43
import { useEffect, useRef, useState } from "react";
54
import { Languages, X } from "lucide-react";
65
import { Button } from "@/components/ui/button";
6+
import { FlagIcon } from "@/components/i18n/FlagIcon";
77
import { LOCALE_SWITCH_NUDGE_KEY, type Locale, isLocale } from "@/lib/i18n/config";
88
import { useLocale } from "@/components/i18n/LocaleProvider";
99

@@ -127,7 +127,7 @@ export function LanguageNudge() {
127127
className="h-16 rounded-xl justify-center gap-1.5 flex-col"
128128
>
129129
<span className="w-9 h-6 rounded-md overflow-hidden ring-1 ring-black/10">
130-
<Image src={item.flagSrc} alt={item.label} width={36} height={24} className="w-full h-full object-cover" />
130+
<FlagIcon locale={item.code} className="size-full" />
131131
</span>
132132
<span className="text-xs">{item.label}</span>
133133
</Button>

components/i18n/LanguagePickerPrompt.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"use client";
22

3-
import Image from "next/image";
43
import { Languages, X } from "lucide-react";
54
import { Button } from "@/components/ui/button";
5+
import { FlagIcon } from "@/components/i18n/FlagIcon";
66
import { useLocale } from "@/components/i18n/LocaleProvider";
77

88
export function LanguagePickerPrompt() {
@@ -57,7 +57,7 @@ export function LanguagePickerPrompt() {
5757
className="h-28 rounded-xl w-full justify-center gap-2 text-base flex-col"
5858
>
5959
<span className="w-16 h-12 rounded-md overflow-hidden ring-1 ring-black/10">
60-
<Image src="/images/flags/id.svg" alt={messages.common.indonesian} className="w-full h-full object-cover" width={64} height={48} />
60+
<FlagIcon locale="id" className="size-full" />
6161
</span>
6262
<span>{messages.common.indonesian}</span>
6363
</Button>
@@ -67,7 +67,7 @@ export function LanguagePickerPrompt() {
6767
className="h-28 rounded-xl w-full justify-center gap-2 text-base flex-col"
6868
>
6969
<span className="w-16 h-12 rounded-md overflow-hidden ring-1 ring-black/10">
70-
<Image src="/images/flags/en-us.svg" alt={messages.common.english} className="w-full h-full object-cover" width={64} height={48} />
70+
<FlagIcon locale="en" className="size-full" />
7171
</span>
7272
<span>{messages.common.english}</span>
7373
</Button>

0 commit comments

Comments
 (0)