From 0af5e96e3adaf80020e05a7e6c2dfd89cdcde071 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 16 Jun 2014 19:12:55 -0700 Subject: [PATCH] Renaming keyword tokens to English. --- core/res/de/strings.xml | 151 ++++++++++++++----------------------- core/res/en/strings.xml | 131 ++++++++++++++++---------------- core/res/fr/strings.xml | 123 +++++++++++++----------------- game-e2/config.xml | 4 - src/kernel/jsonconf.c | 44 +++++------ src/kernel/jsonconf.test.c | 2 +- src/keyword.c | 112 +++++++++++++-------------- src/keyword.test.c | 18 +++-- src/util/log.c | 29 +++++++ src/util/log.h | 1 + 10 files changed, 296 insertions(+), 319 deletions(-) diff --git a/core/res/de/strings.xml b/core/res/de/strings.xml index 20273841d..12d613ccc 100644 --- a/core/res/de/strings.xml +++ b/core/res/de/strings.xml @@ -2113,213 +2113,178 @@ // - + BANNER - + ARBEITEN - - WARTEN - WAIT - - + ATTACKIEREN - - BIETEN - - - BEANSPRUCHEN + CLAIM - + BEKLAUEN - + BELAGERE - + BENENNEN - + BENUTZEN - + BESCHREIBEN - + BETRETEN - + BEWACHEN - + BOTSCHAFT - + ENDE - + FAHREN - + NUMMER - - FRIEDEN - PEACE - - - KRIEG - WAR - - + FOLGEN - + FORSCHEN - + HELFEN - + KÄMPFEN - + KAMPFZAUBER - + KAUFEN - + KONTAKTIEREN - + LEHREN - + LERNEN - + MACHEN - + NACH - + ALLIANZ - ALLIANCE - + BEFÖRDERUNG - PROMOTION - - BEZAHLEN - PAY - - + PFLANZEN - + PRÄFIX - + INFO - + PASSWORT - + REKRUTIEREN - + RESERVIEREN - + ROUTE - + SABOTIEREN - + OPTION - + SPIONIEREN - + STIRB - + TARNEN - + TRANSPORTIEREN - + TREIBEN - + UNTERHALTEN - + VERKAUFEN - + VERLASSEN - + VERGESSEN - + ZAUBERE - + ZEIGEN - + ZERSTÖREN - + ZÜCHTEN - + DEFAULT - + REPORT - - XML - XML - - + URSPRUNG - + EMAIL - + PIRATERIE - + LOCALE - - NEUSTART - - + GRUPPE - - OPFERE - - - BETEN - - + SORTIEREN diff --git a/core/res/en/strings.xml b/core/res/en/strings.xml index 42bfd3bf8..46544a1fc 100644 --- a/core/res/en/strings.xml +++ b/core/res/en/strings.xml @@ -1385,181 +1385,178 @@ // - + WORK - + ATTACK - + BANNER - + STEAL - + BESIEGE - + NAME - + USE - + DESCRIBE - - PRAY - - + ENTER - + GUARD - + BID - + MESSAGE - + DEFAULT - + EMAIL - + END - + RIDE - + FOLLOW - + RESEARCH - + GROUP - + HELP - + COMBATSPELL - + BUY - + CONTACT - + COMBAT - + TEACH - + LEARN - - SUPPLY - - + LOCALE - + MAKE - + MOVE - - RESTART - - + NUMBER - - SACRIFICE - - + OPTION - + PASSWORD - + PLANT - + PIRACY - + PREFIX - + + ALLIANCE + + + PROMOTION + + + CLAIM + + RECRUIT - + REPORT - + RESERVE - + ROUTE - + SABOTAGE - + SORT - + SPY - + QUIT - + HIDE - + CARRY - + TAX - + ENTERTAIN - + ORIGIN - + FORGET - + SELL - + LEAVE - + CAST - + SHOW - + DESTROY - + GROW diff --git a/core/res/fr/strings.xml b/core/res/fr/strings.xml index 33b3da6c4..619af075e 100644 --- a/core/res/fr/strings.xml +++ b/core/res/fr/strings.xml @@ -1393,184 +1393,169 @@ // - + TRAVAILLER - + ATTAQUER - + ANNONCE - + VOLER - + ASSIEGER - + NOMMER - + UTILISER - + DECRIRE - - PRIER - - + ENTRER - + GUARDER - - OFFRIR - - + MESSAGE - + DEFAUT - + EMAIL - + FIN - + CHEVAUCHER - + SUIVRE - + CHERCHER - + GROUPER - + AIDER - + PREPARER - + ACHETER - + CONTACTER - + COMBATTRE - + ENSEIGNER - + APPRENDRE FOURNIR - + LOCAL - + FAIRE - + ALLER - - RECOMMENCER - - + NOMBRE - - SACRIFIER - - + OPTION - + PASSWORD - + PLANTER - + PIRATERIE - + PREFIXE - + RECRUTER - + RAPPORT - + RESERVER - + TRAJET - + SABOTER - + TRIER - + ESPIONNER - + ABANDONNER - - SYNONYME - - + CACHER - + TRANSPORTER - + TAXER - + DIVERTIR - + ORIGINE - + OUBLIER - + VENDRE - + SORTIR - + INCANTER - + MONTRER - + DETRUIRE - + ACCROITRE diff --git a/game-e2/config.xml b/game-e2/config.xml index 00f302177..352e59d95 100644 --- a/game-e2/config.xml +++ b/game-e2/config.xml @@ -54,10 +54,6 @@ - - - - diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 0db6d1d0f..a6b684a08 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -55,7 +55,7 @@ without prior permission by the authors of Eressea. void json_construction(cJSON *json, construction **consp) { cJSON *child; if (json->type!=cJSON_Object) { - log_error("building %s is not a json object: %d\n", json->string, json->type); + log_error_n("building %s is not a json object: %d", json->string, json->type); return; } construction * cons = (construction *)calloc(sizeof(construction), 1); @@ -73,7 +73,7 @@ void json_construction(cJSON *json, construction **consp) { } break; default: - log_error("building %s contains unknown attribute %s\n", json->string, child->string); + log_error_n("building %s contains unknown attribute %s", json->string, child->string); } } *consp = cons; @@ -82,18 +82,18 @@ void json_construction(cJSON *json, construction **consp) { void json_terrain(cJSON *json, terrain_type *ter) { cJSON *child; if (json->type!=cJSON_Object) { - log_error("terrain %s is not a json object: %d\n", json->string, json->type); + log_error_n("terrain %s is not a json object: %d", json->string, json->type); return; } for (child=json->child;child;child=child->next) { - log_error("terrain %s contains unknown attribute %s\n", json->string, child->string); + log_error_n("terrain %s contains unknown attribute %s", json->string, child->string); } } void json_building(cJSON *json, building_type *bt) { cJSON *child; if (json->type!=cJSON_Object) { - log_error("building %s is not a json object: %d\n", json->string, json->type); + log_error_n("building %s is not a json object: %d", json->string, json->type); return; } for (child=json->child;child;child=child->next) { @@ -104,7 +104,7 @@ void json_building(cJSON *json, building_type *bt) { } break; default: - log_error("building %s contains unknown attribute %s\n", json->string, child->string); + log_error_n("building %s contains unknown attribute %s", json->string, child->string); } } } @@ -112,7 +112,7 @@ void json_building(cJSON *json, building_type *bt) { void json_ship(cJSON *json, ship_type *st) { cJSON *child; if (json->type!=cJSON_Object) { - log_error("ship %s is not a json object: %d\n", json->string, json->type); + log_error_n("ship %s is not a json object: %d", json->string, json->type); return; } for (child=json->child;child;child=child->next) { @@ -123,7 +123,7 @@ void json_ship(cJSON *json, ship_type *st) { } break; default: - log_error("ship %s contains unknown attribute %s\n", json->string, child->string); + log_error_n("ship %s contains unknown attribute %s", json->string, child->string); } } } @@ -131,7 +131,7 @@ void json_ship(cJSON *json, ship_type *st) { void json_race(cJSON *json, race *rc) { cJSON *child; if (json->type!=cJSON_Object) { - log_error("race %s is not a json object: %d\n", json->string, json->type); + log_error_n("race %s is not a json object: %d", json->string, json->type); return; } for (child=json->child;child;child=child->next) { @@ -201,7 +201,7 @@ void json_race(cJSON *json, race *rc) { void json_terrains(cJSON *json) { cJSON *child; if (json->type!=cJSON_Object) { - log_error("terrains is not a json object: %d\n", json->type); + log_error_n("terrains is not a json object: %d", json->type); return; } for (child=json->child;child;child=child->next) { @@ -212,7 +212,7 @@ void json_terrains(cJSON *json) { void json_buildings(cJSON *json) { cJSON *child; if (json->type!=cJSON_Object) { - log_error("buildings is not a json object: %d\n", json->type); + log_error_n("buildings is not a json object: %d", json->type); return; } for (child=json->child;child;child=child->next) { @@ -223,7 +223,7 @@ void json_buildings(cJSON *json) { void json_ships(cJSON *json) { cJSON *child; if (json->type!=cJSON_Object) { - log_error("ships is not a json object: %d\n", json->type); + log_error_n("ships is not a json object: %d", json->type); return; } for (child=json->child;child;child=child->next) { @@ -234,7 +234,7 @@ void json_ships(cJSON *json) { static void json_direction(cJSON *json, struct locale *lang) { cJSON *child; if (json->type!=cJSON_Object) { - log_error("directions for locale `%s` not a json object: %d\n", locale_name(lang), json->type); + log_error_n("directions for locale `%s` not a json object: %d", locale_name(lang), json->type); return; } for (child=json->child;child;child=child->next) { @@ -249,7 +249,7 @@ static void json_direction(cJSON *json, struct locale *lang) { init_direction(lang, dir, entry->valuestring); } } else { - log_error("invalid type %d for direction `%s`\n", child->type, child->string); + log_error_n("invalid type %d for direction `%s`", child->type, child->string); } } } @@ -258,7 +258,7 @@ static void json_direction(cJSON *json, struct locale *lang) { void json_directions(cJSON *json) { cJSON *child; if (json->type!=cJSON_Object) { - log_error("directions is not a json object: %d\n", json->type); + log_error_n("directions is not a json object: %d", json->type); return; } for (child=json->child;child;child=child->next) { @@ -270,7 +270,7 @@ void json_directions(cJSON *json) { static void json_keyword(cJSON *json, struct locale *lang) { cJSON *child; if (json->type!=cJSON_Object) { - log_error("keywords for locale `%s` not a json object: %d\n", locale_name(lang), json->type); + log_error_n("keywords for locale `%s` not a json object: %d", locale_name(lang), json->type); return; } for (child=json->child;child;child=child->next) { @@ -285,8 +285,10 @@ static void json_keyword(cJSON *json, struct locale *lang) { init_keyword(lang, kwd, entry->valuestring); } } else { - log_error("invalid type %d for keyword `%s`\n", child->type, child->string); + log_error_n("invalid type %d for keyword `%s`", child->type, child->string); } + } else { + log_error_n("unknown keyword `%s` for locale `%s`", child->string, locale_name(lang)); } } } @@ -294,7 +296,7 @@ static void json_keyword(cJSON *json, struct locale *lang) { void json_keywords(cJSON *json) { cJSON *child; if (json->type!=cJSON_Object) { - log_error("keywords is not a json object: %d\n", json->type); + log_error_n("keywords is not a json object: %d", json->type); return; } for (child=json->child;child;child=child->next) { @@ -306,7 +308,7 @@ void json_keywords(cJSON *json) { void json_races(cJSON *json) { cJSON *child; if (json->type!=cJSON_Object) { - log_error("races is not a json object: %d\n", json->type); + log_error_n("races is not a json object: %d", json->type); return; } for (child=json->child;child;child=child->next) { @@ -317,7 +319,7 @@ void json_races(cJSON *json) { void json_config(cJSON *json) { cJSON *child; if (json->type!=cJSON_Object) { - log_error("config is not a json object: %d\n", json->type); + log_error_n("config is not a json object: %d", json->type); return; } for (child=json->child;child;child=child->next) { @@ -339,7 +341,7 @@ void json_config(cJSON *json) { else if (strcmp(child->string, "terrains")==0) { json_terrains(child); } else { - log_error("config contains unknown attribute %s\n", child->string); + log_error_n("config contains unknown attribute %s", child->string); } } } diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c index f56607f26..aaa3ef6d2 100644 --- a/src/kernel/jsonconf.test.c +++ b/src/kernel/jsonconf.test.c @@ -169,7 +169,7 @@ static void test_directions(CuTest * tc) static void test_keywords(CuTest * tc) { - const char * data = "{\"keywords\": { \"de\" : { \"NACH\" : \"nach\", \"LERNEN\" : \"lernen\" }}}"; + const char * data = "{\"keywords\": { \"de\" : { \"move\" : \"nach\", \"study\" : \"lernen\" }}}"; const struct locale * lang; cJSON *json = cJSON_Parse(data); diff --git a/src/keyword.c b/src/keyword.c index eadda7562..7f8516fdc 100644 --- a/src/keyword.c +++ b/src/keyword.c @@ -77,62 +77,62 @@ bool keyword_disabled(keyword_t kwd) { const char *keywords[MAXKEYWORDS] = { "//", - "BANNER", + "banner", "work", - "ATTACKIEREN", - "BEKLAUEN", - "BELAGERE", - "BENENNEN", - "BENUTZEN", - "BESCHREIBEN", - "BETRETEN", - "BEWACHEN", - "BOTSCHAFT", - "ENDE", - "FAHREN", - "NUMMER", - "FOLGEN", - "FORSCHEN", - "GIB", - "HELFEN", - "KAEMPFEN", - "KAMPFZAUBER", - "KAUFEN", - "KONTAKTIEREN", - "LEHREN", - "LERNEN", - "MACHEN", - "NACH", - "PASSWORT", - "REKRUTIEREN", - "RESERVIEREN", - "ROUTE", - "SABOTIEREN", - "OPTION", - "SPIONIEREN", - "STIRB", - "TARNEN", - "TRANSPORTIEREN", - "TREIBEN", - "UNTERHALTEN", - "VERKAUFEN", - "VERLASSEN", - "VERGESSEN", - "ZAUBERE", - "ZEIGEN", - "ZERSTOEREN", - "ZUECHTEN", - "DEFAULT", - "URSPRUNG", - "EMAIL", - "PIRATERIE", - "GRUPPE", - "SORTIEREN", - "PRAEFIX", - "PFLANZEN", - "ALLIANZ", - "BEANSPRUCHEN", - "PROMOTION", - "BEZAHLEN", + "attack", + "steal", + "besiege", + "name", + "use", + "describe", + "enter", + "guard", + "message", + "end", + "ride", + "number", + "follow", + "research", + "give", + "help", + "fight", + "ready", + "buy", + "contact", + "teach", + "study", + "make", + "move", + "password", + "recruit", + "reserve", + "route", + "sabotage", + "option", + "spy", + "quit", + "hide", + "carry", + "tax", + "entertain", + "sell", + "leave", + "forget", + "cast", + "show", + "destroy", + "grow", + "default", + "origin", + "email", + "piracy", + "group", + "sort", + "prefix", + "plant", + "alliance", + "claim", + "promote", + "pay", }; diff --git a/src/keyword.test.c b/src/keyword.test.c index 3bccf83a1..a3a92a2fa 100644 --- a/src/keyword.test.c +++ b/src/keyword.test.c @@ -11,7 +11,7 @@ static void test_init_keywords(CuTest *tc) { test_cleanup(); lang = get_or_create_locale("en"); - locale_setstring(lang, "keyword::NACH", "MOVE"); + locale_setstring(lang, "keyword::move", "MOVE"); init_keywords(lang); CuAssertIntEquals(tc, K_MOVE, get_keyword("move", lang)); test_cleanup(); @@ -22,20 +22,22 @@ static void test_init_keyword(CuTest *tc) { test_cleanup(); lang = get_or_create_locale("de"); - init_keyword(lang, K_MOVE, "nach"); - init_keyword(lang, K_STUDY, "lernen"); + init_keyword(lang, K_MOVE, "NACH"); + init_keyword(lang, K_STUDY, "LERNEN"); init_keyword(lang, K_DESTROY, "ZERSTOEREN"); CuAssertIntEquals(tc, K_MOVE, get_keyword("nach", lang)); + CuAssertIntEquals(tc, K_STUDY, get_keyword("LERN", lang)); + CuAssertIntEquals(tc, K_STUDY, get_keyword("LERNEN", lang)); CuAssertIntEquals(tc, K_STUDY, get_keyword("lerne", lang)); - CuAssertIntEquals(tc, K_DESTROY, get_keyword("ZERSTÖREN", lang)); + CuAssertIntEquals(tc, K_DESTROY, get_keyword("zerst\xC3\xB6ren", lang)); CuAssertIntEquals(tc, NOKEYWORD, get_keyword("potato", lang)); test_cleanup(); } static void test_findkeyword(CuTest *tc) { test_cleanup(); - CuAssertIntEquals(tc, K_MOVE, findkeyword("NACH")); - CuAssertIntEquals(tc, K_STUDY, findkeyword("LERNEN")); + CuAssertIntEquals(tc, K_MOVE, findkeyword("move")); + CuAssertIntEquals(tc, K_STUDY, findkeyword("study")); CuAssertIntEquals(tc, NOKEYWORD, findkeyword("")); CuAssertIntEquals(tc, NOKEYWORD, findkeyword("potato")); } @@ -45,8 +47,8 @@ static void test_get_keyword_default(CuTest *tc) { test_cleanup(); lang = get_or_create_locale("en"); CuAssertIntEquals(tc, NOKEYWORD, get_keyword("potato", lang)); - CuAssertIntEquals(tc, K_MOVE, get_keyword("NACH", lang)); - CuAssertIntEquals(tc, K_STUDY, get_keyword("LERNEN", lang)); + CuAssertIntEquals(tc, K_MOVE, get_keyword("move", lang)); + CuAssertIntEquals(tc, K_STUDY, get_keyword("study", lang)); } #define SUITE_DISABLE_TEST(suite, test) (void)test diff --git a/src/util/log.c b/src/util/log.c index fe6af23e0..3cab62b42 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -225,6 +225,35 @@ void log_warning(const char *format, ...) } } +void log_error_n(const char *format, ...) +{ + const char * prefix = "ERROR"; + const int mask = LOG_CPERROR; + + /* write to the logfile, always */ + if (logfile && (log_flags & mask)) { + va_list args; + va_start(args, format); + _log_write(logfile, 0, prefix, format, args); + va_end(args); + } + + /* write to stderr, if that's not the logfile already */ + if (logfile!=stderr && (log_stderr & mask)) { + int dupe = check_dupe(format, prefix); + if (!dupe) { + va_list args; + va_start(args, format); + _log_write(stderr, stdio_codepage, prefix, format, args); + fputc('\n', logfile); + va_end(args); + } + } + if (log_flags & LOG_FLUSH) { + log_flush(); + } +} + void log_error(const char *format, ...) { const char * prefix = "ERROR"; diff --git a/src/util/log.h b/src/util/log.h index 41849e533..0ee5f970b 100644 --- a/src/util/log.h +++ b/src/util/log.h @@ -22,6 +22,7 @@ extern "C" { /* use macros above instead of these: */ extern void log_warning(const char *format, ...); extern void log_error(const char *format, ...); + extern void log_error_n(const char *format, ...); extern void log_debug(const char *format, ...); extern void log_info(const char *format, ...); extern void log_printf(FILE * ios, const char *format, ...);