#include "../include/base.h"
#include <string>
#include <libintl.h>
Include dependency graph for i18n.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Defines | |
#define | _(X) gettext(X) |
Functions | |
std::string | Format (const char *format,...) |
void | InitI18N (const std::string &dir) |
void | I18N_SetDir (const std::string &dir) |
std::string Format | ( | const char * | format, | |
... | ||||
) |
Definition at line 38 of file i18n.cpp.
00038 { 00039 const int bufferSize = 256; 00040 char buffer[bufferSize]; 00041 va_list argp; 00042 std::string result; 00043 00044 va_start(argp, format); 00045 00046 int size = vsnprintf(buffer, bufferSize, format, argp); 00047 00048 if( size < 0 ) 00049 Error( "Error formating string..."); 00050 00051 if( size < bufferSize) 00052 result = std::string(buffer); 00053 else{ 00054 char *bigBuffer = (char *)malloc( (size + 1) * sizeof(char) ); 00055 if( bigBuffer == NULL) 00056 Error( "Out of memory !"); 00057 00058 size = vsnprintf(bigBuffer, size + 1, format, argp); 00059 if( size < 0 ) 00060 Error( "Error formating string..."); 00061 00062 result = std::string(bigBuffer); 00063 free(bigBuffer); 00064 } 00065 00066 va_end(argp); 00067 00068 return result; 00069 }
Here is the caller graph for this function:
void I18N_SetDir | ( | const std::string & | dir | ) |
Definition at line 71 of file i18n.cpp.
00071 { 00072 bindtextdomain(GETTEXT_DOMAIN, dir.c_str()); 00073 bind_textdomain_codeset (GETTEXT_DOMAIN, "UTF-8"); 00074 }
Here is the caller graph for this function:
void InitI18N | ( | const std::string & | dir | ) |
Definition at line 76 of file i18n.cpp.
00076 { 00077 setlocale (LC_ALL, ""); 00078 I18N_SetDir (dir); 00079 textdomain(GETTEXT_DOMAIN); 00080 }
Here is the call graph for this function:
Here is the caller graph for this function: