69 const char *
i18n(
const object *who,
const char *
code) {
72 if (!who || !who->
contr)
98 if (strcmp(code, i18n_files[index].code) == 0)
125 return i18n_files[language].
code;
134 for (index = 0; index <
i18n_count; index++) {
137 i18n_files[index].
code,
138 i18n_files[index].
name 155 while ((next = strstr(line,
"\\n")) != NULL) {
186 while ((file =
readdir(dir)) != NULL) {
187 if (strncmp(file->
d_name,
"messages.", 9) != 0)
190 snprintf(filename,
sizeof(filename),
"%s%s", dirname, file->
d_name);
191 if ((fp = fopen(filename,
"r")) == NULL) {
193 filename, strerror(errno));
202 while (fgets(line,
MAX_BUF, fp)) {
203 if (line[0] !=
'#') {
204 line[strlen(line)-1] =
'\0';
208 token = strtok(line,
"|");
211 token = strtok(NULL,
"|");
224 found = bsearch(&code, i18n_files[
i18n_count].messages, i18n_files[
i18n_count].count,
sizeof(
i18n_message), (
int (*)(
const void *,
const void *))i18n_message_compare_code);
226 LOG(
llevError,
"i18n: no language set in %s\n", filename);
234 if (strcmp(i18n_files[
i18n_count].code,
"en") == 0)
244 LOG(
llevError,
"i18n: couldn't find default language (en)\n");
257 for (message = 0; message < i18n_files[file].
count; message++) {
258 free_string(i18n_files[file].messages[message].code);
259 free_string(i18n_files[file].messages[message].message);
261 free(i18n_files[file].messages);
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
static int i18n_message_compare_code(const i18n_message *a, const i18n_message *b)
sstring add_refcount(sstring str)
int i18n_get_language_by_code(const char *code)
static struct i18n_file * i18n_files
void fatal(enum fatal_error err)
void free_string(sstring str)
DIR * opendir(const char *)
struct i18n_file i18n_file
char d_name[_MAX_FNAME+1]
static void convert_newline(char *line)
int get_language(object *op)
sstring i18n_get_language_code(int language)
struct dirent * readdir(DIR *)
sstring add_string(const char *str)
int i18n_find_language_by_code(const char *code)
struct i18n_message * messages
void LOG(LogLevel logLevel, const char *format,...)
const char * i18n(const object *who, const char *code)
struct i18n_message i18n_message
void i18n_list_languages(object *who)