From: Bjoern V. <bj...@cs...> - 2006-02-11 22:07:12
|
Richard Laager <rl...@wi...> wrote: > I imagine the correct approach is this: > > 1. Pass the format string from Gaim to gettext(). > 2. Convert the output from gettext() from UTF-8 to locale format. > 3. Pass the translated, locale-converted string to strftime(). > 4. Convert the output of strftime() back to UTF-8. > > Thoughts? I see one problem with this approach. The step 2 may not be possible without loosing information, if the user sets an unsuitable locale charset. I mean, that a conversion from UTF-8 to locale charset and back to UTF-8 may change the message: message !=3D conv(conv(message, UTF-8, localecharset), localecharset, UTF-8= ) I do not know, if this is an issue in many languages and locale setups. But already in German it can be an issue: In normal case the locale charset (LC_CTYPE) and the language selection (LC_MESSAGES or LANG) should have compatible values. For instance the locale German/Germany (de_DE) has the following compatible charsets in (SuSE) Linux: ISO-8859-1, ISO-8859-15 and UTF-8. But it's also possible to use "C" or "POSIX" as the charset (LC_CTYPE) selection for German. Then a word like Erd=F6l (lets say in UTF-8) is converted to Erd"ol (in ASCII/POSIX). Unfortunately the conversation from Erd"ol to another charset (for instance UTF-8) is always Erd"ol, but not Erd=F6l (original). As a result the user may see the date/time strings with garbage in some locale setups. I see the following better solutions (which still have problems): 1) Set LC_CTYPE=3DUTF-8 within Gaim. The only problem here is to find the "UTF-8" name (LC_CTYPE value) for each system. On Linux it's "utf8", on Solaris and FreeBSD it's "UTF-8". I prefer this solution because of it's simplicity. But where do we found the necessare UTF-8 locale names? Ethan Blanton wrote about this problem. 2) Usage of date/time strings which only have ASCII-value placeholders (regardless of locale). This means, that we can not use names for days, months etc. (%A, %B, ...) but numbers (%d, %m, ...). This date/time strings for strftime() should be still marked as translatable for the reasons which were explained by Ambrose Li. Example: English (original): _("%m/%d/%Y %H:%M") -> 02/11/2006 22:27 German (translated): "%d.%m.%Y %H:%M" -> 11.02.2006 22:27 With this solution we do not need a character conversation. The user can pass UTF-8 via gettext() into strftime(). strftime() fills the placeholders with ASCII characters (numbers) into the UTF-8 date/time string. The attached patch changes the two problematic date/time strings according to solution 2. Please test this patch and write your comments. Regards, Bj=F6rn |