mirror of https://github.com/hykilpikonna/AquaDX
[+] More i18n
parent
3faa5b2f52
commit
16f6acf8fc
|
@ -16,9 +16,9 @@ if (navigator.language.startsWith('zh')) {
|
|||
lang = 'zh'
|
||||
}
|
||||
|
||||
export function t(key: keyof LocalizedMessages, variables?: { [index: string]: string }) {
|
||||
export function t(key: keyof LocalizedMessages, variables?: { [index: string]: any }) {
|
||||
if (variables) {
|
||||
return msgs[lang][key].replace(/\${(.*?)}/g, (_: string, v: string | number) => variables[v])
|
||||
return msgs[lang][key].replace(/\${(.*?)}/g, (_: string, v: string | number) => variables[v] + "")
|
||||
}
|
||||
return msgs[lang][key]
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
export const EN_REF_USER = {
|
||||
'UserHome.ServerRank': 'Server Rank',
|
||||
'UserHome.Rating': 'DX Rating',
|
||||
'UserHome.DXRating': 'DX Rating',
|
||||
'UserHome.Rating': 'Rating',
|
||||
'UserHome.Statistics': 'Statistics',
|
||||
'UserHome.Accuracy': 'Accuracy',
|
||||
'UserHome.DXScore': 'DX Score',
|
||||
|
@ -10,7 +11,12 @@ export const EN_REF_USER = {
|
|||
'UserHome.FirstSeen': 'First Seen',
|
||||
'UserHome.LastSeen': 'Last Seen',
|
||||
'UserHome.Version': 'Last Version',
|
||||
'UserHome.RecentScores': 'Recent Scores'
|
||||
'UserHome.RecentScores': 'Recent Scores',
|
||||
'UserHome.NoData': 'No data in the past ${days} days',
|
||||
'UserHome.Game.Mai2': "Mai",
|
||||
'UserHome.Game.Chu3': "Chuni",
|
||||
'UserHome.Game.Ongeki': "Ongeki",
|
||||
'UserHome.UnknownSong': "(unknown song)",
|
||||
}
|
||||
|
||||
export const EN_REF_Welcome = {
|
||||
|
|
|
@ -2,17 +2,23 @@ import { EN_REF_USER, type EN_REF_Welcome } from "./en_ref";
|
|||
|
||||
const zhUser: typeof EN_REF_USER = {
|
||||
'UserHome.ServerRank': '服务器排名',
|
||||
'UserHome.Rating': 'DX B50分',
|
||||
'UserHome.DXRating': 'DX B50',
|
||||
'UserHome.Rating': '评分',
|
||||
'UserHome.Statistics': '统计数据',
|
||||
'UserHome.Accuracy': '准确度',
|
||||
'UserHome.Accuracy': '准确率',
|
||||
'UserHome.DXScore': 'DX 得分',
|
||||
'UserHome.PlayActivity': '游戏活动',
|
||||
'UserHome.Plays': '出勤次',
|
||||
'UserHome.PlayTime': '出勤时间',
|
||||
'UserHome.Plays': '出勤次数',
|
||||
'UserHome.PlayTime': '游玩时间',
|
||||
'UserHome.FirstSeen': '发现新大陆',
|
||||
'UserHome.LastSeen': '上次出勤',
|
||||
'UserHome.Version': '最新最热否',
|
||||
'UserHome.RecentScores': '我的战绩'
|
||||
'UserHome.RecentScores': '成绩',
|
||||
'UserHome.NoData': '过去 ${days} 天内没有玩过',
|
||||
'UserHome.Game.Mai2': "舞萌",
|
||||
'UserHome.Game.Chu3': "中二",
|
||||
'UserHome.Game.Ongeki': "音击",
|
||||
'UserHome.UnknownSong': "(未知曲目)",
|
||||
}
|
||||
|
||||
const zhWelcome: typeof EN_REF_Welcome = {
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
import Icon from "@iconify/svelte";
|
||||
import {t} from "../libs/i18n";
|
||||
|
||||
const TREND_DAYS = 60
|
||||
|
||||
registerChart()
|
||||
|
||||
export let username: string;
|
||||
|
@ -39,7 +41,7 @@
|
|||
console.log(user)
|
||||
console.log(trend)
|
||||
|
||||
const minDate = moment().subtract(60, 'days').format("YYYY-MM-DD")
|
||||
const minDate = moment().subtract(TREND_DAYS, 'days').format("YYYY-MM-DD")
|
||||
d = {user,
|
||||
trend: trend.filter(it => it.date >= minDate),
|
||||
recent: user.recent.map(it => {return {...music[it.musicId], ...it}})
|
||||
|
@ -50,7 +52,7 @@
|
|||
})
|
||||
}).catch((e) => error = e.message);
|
||||
|
||||
const games = {chu3: 'Chuni', mai2: 'Mai', ongeki: 'Ongeki'}
|
||||
const games = {chu3: t("UserHome.Game.Chu3"), mai2: t("UserHome.Game.Mai2"), ongeki: t("UserHome.Game.Ongeki")}
|
||||
const titleText = games[game]
|
||||
</script>
|
||||
|
||||
|
@ -79,7 +81,7 @@
|
|||
<div class="chart">
|
||||
<div class="info-top">
|
||||
<div class="rating">
|
||||
<span>{game === 'mai2' ? t("UserHome.Rating"): 'Rating'}</span>
|
||||
<span>{game === 'mai2' ? t("UserHome.DXRating"): t("UserHome.Rating")}</span>
|
||||
<span>{d.user.rating.toLocaleString()}</span>
|
||||
</div>
|
||||
|
||||
|
@ -93,7 +95,7 @@
|
|||
<!-- ChartJS cannot be fully responsive unless there is a parent div that's independent from its size and helps it determine its size -->
|
||||
<div class="chartjs-box-reference">
|
||||
{#if d.trend.length === 0}
|
||||
<div class="no-data">No data in the past 60 days</div>
|
||||
<div class="no-data">{t("UserHome.NoData", { days: TREND_DAYS })}</div>
|
||||
{:else}
|
||||
<Line data={{
|
||||
datasets: [
|
||||
|
@ -191,7 +193,7 @@
|
|||
<div class:alt={i % 2 === 0}>
|
||||
<img src={`${DATA_HOST}/d/${game}/music/00${r.musicId.toString().padStart(6, '0').substring(2)}.png`} alt="" on:error={coverNotFound} />
|
||||
<div class="info">
|
||||
<div>{r.name ??"Unable find music"}</div>
|
||||
<div>{r.name ?? t("UserHome.UnknownSong")}</div>
|
||||
<div>
|
||||
<span class={`lv level-${r.level === 10 ? 3 : r.level}`}>
|
||||
{ r.notes?.[r.level === 10 ? 0 : r.level]?.lv?.toFixed(1) ?? r.level ?? '0'}
|
||||
|
|
Loading…
Reference in New Issue