Пример #1
0
// LoadDict wraps enchant_broker_request_dict, and adds
// the loaded dictionary to the Enchant instance.
// It takes a language code name, such as "en_GB", as string
// argument, and it returns a EnchantDict representation
// of this dictionary.
func (e *Enchant) LoadDict(name string) {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))

	if e.dict != nil {
		C.enchant_broker_free_dict(e.broker, e.dict)
	}
	dict := C.enchant_broker_request_dict(e.broker, cName)
	e.dict = dict
}
Пример #2
0
// LoadDict wraps enchant_broker_request_dict, and adds
// the loaded dictionary to the Enchant instance.
// It takes a language code name, such as "en_GB", as string
// argument, and it returns a EnchantDict representation
// of this dictionary.
func (e *Enchant) LoadDict(name string) (Dict, error) {
	cName := C.CString(name)
	defer C.free(unsafe.Pointer(cName))

	dict := C.enchant_broker_request_dict(e.broker, cName)
	if dict == nil {
		return Dict{}, errors.New("Cannot load dictionary")
	}
	return Dict{dict}, nil
}