require "smartinput"

local lng = smartinput.new_language("拼", "Pinyin")
lng.surfaces = {
    {
        surface_id = "more.sur",
        surface_type = smartinput.surface_type.SOFT_FULLCANDIDATE,
        surface_display_name = "more",
    },

    {
        surface_id = "chspy_soft_phonepad.sur",
        surface_type = smartinput.surface_type.SOFT_KEYBOARD,
        surface_subtype = smartinput.surface_subtype.KEYBOARD_PHONEPAD,
        surface_display_name = "chspy_soft_phonepad",
    },

    {
        surface_id = "chspy_soft_qwerty.sur",
        surface_type = smartinput.surface_type.SOFT_KEYBOARD,
        surface_subtype = smartinput.surface_subtype.KEYBOARD_FULL,
        surface_layout = smartinput.surface_layout.QW,
        surface_display_name = "chspy_soft_qwerty",
    },

    {
        surface_id = "chspy_soft_tplus.sur",
        surface_type = smartinput.surface_type.SOFT_KEYBOARD,
        surface_subtype = smartinput.surface_subtype.KEYBOARD_TPLUS,
        surface_layout = smartinput.surface_layout.QW,
        surface_display_name = "chspy_soft_tplus",
    },

    {
        surface_id = "chs_sym_number.sur",
        surface_type = smartinput.surface_type.SOFT_SYMBOL,
        support_mode = smartinput.context.MATH,
        surface_display_name = "symbol",
    },

    {
        surface_id = "number.sur",
        surface_type = smartinput.surface_type.SOFT_SYMBOL,
        support_mode = smartinput.context.NUMBER + smartinput.context.MATH,
        surface_display_name = "number",
    },

    {
        surface_id = "number_left.sur",
        surface_type = smartinput.surface_type.SOFT_SYMBOL,
        surface_display_name = "number_left",
    },

    {
        surface_id = "number_only.sur",
        surface_type = smartinput.surface_type.SOFT_SYMBOL,
        surface_display_name = "number_only",
    },

    {
        surface_id = "chs_abc.sur",
        surface_type = smartinput.surface_type.SOFT_SPECIAL,
        surface_layout = smartinput.surface_layout.QW,
        surface_display_name = "abc",
    },
}

lng.support_keyboard = {
	smartinput.keyboard_type.SOFT_KEYBOARD
}

lng.categories[smartinput.language.category.FASTSWITCH] = "chinese"
lng.categories[smartinput.language.category.LAYOUT] = "chinese_pinyin"
lng.categories[smartinput.language.category.CELLDICT] = "chinese"
lng.categories[smartinput.language.category.NEXTWORD] = "chinese"


lng.mix_input = {
	"english"
}

lng.traits = "chspy_traits.trt"

lng.dictionary = smartinput.new_engine(smartinput.dictionary.engine_type.OCEAN, smartinput.dictionary.dict_type.CHS_PINYIN)

lng.dictionary.files = {
	{
		file_name = "pinyin.rom",
		file_type = smartinput.dictionary.image_type.ROM,
		open_mode = smartinput.file.READ,
		load_mode = smartinput.dictionary.load_mode.PURE_ARRAY
	},
	{
		file_name = "pinyin.r2m",
		file_type = smartinput.dictionary.image_type.BIGRAM,
		open_mode = smartinput.file.READ,
		load_mode = smartinput.dictionary.load_mode.PURE_ARRAY
	},

	{	
		file_name = "chinese_simplified.usr",
		file_type = smartinput.dictionary.image_type.USR,
		open_mode = smartinput.file.READWRITE
	},

	{
		file_name = "simptrad.rom",
		file_type = smartinput.dictionary.image_type.ROM,
		open_mode = smartinput.file.READ,
		load_mode = smartinput.dictionary.load_mode.PURE_ARRAY
	},
}

lng.get_traits = function ()
    if not lng.loaded_traits then
        lng.loaded_traits = _G.dofile(lng.traits)
    end
    return lng.loaded_traits
end

return lng

