rllib  1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions | Variables
rlinifile.cpp File Reference
#include "rldefine.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <windows.h>
#include "rlinifile.h"
#include "rlcutil.h"
Include dependency graph for rlinifile.cpp:

Go to the source code of this file.

Functions

int rlSetTranslator (const char *language, const char *inifile)
 
static const char * fixquote (const char *text, char **mytext)
 
const char * rltranslate (const char *txt, char **mytext)
 
const char * rltranslate2 (const char *section, const char *txt, char **mytext)
 

Variables

static const char null_string [] = ""
 
static rlIniFiletrIniFile = NULL
 

Function Documentation

static const char* fixquote ( const char *  text,
char **  mytext 
)
static

Definition at line 519 of file rlinifile.cpp.

{
if(strchr(text,'\\') == NULL) return text;
int len = strlen(text);
if(*mytext != NULL) delete [] *mytext;
*mytext = new char[len+1];
char *temp = *mytext;
int i2 = 0;
for(int i=0; i<len; i++)
{
if (text[i] == '\\' && text[i+1] == '=') { temp[i2] = '='; i++; }
else if(text[i] == '\\' && text[i+1] == 'n') { temp[i2] = '\n'; i++; }
else if(text[i] == '\\' && text[i+1] == 't') { temp[i2] = '\t'; i++; }
else if(text[i] == '\\' && text[i+1] == '\\') { temp[i2] = '\\'; i++; }
else { temp[i2] = text[i]; }
i2++;
}
temp[i2] = '\0';
//printf("fixquote(%s) return=%s\n", text, temp);
return temp;
}
int rlSetTranslator ( const char *  language,
const char *  inifile 
)

Definition at line 508 of file rlinifile.cpp.

{
if(inifile != NULL)
{
if(trIniFile == NULL) trIniFile = new rlIniFile();
if(trIniFile->read(inifile) < 0) return -1;
}
return 0;
}
const char* rltranslate ( const char *  txt,
char **  mytext 
)

Definition at line 541 of file rlinifile.cpp.

{
if(trIniFile == NULL) return fixquote(txt,mytext); // use original language because translator is not initalized
const char *text = trIniFile->i18n(txt,"@"); // translate
if(strcmp(text,"@") == 0) return fixquote(txt,mytext); // use original language because there is no tranlation available
return fixquote(text,mytext); // return the translated text
}
const char* rltranslate2 ( const char *  section,
const char *  txt,
char **  mytext 
)

Definition at line 549 of file rlinifile.cpp.

{
//printf("rltranslate2(%s,%s) mytext=%s\n", section, txt, *mytext);
if(trIniFile == NULL) return fixquote(txt,mytext); // use original language because translator is not initalized
if(*section == '\0') return rltranslate(txt,mytext); // user did not call pvSelectLanguage()
const char *text = trIniFile->text(section,txt); // translate
if(text[0] == '\0') return fixquote(txt,mytext); // use original language because there is no tranlation available
return fixquote(text,mytext); // return the translated text
}

Variable Documentation

const char null_string[] = ""
static

Definition at line 27 of file rlinifile.cpp.

rlIniFile* trIniFile = NULL
static

Definition at line 506 of file rlinifile.cpp.