Crossfire Server, Trunk
languages.cpp File Reference
#include "global.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <memory>
+ Include dependency graph for languages.cpp:

Go to the source code of this file.

Data Structures

struct  i18n_file
 

Functions

static void convert_newline (char *line)
 
const char * i18n (const object *who, const char *code)
 
language_t i18n_find_language_by_code (const char *code)
 
void i18n_free (void)
 
language_t i18n_get_language_by_code (const char *code)
 
sstring i18n_get_language_code (language_t language)
 
void i18n_init (void)
 
void i18n_list_languages (object *who)
 

Variables

static i18n_filei18n_default = nullptr
 
static std::vector< i18n_file * > i18n_files
 

Function Documentation

◆ convert_newline()

static void convert_newline ( char *  line)
static

Replaces '
' by a newline char.

Since we are replacing 2 chars by 1, no overflow should happen.

Parameters
linetext to replace into.

Definition at line 113 of file languages.cpp.

References buf, is_valid_types_gen::line, MAX_BUF, and give::next.

Referenced by i18n_init().

+ Here is the caller graph for this function:

◆ i18n()

const char* i18n ( const object who,
const char *  code 
)

Translate a message in the appropriate language.

Parameters
whowho to translate for.
codestring to translate, usually the English version.
Returns
translated message, or code if not found or who's language is invalid.

Definition at line 42 of file languages.cpp.

References add_string(), mad_mage_user::file, is_valid_types_gen::found, free_string(), sstring, and autojail::who.

Referenced by command_body(), command_delete(), command_passwd(), command_quest(), command_statistics(), confirm_password(), do_harvest(), draw_ext_info(), draw_ext_info_format(), get_name(), get_party_password(), get_password(), key_change_class(), key_roll_stat(), play_again(), quest_display(), quest_info(), receive_player_password(), and roll_again().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ i18n_find_language_by_code()

language_t i18n_find_language_by_code ( const char *  code)

Attempt to find the identifier of a language from its code.

Parameters
codelanguage code.
Returns
index, -1 if not found.

Definition at line 59 of file languages.cpp.

References i18n_files.

Referenced by command_language(), and i18n_get_language_by_code().

+ Here is the caller graph for this function:

◆ i18n_free()

void i18n_free ( void  )

Clears all i18n-related data.

Definition at line 209 of file languages.cpp.

References free_string(), i18n_files, and diamondslots::message.

Referenced by cleanup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ i18n_get_language_by_code()

language_t i18n_get_language_by_code ( const char *  code)

Find the identifier of a language from its code.

Parameters
codelanguage's code.
Returns
language's code, or the default language if code is invalid.

Definition at line 73 of file languages.cpp.

References is_valid_types_gen::found, i18n_default, and i18n_find_language_by_code().

Referenced by check_login(), and get_player().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ i18n_get_language_code()

sstring i18n_get_language_code ( language_t  language)

Return the code of a specified language.

Parameters
languageidentifier of the language.
Returns
language's code, or default language's code if identifier is invalid.

Definition at line 85 of file languages.cpp.

References i18n_file::code, and i18n_default.

Referenced by command_help(), help_topics(), and save_player().

+ Here is the caller graph for this function:

◆ i18n_init()

void i18n_init ( void  )

◆ i18n_list_languages()

void i18n_list_languages ( object who)

List all languages for who.

Parameters
whowho to display languages for.

Definition at line 95 of file languages.cpp.

References draw_ext_info_format(), i18n_files, MSG_SUBTYPE_NONE, MSG_TYPE_COMMAND, NDI_UNIQUE, and autojail::who.

Referenced by command_language().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ i18n_default

i18n_file* i18n_default = nullptr
static

"English" language.

Definition at line 34 of file languages.cpp.

Referenced by i18n_get_language_by_code(), i18n_get_language_code(), and i18n_init().

◆ i18n_files

std::vector<i18n_file *> i18n_files
static

Defined languages.

Definition at line 32 of file languages.cpp.

Referenced by i18n_find_language_by_code(), i18n_free(), i18n_init(), and i18n_list_languages().