package i18n

// Language represents supported languages
type Language int

const (
	English Language = iota
	Chinese
)

// Localization contains all text strings for the game
type Localization struct {
	Next     string
	Score    string
	Level    string
	Controls string
	Move     string
	Rotate   string
	SoftDrop string
	HardDrop string
	GameOver string
	Restart  string
	Language string
	PressL   string
	PressE   string
}

// currentLanguage holds the current language setting
var currentLanguage Language = English

// localizations contains all supported language strings
var localizations = map[Language]Localization{
	English: {
		Next:     "NEXT:",
		Score:    "Score: %d",
		Level:    "Level: %d",
		Controls: "CONTROLS:",
		Move:     "← →  Move",
		Rotate:   "↑    Rotate",
		SoftDrop: "↓    Soft Drop",
		HardDrop: "Space Hard Drop",
		GameOver: "Game Over!",
		Restart:  "Press R to restart",
		Language: "Language:",
		PressL:   "Press L to switch",
		PressE:   "Press Esc to exit",
	},
	Chinese: {
		Next:     "下一个:",
		Score:    "分数: %d",
		Level:    "等级: %d",
		Controls: "操作说明:",
		Move:     "← →  移动",
		Rotate:   "↑    旋转",
		SoftDrop: "↓    软降落",
		HardDrop: "空格  硬降落",
		GameOver: "游戏结束!",
		Restart:  "按 R 重新开始",
		Language: "语言:",
		PressL:   "按 L 切换",
		PressE:   "按 Esc 退出",
	},
}

// GetText returns localized text for the current language
func GetText() Localization {
	return localizations[currentLanguage]
}

// GetCurrentLanguage returns the current language
func GetCurrentLanguage() Language {
	return currentLanguage
}

// SwitchLanguage toggles between supported languages
func SwitchLanguage() {
	switch currentLanguage {
	case English:
		currentLanguage = Chinese
	case Chinese:
		currentLanguage = English
	}
}

// SetLanguage sets the current language
func SetLanguage(lang Language) {
	currentLanguage = lang
}
