server/src/util/language.h

71 lines
2.1 KiB
C
Raw Normal View History

2010-08-08 10:06:34 +02:00
#ifndef MY_LOCALE_H
#define MY_LOCALE_H
#include <stdbool.h>
2018-05-16 21:58:02 +02:00
#include <stdio.h>
2010-08-08 10:06:34 +02:00
#ifdef __cplusplus
extern "C" {
#endif
#define MAXLOCALES 3
struct locale;
struct critbit_tree;
2010-08-08 10:06:34 +02:00
2016-11-17 22:10:41 +01:00
extern const char *localenames[];
extern struct locale *default_locale;
extern struct locale *locales;
extern struct locale *nextlocale(const struct locale *lang);
/** managing multiple locales: **/
2016-11-17 22:10:41 +01:00
struct locale *get_locale(const char *name);
struct locale *get_or_create_locale(const char *key);
typedef void(*locale_handler)(struct locale *lang);
void init_locales(locale_handler callback);
void free_locales(void);
void reset_locales(void);
2010-08-08 10:06:34 +02:00
/** operations on locales: **/
2016-11-17 22:10:41 +01:00
void locale_setstring(struct locale *lang, const char *key,
const char *value);
2016-11-17 22:10:41 +01:00
const char *locale_getstring(const struct locale *lang,
const char *key);
2016-11-17 22:10:41 +01:00
const char *locale_string(const struct locale *lang, const char *key, bool warn); /* does fallback */
2019-10-07 22:01:02 +02:00
const char *locale_plural(const struct locale *lang, const char *key, int n, bool warn);
2016-11-17 22:10:41 +01:00
unsigned int locale_index(const struct locale *lang);
const char *locale_name(const struct locale *lang);
2010-08-08 10:06:34 +02:00
2016-11-17 22:10:41 +01:00
const char *mkname(const char *namespc, const char *key);
char *mkname_buf(const char *namespc, const char *key, char *buffer);
2010-08-08 10:06:34 +02:00
2016-11-17 22:10:41 +01:00
void make_locales(const char *str);
2010-08-08 10:06:34 +02:00
2018-05-16 21:58:02 +02:00
void po_write_msg(FILE *F, const char *id, const char *str, const char *ctxt);
#define LOC(lang, s) (lang?locale_string(lang, s, true):s)
2010-08-08 10:06:34 +02:00
enum {
UT_PARAMS,
UT_KEYWORDS,
UT_SKILLS,
UT_RACES,
UT_OPTIONS,
UT_DIRECTIONS,
UT_ARCHETYPES,
UT_MAGIC,
UT_TERRAINS,
UT_SPECDIR,
UT_MAX
};
void ** get_translations(const struct locale *lang, int type);
void * get_translation(const struct locale *lang, const char *str, int type);
void init_translations(const struct locale *lang, int ut, const char * (*string_cb)(int i), int maxstrings);
void add_translation(struct critbit_tree **cb, const char *str, int i);
2010-08-08 10:06:34 +02:00
#ifdef __cplusplus
}
#endif
#endif