27
//cannot be instantiated outside translator
28
translator() { current_lang = -1; }
33
/* The single instance that this class will use to gain access to
34
* the member variables such as language names
36
static translator single_instance;
38
/* Methods related to loading a language file into memory */
39
static void load_language_file(FILE* file);
40
static void load_language_iso(const std::string &iso);
44
const char* translate(const char* text) const;
46
stringhashtable_tpl<const char*> texts;
53
static void init_city_names(int lang);
54
static const char* get_city_name(uint nr); ///< return a random city name
55
static int get_count_city_name(void);
58
* Loads up all files of language type from the 'language' directory.
59
* This method must be called for languages to be loaded up, undefined
60
* behaviour may follow if calls to translate message or similar are
61
* called before load has been called
63
static bool load(const std::string &scenario_path);
66
* Get/Set the currently selected language, based on the
69
static int get_language() {
70
return single_instance.current_lang;
73
// returns the id for this language or -1 if not there
74
static int get_language(const char* iso);
76
/** Get information about the currently selected language */
77
static const lang_info* get_lang();
79
static const lang_info* get_langs();
82
* First checks to see whether the language is in bounds, will
83
* then change what language is being used, otherwise prints
84
* an error message, leaving the language as it is
86
static void set_language(int lang);
87
static void set_language(const char* iso);
90
* Returns the number of loaded languages.
92
static int get_language_count() { return single_instance.lang_count; }
95
* Translates a given string(key) to its locale
96
* specific counterpart, using the current language
98
* the second variant just uses the language with the index
99
* @return translated string, (null) if string is null,
100
* or the string if the translation is not found
102
static const char *translate(const char* str);
103
static const char *translate(const char* str, int lang);
106
* @return replacement info for almost any object within the game
108
static const char *compatibility_name(const char* str);
110
// return the name of the month
111
static const char *get_month_name(uint16 month);
28
//cannot be instantiated outside translator
29
translator() { current_lang = -1; }
34
/* The single instance that this class will use to gain access to
35
* the member variables such as language names
37
static translator single_instance;
39
/* Methods related to loading a language file into memory */
40
static void load_language_file(FILE* file);
41
static void load_language_iso(const std::string &iso);
43
static vector_tpl<char*> city_name_list;
44
static vector_tpl<char*> street_name_list;
46
static void load_custom_list( int lang, vector_tpl<char*> &name_list, const char *fileprefix );
50
const char* translate(const char* text) const;
52
stringhashtable_tpl<const char*> texts;
59
static void init_custom_names(int lang);
61
static const vector_tpl<char*> &get_city_name_list() { return city_name_list; }
62
static const vector_tpl<char*> &get_street_name_list() { return street_name_list; }
65
* Loads up all files of language type from the 'language' directory.
66
* This method must be called for languages to be loaded up, undefined
67
* behaviour may follow if calls to translate message or similar are
68
* called before load has been called
70
static bool load(const std::string &scenario_path);
73
* Get/Set the currently selected language, based on the
76
static int get_language() {
77
return single_instance.current_lang;
80
// returns the id for this language or -1 if not there
81
static int get_language(const char* iso);
83
/** Get information about the currently selected language */
84
static const lang_info* get_lang();
86
static const lang_info* get_langs();
89
* First checks to see whether the language is in bounds, will
90
* then change what language is being used, otherwise prints
91
* an error message, leaving the language as it is
93
static void set_language(int lang);
94
static void set_language(const char* iso);
97
* Returns the number of loaded languages.
99
static int get_language_count() { return single_instance.lang_count; }
102
* Translates a given string(key) to its locale
103
* specific counterpart, using the current language
105
* the second variant just uses the language with the index
106
* @return translated string, (null) if string is null,
107
* or the string if the translation is not found
109
static const char *translate(const char* str);
110
static const char *translate(const char* str, int lang);
113
* @return replacement info for almost any object within the game
115
static const char *compatibility_name(const char* str);
117
// return the name of the month
118
static const char *get_month_name(uint16 month);