aboutsummaryrefslogtreecommitdiffhomepage
path: root/translate.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-01-04 22:51:02 +1000
committerGravatar axel <axel@liljencrantz.se>2006-01-04 22:51:02 +1000
commitec43c635cc65145dc4c36b4b284b86119534533e (patch)
treef563bf720ab28d1269a0be9805a3fef4dbd6e05d /translate.c
parent26de6ba26b71f06c15ee7e8a54a7b52e0437047d (diff)
Add i18n through gettext, as well as a Swedish translation
darcs-hash:20060104125102-ac50b-5bf026578a69bd94f7a7a3c8dee0ebccd95e5c24.gz
Diffstat (limited to 'translate.c')
-rw-r--r--translate.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/translate.c b/translate.c
new file mode 100644
index 00000000..4bf60a35
--- /dev/null
+++ b/translate.c
@@ -0,0 +1,78 @@
+/** \file translate.c
+
+Translation library, internally uses catgets
+
+*/
+
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <libintl.h>
+
+#include "common.h"
+#include "util.h"
+
+#if HAVE_GETTEXT
+
+#define BUFF_COUNT 64
+
+static string_buffer_t buff[BUFF_COUNT];
+static int curr_buff=0;
+
+const wchar_t *wgettext( const wchar_t *in )
+{
+ char *mbs_in = 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;
+
+/*
+ write( 2, res, strlen(res) );
+*/
+// debug( 1, L"%ls -> %s (%d) -> %ls (%d)\n", in, out, strlen(out) , wres, wcslen(wres) );
+
+ return wres;
+}
+
+
+void translate_init()
+{
+ int i;
+
+ for(i=0; i<BUFF_COUNT; i++ )
+ sb_init( &buff[i] );
+
+ bindtextdomain( PACKAGE_NAME, LOCALEDIR );
+ textdomain( PACKAGE_NAME );
+
+}
+
+void translate_destroy()
+{
+ int i;
+
+ for(i=0; i<BUFF_COUNT; i++ )
+ sb_destroy( &buff[i] );
+}
+
+#else
+
+const wchar_t *wgettext( const wchar_t *in )
+{
+ return in;
+}
+
+void translate_init()
+{
+}
+
+void translate_destroy()
+{
+}
+
+#endif