lang.h File Reference


Detailed Description

Supports multiple languages.

Definition in file lang.h.

#include <vector>
#include <string>

Include dependency graph for lang.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void lang_get_langs (int file_id, vector< string > &langs)
 Enumerates available languages.
string lang_get_string (int file_id, string lang, int id)
 Gets language-specific string, and initializes an array if needed.
void lang_rehash ()
 Rehashses the language files.
string lang_subst (string str, string substr)
 Routine for "%s" substitution.


Function Documentation

void lang_get_langs int  file_id,
vector< string > &  langs
 

Enumerates available languages.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
file_id ID of language file ("lang/langID.txt")
langs Returns array of available languages

Definition at line 267 of file lang.cpp.

References FILE_SLASH, lang01, lang01_init, and lang_01_init().

Referenced by dcc_loop_language().

00268 {
00269     langs.clear();
00270 
00271     if(file_id==1 && !lang01_init) {
00272         lang_01_init("lang" FILE_SLASH "lang01.txt");
00273         lang01_init=true;
00274     }
00275     if(file_id==1) {
00276         vector<s_lang>::iterator i;
00277         for(i=lang01.begin(); i!=lang01.end(); i++) {
00278             vector<string>::iterator i1;
00279             bool got=false;
00280             for(i1=langs.begin(); i1!=langs.end(); i1++)
00281                 if(!(*i1).compare((*i).lang)) {
00282                     got=true;
00283                     break;
00284                 }
00285             if(!got)
00286                 langs.push_back((*i).lang);
00287         }
00288     }
00289 }

Here is the call graph for this function:

string lang_get_string int  file_id,
string  lang,
int  id
 

Gets language-specific string, and initializes an array if needed.

Author:
VooDooMan
Version:
1
Date:
2004
Parameters:
file_id ID of language file ("lang/langID.txt")
lang Language identification string
id ID of message
Returns:
Returns language-specific string, if not found, returns an empty string

Definition at line 169 of file lang.cpp.

References FILE_SLASH, lang01, lang01_init, lang_01_init(), and log_debug().

Referenced by botnet_showbots(), dcc_apply(), dcc_broadcast(), dcc_check_for_filesystem(), dcc_check_limit(), dcc_loop(), dcc_loop_edit_chan(), dcc_loop_edit_dynbans(), dcc_loop_edit_proc(), dcc_loop_edit_rproc(), dcc_loop_edit_user1(), dcc_loop_edit_user2(), dcc_loop_filesystem(), dcc_loop_filesystem_disp_rights(), dcc_loop_language(), dcc_loop_msg(), dcc_loop_new_user(), dcc_loop_private(), dcc_loop_replication(), dcc_loop_terminator(), dcc_notify(), dcc_rehashed(), dcc_send_file(), dcc_upgrade(), dcc_upgrade_bot_join(), dcc_upgrade_bot_mode(), dcc_upgrade_bot_nick(), dcc_user_pong(), filesys_build_getfile_message(), filesys_dcc_check_for_notifies(), irc_check_for_filesystem(), irc_loop_process_input(), irc_quoted_callback(), logic_partyline_whois(), logic_rehash(), logic_rollback(), and stats_display().

00170 {
00171     if(file_id==1 && !lang01_init) {
00172         lang_01_init("lang" FILE_SLASH "lang01.txt");
00173         lang01_init=true;
00174     }
00175     if(file_id==1) {
00176         vector<s_lang>::iterator i;
00177         for(i=lang01.begin(); i!=lang01.end(); i++)
00178             if((*i).id==id && !(*i).lang.compare(lang))
00179                 return (*i).text;
00180         char tmp[1024];
00181         sprintf(tmp,"%s%d%s%s%s%d%s","in file " __FILE__ " in function " __FUNC__ " occurred error: cannot get language string: file_id=",file_id," lang=",lang.c_str()," id=",id," - trying default language \"en\"");
00182         log_debug(tmp);
00183         // not found? try "en" as lang
00184         lang="en";
00185         for(i=lang01.begin(); i!=lang01.end(); i++)
00186             if((*i).id==id && !(*i).lang.compare(lang))
00187                 return (*i).text;
00188     }
00189     char tmp[1024];
00190     sprintf(tmp,"%s%d%s%s%s%d","in file " __FILE__ " in function " __FUNC__ " occurred error: cannot get language string: file_id=",file_id," lang=",lang.c_str()," id=",id);
00191     log_debug(tmp);
00192     return "<?>";
00193 }

Here is the call graph for this function:

void lang_rehash  ) 
 

Rehashses the language files.

Author:
VooDooMan
Version:
1
Date:
2004

Definition at line 297 of file lang.cpp.

References FILE_SLASH, lang01_init, and lang_01_init().

Referenced by dcc_loop().

00298 {
00299     lang01_init=false;
00300     lang_01_init("lang" FILE_SLASH "lang01.txt");
00301     lang01_init=true;
00302 }

Here is the call graph for this function:

string lang_subst string  str,
string  substr
 

Routine for "%s" substitution.

Author:
VooDooMan
Version:
2
Date:
2004, 2005
Parameters:
str Message containing at least one "%s" to substitute
substr Substring, wich will be inserted instead of FIRST "%s" found in str
Returns:
Returns resulting string

Definition at line 204 of file lang.cpp.

References log_debug().

Referenced by dcc_apply(), dcc_broadcast(), dcc_loop(), dcc_loop_edit_proc(), dcc_loop_edit_rproc(), dcc_loop_edit_user1(), dcc_loop_edit_user2(), dcc_loop_filesystem(), dcc_loop_filesystem_disp_rights(), dcc_loop_language(), dcc_loop_new_user(), dcc_rehashed(), dcc_user_pong(), and irc_quoted_callback().

00205 {
00206     string res;
00207     int esc=0;
00208     bool got=false;
00209     for(unsigned int i1=0; i1<str.length(); i1++) {
00210         if(esc==0 && str[i1]=='%') {
00211             esc++;
00212             continue;
00213         }
00214         if(esc==1 && str[i1]=='s' /*&& substr.compare("")*/) {
00215             if(!got) {
00216                 got=true;
00217                 res+=substr;
00218                 substr="";
00219             } else {
00220                 res+="%s";
00221             }
00222             esc=0;
00223             continue;
00224         }
00225         if(esc==1 && str[i1]=='s') {
00226             res+="%s";
00227             esc=0;
00228             continue;
00229         }
00230         if((esc==1 || esc==2) && str[i1]=='%') {
00231             res+="%";
00232             continue;
00233         }
00234         res+=str[i1];
00235     }
00236 
00237     if(!got) {
00238         while(str.find("\r",0)!=string::npos)
00239             str.erase(str.find("\r",0),1);
00240         while(str.find("\n",0)!=string::npos)
00241             str.erase(str.find("\n",0),1);
00242 
00243         while(substr.find("\r",0)!=string::npos)
00244             substr.erase(substr.find("\r",0),1);
00245         while(substr.find("\n",0)!=string::npos)
00246             substr.erase(substr.find("\n",0),1);
00247 
00248         string log="Warning: In function " __FUNC__ " I was unable to find \"%s\" sequence to substitute it with sub-string. (following strings will have \\r and \\n stripped off). String was: \"";
00249         log+=str;
00250         log+="\", and sub-string as substituent was: \"";
00251         log+=substr;
00252         log+="\"";
00253         log_debug(log.c_str());
00254     }
00255 
00256     return res;
00257 }

Here is the call graph for this function:


Generated on Sun Jul 10 04:47:57 2005 for VooDoo cIRCle by doxygen 1.4.3

Hosted by SourceForge.net Logo