[libvoikko] API added: voikkoGetGrammarErrorShortDescription

Harri Pitkänen hatapitk at iki.fi
Mon Oct 14 19:19:44 EEST 2013


We now have a new API function for libvoikko:

/**
 * Get the localized short description of the grammar error.
 * @param error The grammar error
 * @param language ISO language code for the lanugage of error description
 * @return The UTF-8 encoded localized error description. Use
 *         voikkoFreeErrorMessageCstr to delete the message after use.
 */
char * voikkoGetGrammarErrorShortDescription(struct VoikkoGrammarError * 
error, const char * language);

This can be used as a replacement for the old function that is now marked as 
deprecated:

const char * voikko_error_message_cstr(int error_code, const char * language);


Using the new function you can have the error description depend on the 
specific error, not just the error code. And since we now specify that the 
resulting string must be deleted after use it is possible to load the 
descriptions from a file.

What is still missing is a function voikkoGetGrammarErrorTitle that would 
depend on the error code but not on the specific error. This would be needed 
if we wanted to build a settings pane for enabling or disabling checks for 
specific error types (this exists at least in MS Word). But since we don't 
have the UI yet I left this one out for now.

Libreoffice-voikko has also been modified to use the new API.

The implementation for voikkoGetGrammarErrorShortDescription can be found 
under src/grammar/error.cpp. This is where you can plug in your code for 
producing variable error descriptions, reading them form an XML file or 
something like that.

The command line tools and Python/Java/.Net interfaces have not yet been 
updated for the new API.

Harri



More information about the Libvoikko mailing list