[+] Leaderboard i18n

pull/23/head
Azalea 2024-03-14 22:41:23 -04:00
parent 10d19a5392
commit ed1ed6cbe9
4 changed files with 29 additions and 9 deletions

View File

@ -23,6 +23,7 @@ export function t(key: keyof LocalizedMessages, variables?: { [index: string]: a
}
return msgs[lang][key]
}
Object.assign(window, { t })
export const GAME_TITLE: { [key in GameName]: string } =
{chu3: t("game.chu3"), mai2: t("game.mai2"), ongeki: t("game.ongeki")}

View File

@ -43,12 +43,21 @@ export const EN_REF_Welcome = {
'welcome.verification-failed': 'Verification failed: ${message}. Please try again.',
}
export const EN_REF_LEADERBOARD = {
'Leaderboard.Title': 'Server Leaderboard',
'Leaderboard.Rank': 'Rank',
'Leaderboard.Rating': 'Rating',
'Leaderboard.Accuracy': 'Accuracy',
'Leaderboard.FC': 'FC',
'Leaderboard.AP': 'AP',
}
export const EN_REF_GENERAL = {
'game.mai2': "Mai",
'game.chu3': "Chuni",
'game.ongeki': "Ongeki",
}
export const EN_REF = { ...EN_REF_USER, ...EN_REF_Welcome, ...EN_REF_GENERAL }
export const EN_REF = { ...EN_REF_USER, ...EN_REF_Welcome, ...EN_REF_GENERAL, ...EN_REF_LEADERBOARD }
export type LocalizedMessages = typeof EN_REF

View File

@ -1,4 +1,4 @@
import { EN_REF_GENERAL, EN_REF_USER, type EN_REF_Welcome } from "./en_ref";
import { EN_REF_GENERAL, EN_REF_LEADERBOARD, EN_REF_USER, type EN_REF_Welcome } from "./en_ref";
const zhUser: typeof EN_REF_USER = {
'UserHome.ServerRank': '服务器排名',
@ -45,10 +45,19 @@ const zhWelcome: typeof EN_REF_Welcome = {
'welcome.verification-failed': '验证失败:${message}。请重试',
}
const zhLeaderboard: typeof EN_REF_LEADERBOARD = {
'Leaderboard.Title': '排行榜',
'Leaderboard.Rank': '排名',
'Leaderboard.Rating': '评分',
'Leaderboard.Accuracy': '准确率',
'Leaderboard.FC': 'FC',
'Leaderboard.AP': 'AP',
}
const zhGeneral: typeof EN_REF_GENERAL = {
'game.mai2': "舞萌",
'game.chu3': "中二",
'game.ongeki': "音击",
}
export const ZH = { ...zhUser, ...zhWelcome, ...zhGeneral }
export const ZH = { ...zhUser, ...zhWelcome, ...zhGeneral, ...zhLeaderboard }

View File

@ -5,6 +5,7 @@
import StatusOverlays from "../components/StatusOverlays.svelte";
import type { GameName } from "../libs/scoring";
import { GAME_TITLE } from "../libs/i18n";
import { t } from "../libs/i18n";
export let game: GameName = 'mai2';
@ -22,7 +23,7 @@
<main class="content leaderboard">
<div class="outer-title-options">
<h2>Global Leaderboard</h2>
<h2>{t("Leaderboard.Title")}</h2>
<nav>
{#each Object.entries(GAME_TITLE) as [k, v]}
<a href="/ranking/{k}" class:active={k === game}>{v}</a>
@ -33,12 +34,12 @@
{#if d}
<div class="leaderboard-container">
<div class="lb-user">
<span class="rank">Rank</span>
<span class="rank">{t("Leaderboard.Rank")}</span>
<span class="name"></span>
<span class="rating">Rating</span>
<span class="accuracy">Accuracy</span>
<span class="fc">FC</span>
<span class="ap">AP</span>
<span class="rating">{t("Leaderboard.Rating")}</span>
<span class="accuracy">{t("Leaderboard.Accuracy")}</span>
<span class="fc">{t("Leaderboard.FC")}</span>
<span class="ap">{t("Leaderboard.AP")}</span>
</div>
{#each d.users as user, i (user.rank)}
<div class="lb-user" class:alternate={i % 2 === 1}>