2013/6/5 Hans de Goede <hdego...@redhat.com>: > +++ b/libusb/strerror.c > @@ -0,0 +1,205 @@
> +/** \ingroup misc > + * Set the language, and only the language, not the encoding! used for > + * translatable libusb messages. > + * > + * This takes a locale string in the default setlocale format: > + * lang[_country_region][.codeset]. Only the lang part of the string is used, > + * and only 2 letter ISO 639-1 codes are accepted, ie "en". The optional > + * country_regio and codeset parts are ignored. This means that functions country_regio -> country_region > + * which return translatable strings will NOT honor the specified encoding. > + * If lang is en, then all translatable strings will be pure ASCII, for all lang -> locale? The parameter is called locale, not lang. en -> "en" with quotes to indicates a C-string. > + * other languages they will be encoded as UTF-8 strings! > + * > + * If libusb_setlocale() is not called, all messages will be in English. > + * > + * The following functions return translatable strings: libusb_strerror(). > + * Note that the libusb log messages controlled through libusb_set_debug() > + * are not translated, they are always in English. > + * > + * For POSIX UTF-8 environments if you want libusb to follow the standard > + * locale settings, call libusb_setlocale(setlocale(LC_MESSAGES, NULL)), > + * after your app has done its locale setup. > + * > + * \param locale locale-string in the form of lang[_country_region][.codeset] > + * \returns 0 on success 0 -> LIBUSB_SUCCESS > + * \returns LIBUSB_ERROR_NOT_FOUND if the requested language is not supported Can also return LIBUSB_ERROR_INVALID_PARAM for "Unrecognized locale format: " > + * \returns a LIBUSB_ERROR code on other errors Maybe only document used error codes? I checked and the other libusb functions are not extensively documented for the possible error codes returned. So it is up to you to decide how much documentation you want to use. > + */ > +int API_EXPORTED libusb_setlocale(const char *locale) > +{ > + const char * const iso639[] = { > + /* Note the order here MUST match the libusb_locale_enum */ > + "en", /* LANG_EN */ > + "nl", /* LANG_NL */ > + NULL > + }; > + char lang[3] = { 0, }; > + int i; > + > + for (i = 0; > + i < 3 && locale[i] && locale[i] != '_' && locale[i] != '.'; > + i++) > + lang[i] = locale[i]; > + > + if (lang[2] != 0) { > + usbi_warn(NULL, "Unrecognized locale format: %s", locale); > + return LIBUSB_ERROR_INVALID_PARAM; > + } > + > + for (i = 0; iso639[i]; i++) { > + if (strcmp(lang, iso639[i]) == 0) > + break; > + } > + if (!iso639[i]) { > + usbi_warn(NULL, "Unsupported language: %s", lang); > + return LIBUSB_ERROR_NOT_FOUND; > + } > + > + libusb_locale = i; > + > + return LIBUSB_SUCCESS; > +} No more remarks. OK for me. -- Dr. Ludovic Rousseau ------------------------------------------------------------------------------ How ServiceNow helps IT people transform IT departments: 1. A cloud service to automate IT design, transition and operations 2. Dashboards that offer high-level views of enterprise services 3. A single system of record for all IT processes http://p.sf.net/sfu/servicenow-d2d-j _______________________________________________ libusbx-devel mailing list libusbx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libusbx-devel