Hi, On 09/15/2012 04:31 PM, Pete Batard wrote: > On 2012.09.15 11:35, Hans de Goede wrote: >> BTW I agree that we really need to do a libusb_strerror() >> but I also agree that that should handle translations... >> >> For Linux this can be easily done with gettext, but for >> other platforms it cannot... Either way we should honor >> the LANG / LC_MESSAGES setting under Linux for determining >> which language to use for the messages. For other platforms >> we may need a libusb_set_lang or some such ?? > > I've said it before and I'll say it again, though not everybody may like > it; if we want to handle translations in libusb_strerror, we should: > 1. State that the function returns an UTF-8 string always.
Ack. > 2. Have it take an extra parameter (ISO code or something) for the > required translation (would default to returning en_US if not found) and > let the app developer handle the rest. We spent an awful lot of time on > this already, and it baffles the mind that we should waste so much > effort for less than 20 messages. Yeah, it'll make app developers on > Linux add a couple lines of codes to read LANG/LC_MESSAGE and > potentially convert the result UTF-8 to whatever. But that's a fairly > well documented process (heck, I'll write a doc sample on how to do just > that if needed) and not the end of the world. Sounds reasonable, may I suggest one modification though: 1) We make the extra parameter: "const char *lang" (I guess you already had that in mind just stating it explicitly) 2) We add a "const char *(*get_default_lang)(struct libusb_context *ctx);" member to struct usbi_os_backend 3) When the lang param is NULL, then the os_backend get_default_lang op gets called. On Linux + BSD this could do the necessary environment munging, avoiding apps having to duplicate this everywhere. On Windows it could get the language the OS is installed in / configured for, etc. > There, language support done in a matter of minutes, not days. And since > our sources *are* UTF-8, no need for splitting languages in zillions of > subfiles: if someone wants to add a translation, just edit the single > libusb_intl_messages.h or something we'll have, and send us a patch. Sounds good to me, I say go for it! Regards, Hans ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ libusbx-devel mailing list libusbx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libusbx-devel