rllib  1
Classes | Macros | Functions
rlinifile.h File Reference
#include "rldefine.h"
#include "rlstring.h"
Include dependency graph for rlinifile.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  rlIniFile
 
struct  rlIniFile::_rlSectionName_
 
struct  rlIniFile::_rlSection_
 

Macros

#define rltr(txt)   rltranslate(txt)
 
#define pvtr(txt)   rltranslate2(p->lang_section,txt,&p->mytext2)
 

Functions

int rlSetTranslator (const char *language, const char *inifile=NULL)
 
const char * rltranslate (const char *txt, char **mytext=NULL)
 
const char * rltranslate2 (const char *section, const char *txt, char **mytext=NULL)
 

Macro Definition Documentation

◆ pvtr

#define pvtr (   txt)    rltranslate2(p->lang_section,txt,&p->mytext2)

Definition at line 123 of file rlinifile.h.

◆ rltr

#define rltr (   txt)    rltranslate(txt)

Definition at line 118 of file rlinifile.h.

Function Documentation

◆ rlSetTranslator()

int rlSetTranslator ( const char *  language,
const char *  inifile = NULL 
)

Definition at line 512 of file rlinifile.cpp.

513 {
514  if(inifile != NULL)
515  {
516  if(trIniFile == NULL) trIniFile = new rlIniFile();
517  if(trIniFile->read(inifile) < 0) return -1;
518  }
519  trIniFile->setDefaultSection(language);
520  return 0;
521 }
static rlIniFile * trIniFile
Definition: rlinifile.cpp:510
int read(const char *filename)
Definition: rlinifile.cpp:116
void setDefaultSection(const char *section)
Definition: rlinifile.cpp:483

◆ rltranslate()

const char* rltranslate ( const char *  txt,
char **  mytext = NULL 
)

Definition at line 545 of file rlinifile.cpp.

546 {
547  if(trIniFile == NULL) return fixquote(txt,mytext); // use original language because translator is not initalized
548  const char *text = trIniFile->i18n(txt,"@"); // translate
549  if(strcmp(text,"@") == 0) return fixquote(txt,mytext); // use original language because there is no tranlation available
550  return fixquote(text,mytext); // return the translated text
551 }
static rlIniFile * trIniFile
Definition: rlinifile.cpp:510
const char * i18n(const char *tag, const char *default_text="")
Definition: rlinifile.cpp:493
static const char * fixquote(const char *text, char **mytext)
Definition: rlinifile.cpp:523

◆ rltranslate2()

const char* rltranslate2 ( const char *  section,
const char *  txt,
char **  mytext = NULL 
)

Definition at line 553 of file rlinifile.cpp.

554 {
555  //printf("rltranslate2(%s,%s) mytext=%s\n", section, txt, *mytext);
556  if(trIniFile == NULL) return fixquote(txt,mytext); // use original language because translator is not initalized
557  if(*section == '\0') return rltranslate(txt,mytext); // user did not call pvSelectLanguage()
558  const char *text = trIniFile->text(section,txt); // translate
559  if(text[0] == '\0') return fixquote(txt,mytext); // use original language because there is no tranlation available
560  return fixquote(text,mytext); // return the translated text
561 }
static rlIniFile * trIniFile
Definition: rlinifile.cpp:510
const char * text(const char *section, const char *name)
Definition: rlinifile.cpp:208
const char * rltranslate(const char *txt, char **mytext)
Definition: rlinifile.cpp:545
static const char * fixquote(const char *text, char **mytext)
Definition: rlinifile.cpp:523