Merge pull request #652 from ennorehling/develop

finish locale refactoring for now.
This commit is contained in:
Enno Rehling 2017-02-12 06:31:40 +01:00 committed by GitHub
commit 69fd8edb8b
9 changed files with 15 additions and 29 deletions

2
clibs

@ -1 +1 @@
Subproject commit 27c8b3202b52766465743c3324fc0b52c5ba4b11
Subproject commit f91ef37f08c5244bf616f1836c0aa9caaf36805c

View File

@ -146,7 +146,7 @@ function process(rules, orders)
init_summary()
-- run the turn:
if read_orders(orders) ~= 0 then
if eressea.read_orders(orders) ~= 0 then
print("could not read " .. orders)
return -1
end

View File

@ -223,14 +223,6 @@ static int tolua_rng_int(lua_State * L)
return 1;
}
static int tolua_read_orders(lua_State * L)
{
const char *filename = tolua_tostring(L, 1, 0);
int result = readorders(filename);
lua_pushinteger(L, result);
return 1;
}
static int tolua_message_unit(lua_State * L)
{
unit *sender = (unit *)tolua_tousertype(L, 1, 0);
@ -1072,8 +1064,6 @@ int tolua_bindings_open(lua_State * L, const dictionary *inifile)
tolua_function(L, TOLUA_CAST "factions", tolua_get_factions);
tolua_function(L, TOLUA_CAST "regions", tolua_get_regions);
tolua_function(L, TOLUA_CAST "read_turn", tolua_read_turn);
// tolua_function(L, TOLUA_CAST "write_map", &tolua_write_map);
tolua_function(L, TOLUA_CAST "read_orders", tolua_read_orders);
tolua_function(L, TOLUA_CAST "process_orders", tolua_process_orders);
tolua_function(L, TOLUA_CAST "init_reports", tolua_init_reports);
tolua_function(L, TOLUA_CAST "write_reports", tolua_write_reports);

View File

@ -654,7 +654,7 @@ static void json_strings(cJSON *json) {
}
for (child = json->child; child; child = child->next) {
if (child->type == cJSON_Object) {
struct locale *lang = get_or_create_locale(child->string);
struct locale *lang = get_locale(child->string);
json_locale(child, lang);
}
else {
@ -695,7 +695,7 @@ static void json_directions(cJSON *json) {
return;
}
for (child = json->child; child; child = child->next) {
struct locale * lang = get_or_create_locale(child->string);
struct locale * lang = get_locale(child->string);
json_direction(child, lang);
}
}
@ -771,7 +771,7 @@ static void json_skills(cJSON *json) {
return;
}
for (child = json->child; child; child = child->next) {
struct locale * lang = get_or_create_locale(child->string);
struct locale * lang = get_locale(child->string);
json_skill(child, lang);
}
}
@ -783,7 +783,7 @@ static void json_keywords(cJSON *json) {
return;
}
for (child = json->child; child; child = child->next) {
struct locale * lang = get_or_create_locale(child->string);
struct locale * lang = get_locale(child->string);
json_keyword(child, lang);
}
}

View File

@ -600,9 +600,10 @@ static void test_infinitive_from_config(CuTest *tc) {
cJSON *json = cJSON_Parse(data);
CuAssertPtrNotNull(tc, json);
test_setup();
lang = get_or_create_locale("de");
json_config(json);
lang = get_or_create_locale("de");
CuAssertIntEquals(tc, K_STUDY, get_keyword("LERN", lang));
CuAssertIntEquals(tc, K_STUDY, get_keyword("LERNE", lang));
CuAssertIntEquals(tc, K_STUDY, get_keyword("LERNEN", lang));

View File

@ -66,10 +66,6 @@ static void xml_readtext(xmlNodePtr node, struct locale **lang, xmlChar ** text)
xmlChar *propValue = xmlGetProp(node, BAD_CAST "locale");
assert(propValue != NULL);
*lang = get_locale((const char *)propValue);
#ifdef MAKE_LOCALES
if (*lang == NULL)
*lang = get_or_create_locale((const char *)propValue);
#endif
xmlFree(propValue);
*text = xmlNodeListGetString(node->doc, node->children, 1);
@ -361,7 +357,6 @@ static int parse_calendar(xmlDocPtr doc)
xpathCalendars = xmlXPathEvalExpression(BAD_CAST "/eressea/calendar", xpath);
nsetCalendars = xpathCalendars->nodesetval;
months_per_year = 0;
if (nsetCalendars != NULL && nsetCalendars->nodeNr != 0) {
int c;
for (c = 0; c != nsetCalendars->nodeNr; ++c) {

View File

@ -70,15 +70,13 @@ static void load_inifile(dictionary * d)
lomem = iniparser_getint(d, "game:lomem", lomem) ? 1 : 0;
verbosity = iniparser_getint(d, "game:verbose", 2);
str = iniparser_getstring(d, "game:locales", "de,en");
make_locales(str);
}
static dictionary *parse_config(const char *filename)
{
char path[MAX_PATH];
dictionary *d;
const char *cfgpath = config_get("config.path");
const char *str, *cfgpath = config_get("config.path");
if (cfgpath) {
join_path(cfgpath, filename, path, sizeof(path));
@ -99,6 +97,8 @@ static dictionary *parse_config(const char *filename)
gm_codepage = iniparser_getint(d, "editor:codepage", gm_codepage);
#endif
}
str = config_get("game.locales");
make_locales(str ? str : "de,en");
return d;
}

View File

@ -157,7 +157,7 @@ size_t report_status(const unit * u, const struct locale *lang, char *fsbuf, siz
if (!status) {
const char *lname = locale_name(lang);
struct locale *wloc = get_or_create_locale(lname);
struct locale *wloc = get_locale(lname);
log_warning("no translation for combat status %s in %s", combatstatus[u->status], lname);
locale_setstring(wloc, combatstatus[u->status], combatstatus[u->status]+7);
len = strlcpy(fsbuf, combatstatus[u->status]+7, buflen);

View File

@ -327,10 +327,10 @@ static int locale_init = 0;
void init_locales(void)
{
int l;
locale * lang;
if (locale_init) return;
for (l = 0; localenames[l]; ++l) {
struct locale *lang = get_or_create_locale(localenames[l]);
assert(locales);
for (lang = locales; lang; lang = lang->next) {
init_locale(lang);
}
locale_init = 1;