Files
gunshiz 316a1eecfa
CI / Build immutable images and deploy (push) Has been cancelled
CI / Verify (push) Has been cancelled
fix(ui) : keep technical labels English and compact badges
2026-09-14 17:43:29 +07:00

163 lines
6.9 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { Locale } from "@/lib/i18n/locales";
export type { Locale } from "@/lib/i18n/locales";
const english = {
exportImage: "Export image",
withoutNote: "Export without note",
exporting: "Exporting…",
exportError: "Could not export the image. Please try again.",
damageTitle: "Choose a damage metric",
damageDescription: "Choose the damage metric for your weapon comparison image.",
overallDamage: "Overall Damage",
personalDamage: "Personal Damage",
weaponTitle: "{name} Weapons",
condition: "Condition {index}",
sectionTitle: "Choose what to export",
sectionDescription: "Select individual sections or choose All sections to export everything.",
allSections: "All sections",
tierlist: "Artifact Tier List",
bestStats: "Best Main Stats & Substats",
targetStats: "Target Stats",
talents: "Talent Priority",
addNote: "Include note",
recommendedCondition: "Recommended stats condition",
targetCondition: "Target stats condition",
mainStats: "Best Main Stats",
substats: "Best Substats",
sands: "Sands",
goblet: "Goblet",
circlet: "Circlet",
artifactRecommendation: "Recommended Artifacts & Stats",
artifactTitle: "Artifacts & Stats",
lateGame: "Late Game",
earlyGame: "Early Game",
minimumStats: "Recommended Minimum Stats",
level: "Level {level}+",
normalAttack: "Normal Attack",
skill: "Elemental Skill",
burst: "Elemental Burst",
note: "Notes",
extraGuide: "Additional Guide",
missingItem: "Item unavailable",
constellationTitle: "{name}’s Constellations",
teamDamage: "Team Damage",
rotation: "Rotation duration: {seconds} seconds",
teamCredit: "Genshin isnt Mobile Game",
watermark: "Genshin isnt Mobile Game",
disclaimer: "Results cannot be directly compared with other theorycrafters’ calculations,\nas each uses different stats.\nThe figures shown may change in future updates.",
overviewDownloaded: "Overview image downloaded.",
downloadPng: "Download PNG {width}×{height}",
materials: "MATERIALS",
materialLevel: "LV.{level}"
} as const;
export type ExportMessageKey = keyof typeof english;
// Technical headings and labels use English in every locale.
const thai: Record<ExportMessageKey, string> = {
exportImage: "ส่งออกภาพ",
withoutNote: "ส่งออกภาพโดยไม่รวมโน้ต",
exporting: "กำลังส่งออก…",
exportError: "ส่งออกภาพไม่สำเร็จ กรุณาลองอีกครั้ง",
damageTitle: "เลือกประเภทดาเมจ",
damageDescription: "เลือกค่าที่ต้องการใช้สร้างภาพเปรียบเทียบอาวุธ",
overallDamage: english.overallDamage,
personalDamage: english.personalDamage,
weaponTitle: english.weaponTitle,
condition: english.condition,
sectionTitle: "เลือกข้อมูลสำหรับส่งออก",
sectionDescription: "เลือกได้หลายส่วน หรือเลือกทั้งหมดเพื่อส่งออกทุกส่วน",
allSections: "ทั้งหมด",
tierlist: english.tierlist,
bestStats: english.bestStats,
targetStats: english.targetStats,
talents: english.talents,
addNote: "รวมโน้ต",
recommendedCondition: english.recommendedCondition,
targetCondition: english.targetCondition,
mainStats: english.mainStats,
substats: english.substats,
sands: english.sands,
goblet: english.goblet,
circlet: english.circlet,
artifactRecommendation: english.artifactRecommendation,
artifactTitle: english.artifactTitle,
lateGame: english.lateGame,
earlyGame: english.earlyGame,
minimumStats: english.minimumStats,
level: english.level,
normalAttack: english.normalAttack,
skill: english.skill,
burst: english.burst,
note: "โน็ต",
extraGuide: "คู่มือเสริม",
missingItem: "ไม่พบรายการ",
constellationTitle: english.constellationTitle,
teamDamage: english.teamDamage,
rotation: english.rotation,
teamCredit: "Genshin isnt Mobile Game",
watermark: "Genshin isnt Mobile Game",
disclaimer: "ไม่สามารถเอาไปเปรียบเทียบกับการคำนวณของ TC ท่านอื่นๆได้\nเพราะแต่ละคนใช้สแตทในการคำนวณที่ไม่เหมือนกัน\nและตารางที่เห็นอาจมีการเปลี่ยนแปลงได้ในอนาคต",
overviewDownloaded: "ดาวน์โหลดภาพ Overview แล้ว",
downloadPng: "ดาวน์โหลด PNG {width}×{height}",
materials: english.materials,
materialLevel: english.materialLevel
};
export const exportMessages = { en: english, th: thai };
export function exportText(
key: ExportMessageKey,
params: Record<string, string | number> = {},
locale: Locale = "en",
): string {
return exportMessages[locale][key].replace(
/\{(\w+)\}/gu,
(placeholder, name: string) => String(params[name] ?? placeholder),
);
}
export function withoutNotesFileName(fileName: string): string {
return /\.[^.]+$/u.test(fileName)
? fileName.replace(/(\.[^.]+)$/u, "-without-notes$1")
: `${fileName}-without-notes`;
}
const thaiStats: Record<string, string> = {
HP: "พลังชีวิต",
ATK: "พลังโจมตี",
DEF: "พลังป้องกัน",
EM: "ความชำนาญธาตุ",
ER: "ฟื้นฟูพลังงาน",
"CRIT RATE": "อัตราคริ",
"CRIT DAMAGE": "ความแรงคริ",
"ATK%": "พลังโจมตี%",
"HP%": "พลังชีวิต%",
"DEF%": "พลังป้องกัน%",
"CRIT Rate%/CRIT DMG%": "อัตราคริ/ความแรงคริ",
"Pyro DMG%": "ความเสียหายธาตุไฟ%",
"Hydro DMG%": "ความเสียหายธาตุน้ำ%",
"Cryo DMG%": "ความเสียหายธาตุน้ำแข็ง%",
"Electro DMG%": "ความเสียหายธาตุไฟฟ้า%",
"Anemo DMG%": "ความเสียหายธาตุลม%",
"Geo DMG%": "ความเสียหายธาตุดิน%",
"Dendro DMG%": "ความเสียหายธาตุไม้%",
"Physical DMG%": "ความเสียหายกายภาพ%",
"Healing Bonus%": "โบนัสการรักษา%",
};
const englishStats: Record<string, string> = {
HP: "HP",
ATK: "ATK",
DEF: "DEF",
EM: "Elemental Mastery",
ER: "Energy Recharge",
"CRIT RATE": "CRIT Rate",
"CRIT DAMAGE": "CRIT DMG",
"CRIT Rate%/CRIT DMG%": "CRIT Rate / CRIT DMG",
};
export function exportStatLabel(value: string, locale: Locale = "en"): string {
return (locale === "th" ? thaiStats : englishStats)[value] ?? value;
}