Machine translated the ruleset for now. Added a lib to process the new system

This commit is contained in:
2025-09-15 17:21:54 +03:00
parent 312827748b
commit a9f33e9ec0
7 changed files with 304 additions and 58 deletions

View File

@@ -36,7 +36,6 @@ export default function Expo() {
lvlup: "LVLup!",
redbull: "Red Bull",
// fuajee rooms
ityk: t("expo.areas.ityk"),
estoniagamedev: t("expo.areas.estoniagamedev"),
info: t("expo.areas.info"),
tartuyk: t("expo.areas.tartuyk"),
@@ -382,8 +381,8 @@ export default function Expo() {
depth: 3.5,
x: -6,
z: 2.8,
color: fuajeeRoomColors[0],
name: roomNames.ityk,
color: fuajeeRoomColors[4],
name: roomNames.ittk,
},
{
width: 5,
@@ -815,24 +814,6 @@ export default function Expo() {
{currentView === "fuajee" && (
<div className="flex flex-wrap gap-4 pb-4">
<div className="flex items-center gap-2">
<div
className="w-4 h-4 border border-gray-300"
style={{ backgroundColor: "#7b1642" }}
></div>
<span className="text-sm text-[#2A2C3F] dark:text-[#EEE5E5]">
{t("expo.areas.ityk")}
</span>
</div>
<div className="flex items-center gap-2">
<div
className="w-4 h-4 border border-gray-300"
style={{ backgroundColor: "#365591" }}
></div>
<span className="text-sm text-[#2A2C3F] dark:text-[#EEE5E5]">
{t("expo.areas.tartuyk")}
</span>
</div>
<div className="flex items-center gap-2">
<div
className="w-4 h-4 border border-gray-300"
@@ -842,33 +823,6 @@ export default function Expo() {
{t("expo.areas.estoniagamedev")}
</span>
</div>
<div className="flex items-center gap-2">
<div
className="w-4 h-4 border border-gray-300"
style={{ backgroundColor: "#a82838" }}
></div>
<span className="text-sm text-[#2A2C3F] dark:text-[#EEE5E5]">
{t("expo.areas.tly")}
</span>
</div>
<div className="flex items-center gap-2">
<div
className="w-4 h-4 border border-gray-300"
style={{ backgroundColor: "#d12e7d" }}
></div>
<span className="text-sm text-[#2A2C3F] dark:text-[#EEE5E5]">
{t("expo.areas.ittk")}
</span>
</div>
<div className="flex items-center gap-2">
<div
className="w-4 h-4 border border-gray-300"
style={{ backgroundColor: "#ff6347" }}
></div>
<span className="text-sm text-[#2A2C3F] dark:text-[#EEE5E5]">
{t("expo.areas.info")}
</span>
</div>
<div className="flex items-center gap-2">
<div
className="w-4 h-4 border border-gray-300"
@@ -878,6 +832,24 @@ export default function Expo() {
{t("expo.areas.gameup")}
</span>
</div>
<div className="flex items-center gap-2">
<div
className="w-4 h-4 border border-gray-300"
style={{ backgroundColor: "#ff6347" }}
></div>
<span className="text-sm text-[#2A2C3F] dark:text-[#EEE5E5]">
{t("expo.areas.info")}
</span>
</div>
<div className="flex items-center gap-2">
<div
className="w-4 h-4 border border-gray-300"
style={{ backgroundColor: "#d12e7d" }}
></div>
<span className="text-sm text-[#2A2C3F] dark:text-[#EEE5E5]">
{t("expo.areas.ittk")}
</span>
</div>
<div className="flex items-center gap-2">
<div
className="w-4 h-4 border border-gray-300"
@@ -887,6 +859,24 @@ export default function Expo() {
{t("expo.areas.photobooth")}
</span>
</div>
<div className="flex items-center gap-2">
<div
className="w-4 h-4 border border-gray-300"
style={{ backgroundColor: "#365591" }}
></div>
<span className="text-sm text-[#2A2C3F] dark:text-[#EEE5E5]">
{t("expo.areas.tartuyk")}
</span>
</div>
<div className="flex items-center gap-2">
<div
className="w-4 h-4 border border-gray-300"
style={{ backgroundColor: "#a82838" }}
></div>
<span className="text-sm text-[#2A2C3F] dark:text-[#EEE5E5]">
{t("expo.areas.tly")}
</span>
</div>
</div>
)}

View File

@@ -4,14 +4,12 @@ import { vipnagorgialla } from "@/components/Vipnagorgialla";
import SectionDivider from "@/components/SectionDivider";
import { getTranslations, setRequestLocale } from "next-intl/server";
// Map of valid slugs to their corresponding file paths and translation keys
// Map of valid slugs to their translation keys
const rulesMap = {
lol: {
filePath: "src/data/rules/lol.md",
titleKey: "rules.lolRules",
},
cs2: {
filePath: "src/data/rules/cs2.md",
titleKey: "rules.cs2Rules",
},
} as const;
@@ -22,7 +20,7 @@ interface PageProps {
params: Promise<{ slug: string; locale: string }>;
}
async function getRuleContent(slug: string) {
async function getRuleContent(slug: string, locale: string) {
if (!Object.keys(rulesMap).includes(slug)) {
return null;
}
@@ -30,14 +28,29 @@ async function getRuleContent(slug: string) {
const ruleConfig = rulesMap[slug as RuleSlug];
try {
const file = Bun.file(ruleConfig.filePath);
// Try to load the file for the current locale first
let filePath = `src/data/rules/${locale}/${slug}.md`;
let file = Bun.file(filePath);
// Check if file exists, if not fallback to Estonian
if (!(await file.exists()) && locale !== "et") {
console.warn(
`Rules file not found for ${slug} in ${locale}, falling back to Estonian`,
);
filePath = `src/data/rules/et/${slug}.md`;
file = Bun.file(filePath);
}
const content = await file.text();
return {
content,
titleKey: ruleConfig.titleKey,
};
} catch (error) {
console.error(`Error reading rule file for slug ${slug}:`, error);
console.error(
`Error reading rule file for slug ${slug} in locale ${locale}:`,
error,
);
return null;
}
}
@@ -46,7 +59,7 @@ export default async function RulePage({ params }: PageProps) {
const { slug, locale } = await params;
setRequestLocale(locale);
const t = await getTranslations({ locale });
const ruleData = await getRuleContent(slug);
const ruleData = await getRuleContent(slug, locale);
if (!ruleData) {
notFound();