#include "eduwin.h"

static HWND g_hello;   /* 显示翻译文字 */

static void switch_zh(void *data)
{
    (void)data;
    i18n_set_lang("zh");
    set_text(g_hello, i18n_get_str("hello"));
}

static void switch_en(void *data)
{
    (void)data;
    i18n_set_lang("en");
    set_text(g_hello, i18n_get_str("hello"));
}

static void switch_jp(void *data)
{
    (void)data;
    i18n_set_lang("jp");
    set_text(g_hello, i18n_get_str("hello"));
}

int main(void)
{
    if (init_app() != 0) return 1;

    /* 加载翻译文件 */
    i18n_init(L"lang.json");

    HWND win = create_window(i18n_get_str("title"), 420, 180);
    if (!win) return 1;

    /* 翻译文字 */
    g_hello = create_label(win, i18n_get_str("hello"), 20, 20, 380, 30);

    /* 三个切换按钮 */
    HWND btn_zh = create_button(win, i18n_get_str("switch_to_zh"), 20,  70, 110, 28);
    HWND btn_en = create_button(win, i18n_get_str("switch_to_en"), 155, 70, 110, 28);
    HWND btn_jp = create_button(win, i18n_get_str("switch_to_jp"), 290, 70, 110, 28);

    on_button_click(btn_zh, switch_zh, NULL);
    on_button_click(btn_en, switch_en, NULL);
    on_button_click(btn_jp, switch_jp, NULL);

    show_window(win);
    run_app();
    return 0;
}
