00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef I18N_H
00011 #define I18N_H I18N_H
00012
00013 #ifndef HAVE_NO_I18N
00014 #include <libintl.h>
00015 #include <locale.h>
00016 #include "typedefs.h"
00017
00018 void i18nInit(){
00019 setlocale( LC_ALL, "" );
00020 bindtextdomain( "readesm", PREFIX "/share/locale" );
00021 textdomain( "readesm" );
00022 }
00023
00024 string tr(const string& in){
00025 return (in.empty())? in : gettext(in.c_str());
00026 }
00027 string tr(const char* in){
00028 return *in == 0 ? in : gettext(in);
00029 }
00030
00031 char* trc(const char* in){
00032 return gettext(in);
00033 }
00034
00035 #else
00036 #include "typedefs.h"
00037 void i18nInit(){}
00038 string tr(const string& in){ return in; }
00039 string tr(const char* in){ return in; }
00040 const char* trc(const char* in){ return in; }
00041 #endif
00042
00043 string latin1tounicode(unsigned char in){
00044 if(in <= 127){
00045 static char dummy[] = { 0, 0 };
00046 dummy[0] = in;
00047 return dummy;
00048 }
00049 if(in < 160) return string();
00050 const char* conversion[]= { " ", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "\xc2\xad", "®", "¯", \
00051 "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", \
00052 "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", \
00053 "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", \
00054 "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", \
00055 "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ" };
00056 if(in <= 255) return conversion[in - 160];
00057 return "";
00058 }
00059 #endif