src/tool/i18n.cpp File Reference

#include "i18n.h"
#include <string>
#include <stdio.h>
#include <stdarg.h>
#include "debug.h"
#include "../config.h"
#include "../game/config.h"

Include dependency graph for i18n.cpp:

Go to the source code of this file.

Defines

#define GETTEXT_DOMAIN   PACKAGE

Functions

std::string Format (const char *format,...)
void I18N_SetDir (const std::string &dir)
void InitI18N (const std::string &dir)


Define Documentation

#define GETTEXT_DOMAIN   PACKAGE

Definition at line 36 of file i18n.cpp.


Function Documentation

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:


Generated on Mon Jan 1 13:26:02 2007 for Wormux by  doxygen 1.4.7