diff options
author | axel <axel@liljencrantz.se> | 2006-01-05 23:41:59 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2006-01-05 23:41:59 +1000 |
commit | e12902fe3cff878371719ab7df490a5e98cfabc9 (patch) | |
tree | 70b3764110132c4965a9c7ec61f65da5da98a8f7 /translate.c | |
parent | 48030576e4d8b8ad0425109dd478544e57357554 (diff) |
Translate most shellscript output, translate internal completion descriptions, and several translation bugfixes
darcs-hash:20060105134159-ac50b-0a7805971e079dd1a511c6bca227db4504902ef0.gz
Diffstat (limited to 'translate.c')
-rw-r--r-- | translate.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/translate.c b/translate.c index 4bf60a35..b2b778ca 100644 --- a/translate.c +++ b/translate.c @@ -20,13 +20,36 @@ Translation library, internally uses catgets static string_buffer_t buff[BUFF_COUNT]; static int curr_buff=0; +static char *wcs2str_buff=0; +static size_t wcs2str_buff_count=0; + +char *translate_wcs2str( const wchar_t *in ) +{ + size_t len = MAX_UTF8_BYTES*wcslen(in)+1; + if( len > wcs2str_buff_count ) + { + wcs2str_buff = realloc( wcs2str_buff, len ); + if( wcs2str_buff == 0 ) + { + die_mem(); + } + } + + wcstombs( wcs2str_buff, + in, + MAX_UTF8_BYTES*wcslen(in)+1 ); + + return wcs2str_buff; +} + const wchar_t *wgettext( const wchar_t *in ) { - char *mbs_in = wcs2str( in ); + char *mbs_in = translate_wcs2str( in ); char *out = gettext( mbs_in ); wchar_t *wres=0; sb_clear( &buff[curr_buff] ); + sb_printf( &buff[curr_buff], L"%s", out ); wres = (wchar_t *)buff[curr_buff].buff; curr_buff = (curr_buff+1)%BUFF_COUNT; @@ -58,6 +81,8 @@ void translate_destroy() for(i=0; i<BUFF_COUNT; i++ ) sb_destroy( &buff[i] ); + + free( wcs2str_buff ); } #else |