from dataclasses import dataclass

@dataclass
class Language:
    supports = ['zh_CN', 'en_US']
    select = supports[0]
    zh_CN = {
        'Home': "主页",
        'boot img': "boot镜像",
        'choose file': "选择文件",
        'arch': "架构",
        'keep verity': "保持验证",
        'keep encypt': "保持强制加密",
        'patch vbmeta flag': "修补vbmeta标志",
        'legacy sar': "传统SAR设备 (如果你的设备是system-as-root但不是动态设备需勾选此项)",
        'start patch': "开始修补",
        'clean': "清除输出",
        'recovery': "修补recovery",
        'Select and Download': "选择与下载",
        'settings': "设置",
        'use proxy': "使用代理",
        'github mirror': "Github镜像源",
        'input your git mirror here': "在此处填入你的镜像链接",
        'use jsdelivr': "使用jsdelivr加速下载",
        'use local file': "使用本地文件修补",
        'use delta magisk': "使用delta面具修补",
        'refresh list': "刷新列表",
        'available magisk list': "可用的magisk版本",
        'magisk is not select': "当前未选择magisk安装包",
        'Other': "其他",
        'introduce': "介绍",
        'vist github': "访问开源地址",
        'log level': "日志等级",
        'scaling': "缩放",
        'Based on CustomTkinter': "此界面基于[CustomTkinter]库",
        'progress': "进度",

        'please select a exist boot image': "- 请选择一个存在的boot镜像",
        'please select a valid magisk apk': "- 请选择一个合理并存在的magisk安装包",
        'detect select magisk version is': "- 检测到apk的magisk版本为",
        'file not exist, ready to download': "- 文件不存在， 准备下载...",
        'use mirror download': "- 使用镜像网站下载...",
        'file exist, no need download': "- 文件存在，无需重复下载...",
        'current magisk': "- 当前magisk版本...",
        'refresh magisk list': "- 刷新magisk列表",
        'use from local prebuilt dir': "- 从本地prebuil目录获取",
        'no magisk in prebuilt, please downloadn and place': "- 没有找到magisk安装包，请手动下载后放置在工作目录下",
        'work dir': "工作目录",
        'cannot find any apk, please download and put them into prebuilt dir':"- 没有在本地目录找到任何安装包，请手动下载后放入prebuilt目录",
        'select a boot image': "选择一个boot镜像",

        'get version faild, please check net or add proxy': "获取版本失败，请检查网络或尝试添加代理...",
        'internet connect faild or cannot connect target url': "- 网络异常或无法连接到目标链接...",
        'start download': "开始下载",
        'download complete': "下载完成",
        'start decompress needed': "- 开始解压需要的文件...",

        'cannot initilazed with magiskboot': "- magiskboot文件不存在，无法完成初始化",
        'boot image does not exist':"- boot 镜像不存在",
        'unpack boot image': "- 解包boot镜像...",
        'unknow/unsupport format': "! 不支持/未知 镜像格式",
        'chromeos format boot':"- ChromeOS 格式boot镜像",
        'not support yet': "- 暂不支持",
        'unable to unpack boot': "! 无法解包此boot镜像",
        'check ramdisk status': "- 检查ramdisk状态",
        'detect original boot': "- 检测到原始未修改的boot镜像",
        'detect magisk patched boot': "- 检测到经过magisk修补过的boot镜像",
        'boot patched by unknow program': "- boot镜像被未知的程序修改过",
        'please resotre original boot':"- 请先将其还原之原始的boot镜像",
        'patch ramdisk': "- 修补ramdisk",
        'unable to patch ramdisk':"- 无法修补ramdisk",
        'boot image patched by old magisk': "- Boot 镜像中的%s被旧的magisk修补过",
        'please try again with original boot': "- 请使用没有修改过的boot镜像再试一次",
        'patch boot image fstab': "- 修补boot镜像中%s的fstab",
        'repack boot image': "- 打包boot镜像",
        'faild to repack boot image': "- 打包boot镜像失败",
        'done': "- 完成！",
        'cleanup': "- 清理文件",




    }
    en_US = {
        'Home': "Home",
        'boot img': "Boot Image",
        'choose file': "ChooseFile",
        'arch': "Arch",
        'keep verity': "Keep Verity",
        'keep encypt': "Keep Force Encrypt",
        'patch vbmeta flag': "Patch vbmeta Flag",
        'legacy sar': "Legacy SAR (If your device is system-as-root BUT not dynamic partitions)",
        'start patch': "StartPatch",
        'clean': 'Clean',
        'recovery': "Patch recovery",
        'Select and Download': "Select and Download",
        'settings': "Settings",
        'use proxy': "Use Proxy",
        'github mirror': "Github Mirror",
        'input your git mirror here': "Insert your mirror url here",
        'use jsdelivr': "Use jsdilivr download",
        'use local file': "Use Local Magisk Apk",
        'use delta magisk': "Use Delta Magisk",
        'refresh list': "RefreshList",
        'available magisk list': "Available Magisk APK",
        'magisk is not select': "No magisk APK selected",
        'Other': "Other",
        'introduce': "Introduce",
        'vist github': "Visit Source",
        'log level': "Log Level",
        'scaling': "Scaling",
        'Based on CustomTkinter': "Based on [CustomTkinter]",
        'progress': "Progress",

        'please select a exist boot image': "- Please select a Exist boot image",
        'please select a valid magisk apk': "- Please Select a Valid magisk apk",
        'detect select magisk version is': "- Detect select magisk version is",
        'file not exist, ready to download': "- File does not exist , Prepare to download...",
        'use mirror download': "- Download from github mirror...",
        'file exist, no need download': "- File already exist, no need to download...",
        'current magisk': "- Current Magisk version...",
        'refresh magisk list': "- Refresh Magisk list",
        'use from local prebuilt dir': "- Get magisk from local prebuilt dir",
        'no magisk in prebuilt, please downloadn and place': "- Cannot find magisk apk, please download and put into prebuilt dir",
        'work dir': "WorkDir",
        'cannot find any apk, please download and put them into prebuilt dir':"- Cannot find any magisk apk in prebuilt, please downlaod and put into prebuilt dir",
        'select a boot image': "Select a boot image",

        'get version faild, please check net or add proxy': "Get Releases failed, please try to redownload or add proxy...",
        'internet connect faild or cannot connect target url': "- Connect Failed...",
        'start download': "Start download",
        'download complete': "Downlaod Complete",
        'start decompress needed': "- Start decompress needed...",

        'cannot initilazed with magiskboot': "- Cannot initialized with magiskboot",
        'boot image does not exist':"- boot does not exist",
        'unpack boot image': "- Unpacking boot image",
        'unknow/unsupport format': "! Unsupported/Unknown image format",
        'chromeos format boot':"- ChromeOS boot image detected",
        'not support yet': "- Unsupport yet",
        'unable to unpack boot': "! Unable to unpack boot image",
        'check ramdisk status': "- Checking ramdisk status",
        'detect original boot': "- Stock boot image detected",
        'detect magisk patched boot': "- Magisk patched boot image detected",
        'boot patched by unknow program': "- Boot image patched by unsupported programs",
        'please resotre original boot':"- Please restore back to stock boot image",
        'patch ramdisk': "- Patching ramdisk",
        'unable to patch ramdisk':"- Unable to patch ramdisk",
        'boot image patched by old magisk': "- Boot image %s was patched by old (unsupported) Magisk",
        'please try again with original boot': "- Please try again with *unpatched* boot image",
        'patch boot image fstab': "- Patch fstab in boot image %s",
        'repack boot image': "- Repacking boot image",
        'faild to repack boot image': "- Unable to repack boot image",
        'done': "- Done !",
        'cleanup': "- Cleanup...",
    }

def langget(key) -> str:
    try:
        val = getattr(Language, Language.select).get(key)
        if val:
            return val
        else: return key
    except: return key
