diff --git a/conf/e2/config.json b/conf/e2/config.json
new file mode 100644
index 000000000..b2acffcb3
--- /dev/null
+++ b/conf/e2/config.json
@@ -0,0 +1,5 @@
+{
+ "include": [
+ "keywords.json"
+ ]
+}
diff --git a/conf/e3/config.json b/conf/e3/config.json
new file mode 100644
index 000000000..b2acffcb3
--- /dev/null
+++ b/conf/e3/config.json
@@ -0,0 +1,5 @@
+{
+ "include": [
+ "keywords.json"
+ ]
+}
diff --git a/conf/e4/config.json b/conf/e4/config.json
new file mode 100644
index 000000000..b2acffcb3
--- /dev/null
+++ b/conf/e4/config.json
@@ -0,0 +1,5 @@
+{
+ "include": [
+ "keywords.json"
+ ]
+}
diff --git a/conf/keywords.json b/conf/keywords.json
new file mode 100644
index 000000000..bc5538810
--- /dev/null
+++ b/conf/keywords.json
@@ -0,0 +1,65 @@
+{
+ "keywords": {
+ "de": {
+ "//" : "//",
+ "banner": "BANNER",
+ "work": [ "ARBEITE", "ARBEITEN" ],
+ "attack": ["ATTACKIERE", "ATTACKIEREN"],
+ "steal": [ "BEKLAUE", "BEKLAUEN" ],
+ "besiege": ["BELAGERE", "BELAGERN" ],
+ "name": [ "BENENNE", "BENENNEN" ],
+ "use": [ "BENUTZE", "BENUTZEN" ],
+ "describe": [ "BESCHREIBE", "BESCHREIBEN" ],
+ "enter": ["BETRETE", "BETRETEN"],
+ "guard": ["BEWACHE", "BEWACHEN"],
+ "message": "BOTSCHAFT",
+ "end": "ENDE",
+ "ride": ["REITE", "REITEN"],
+ "number": "NUMMER",
+ "follow": ["FOLGE","FOLGEN"],
+ "research": ["FORSCHE", "FORSCHEN"],
+ "give": "GIB",
+ "help": [ "HELFE", "HELFEN" ],
+ "combat": [ "KÄMPFE", "KÄMPFEN" ],
+ "ready" : "KAMPFZAUBER",
+ "buy" : [ "KAUFE", "KAUFEN"],
+ "contact": [ "KONTAKT", "KONTAKTIEREN"],
+ "teach": ["LEHRE", "LEHREN"],
+ "study": ["LERNE", "LERNEN"],
+ "make": ["MACHE", "MACHEN"],
+ "maketemp": ["MACHE TEMP", "MACHETEMP"],
+ "move" : "NACH",
+ "password" : "PASSWORD",
+ "recruit": ["REKRUTIERE", "REKRUTIEREN"],
+ "reserve": ["RESERVIERE", "RESERVIEREN"],
+ "route": "ROUTE",
+ "sabotage": ["SABOTIERE", "SABOTIEREN"],
+ "option": "OPTION",
+ "spy": ["SPIONIERE", "SPIONIEREN"],
+ "quit": "STIRB",
+ "hide": ["TARNE", "TARNEN"],
+ "carry": ["TRANSPORTIERE", "TRANSPORTIEREN"],
+ "tax": ["TREIBE", "TREIBEN", "STEUERN"],
+ "entertain": ["UNTERHALTE", "UNTERHALTEN"],
+ "sell": ["VERKAUFE", "VERKAUFEN"],
+ "leave": ["VERLASSE", "VERLASSEN"],
+ "forget": ["VERGISS", "VERGESSEN"],
+ "cast": ["ZAUBERE", "ZAUBERN"],
+ "show": ["ZEIGE", "ZEIGEN"],
+ "destroy": ["ZERSTÖRE", "ZERSTÖREN"],
+ "grow": ["ZÜCHTE", "ZÜCHTEN"],
+ "default": "DEFAULT",
+ "origin": "URSPRUNG",
+ "email": "EMAIL",
+ "piracy": "PIRATERIE",
+ "group": "GRUPPE",
+ "sort": ["SORTIERE", "SORTIEREN"],
+ "prefix": "PRÄFIX",
+ "plant": ["PFLANZE", "PFLANZEN"],
+ "alliance": "ALLIANZ",
+ "claim": ["BEANSPRUCHE", "BEANSPRUCHEN"],
+ "promote": ["BEFÖRDERE", "BEFÖRDERUNG"],
+ "pay": ["BEZAHLE", "BEZAHLEN"]
+ }
+ }
+}
diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml
index 863b26e35..ddf8ced6d 100644
--- a/res/core/de/strings.xml
+++ b/res/core/de/strings.xml
@@ -2111,199 +2111,6 @@
-
-
-
- //
-
-
- BANNER
-
-
- ARBEITEN
-
-
- ATTACKIEREN
-
-
- BEANSPRUCHEN
-
-
- BEKLAUEN
-
-
- BELAGERE
-
-
- BENENNEN
-
-
- BENUTZEN
-
-
- BESCHREIBEN
-
-
- BETRETEN
-
-
- GIB
-
-
- BEWACHEN
-
-
- BOTSCHAFT
-
-
- ENDE
-
-
- FAHREN
-
-
- NUMMER
-
-
- FOLGEN
-
-
- FORSCHEN
-
-
- HELFEN
-
-
- KÄMPFEN
-
-
- KAMPFZAUBER
-
-
- KAUFEN
-
-
- KONTAKTIEREN
-
-
- LEHREN
-
-
- LERNEN
-
-
- LOCALE
-
-
- MACHEN
-
-
- MACHETEMP
-
-
- NACH
-
-
- ALLIANZ
-
-
- BEFÖRDERUNG
-
-
- BEZAHLEN
-
-
- 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
-
-
- URSPRUNG
-
-
- EMAIL
-
-
- PIRATERIE
-
-
- LOCALE
-
-
- GRUPPE
-
-
- SORTIEREN
-
-
-
Optionen
diff --git a/scripts/eressea/xmlconf.lua b/scripts/eressea/xmlconf.lua
index 0840a31f7..8ddd09539 100644
--- a/scripts/eressea/xmlconf.lua
+++ b/scripts/eressea/xmlconf.lua
@@ -1,9 +1,10 @@
local confdir = 'conf/'
-if config.rules then
- confdir = confdir .. config.rules .. '/'
-end
if config.install then
confdir = config.install .. '/' .. confdir
end
-read_xml(confdir .. 'config.xml', confdir .. 'catalog.xml')
-eressea.config.read(confdir .. 'config.json')
+rules=''
+if config.rules then
+ rules = config.rules .. '/'
+end
+read_xml(confdir .. rules .. 'config.xml', confdir .. rules .. 'catalog.xml')
+eressea.config.read(rules .. 'config.json', confdir)
diff --git a/src/bind_config.c b/src/bind_config.c
index 2de4c0d2a..e87f65fb5 100644
--- a/src/bind_config.c
+++ b/src/bind_config.c
@@ -50,9 +50,19 @@ int config_parse(const char *json)
return 1;
}
-int config_read(const char *filename)
+int config_read(const char *filename, const char * relpath)
{
- FILE *F = fopen(filename, "rt");
+ char name[MAX_PATH];
+ FILE *F;
+
+ json_relpath = relpath;
+ if (relpath) {
+ _snprintf(name, sizeof(name), "%s/%s", relpath, filename);
+ F = fopen(name, "rt");
+ }
+ else {
+ F = fopen(filename, "rt");
+ }
if (F) {
int result;
char *data;
diff --git a/src/bind_config.h b/src/bind_config.h
index 27f59f853..aa6efde05 100644
--- a/src/bind_config.h
+++ b/src/bind_config.h
@@ -6,7 +6,7 @@ extern "C" {
void config_reset(void);
int config_parse(const char *json);
-int config_read(const char *filename);
+int config_read(const char *filename, const char * relpath);
#ifdef __cplusplus
}
diff --git a/src/config.pkg b/src/config.pkg
index 33f94bed8..d0cb3f905 100644
--- a/src/config.pkg
+++ b/src/config.pkg
@@ -5,7 +5,7 @@ $#include "bind_config.h"
module eressea {
module config {
void config_reset @ reset(void);
- int config_read @ read(const char *filename);
+ int config_read @ read(const char *filename, const char *relpath);
int config_parse @ parse(const char *json);
}
}
diff --git a/src/config.pkg.c b/src/config.pkg.c
index c4225ff7b..cc4bb6965 100644
--- a/src/config.pkg.c
+++ b/src/config.pkg.c
@@ -57,16 +57,18 @@ static int tolua_config_eressea_config_read00(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isstring(tolua_S,1,0,&tolua_err) ||
- !tolua_isnoobj(tolua_S,2,&tolua_err)
+ !tolua_isstring(tolua_S, 1, 0, &tolua_err) ||
+ !tolua_isstring(tolua_S, 2, 0, &tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- const char* filename = ((const char*) tolua_tostring(tolua_S,1,0));
+ const char* filename = ((const char*)tolua_tostring(tolua_S, 1, 0));
+ const char* relpath = ((const char*)tolua_tostring(tolua_S, 2, 0));
{
- int tolua_ret = (int) config_read(filename);
+ int tolua_ret = (int) config_read(filename, relpath);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
diff --git a/src/kernel/config.c b/src/kernel/config.c
index 17484449d..15e77b987 100644
--- a/src/kernel/config.c
+++ b/src/kernel/config.c
@@ -1961,20 +1961,6 @@ void kernel_done(void)
gc_done();
}
-const char *localenames[] = {
- "de", "en",
- NULL
-};
-
-void init_locales(void)
-{
- int l;
- for (l = 0; localenames[l]; ++l) {
- struct locale *lang = get_or_create_locale(localenames[l]);
- init_locale(lang);
- }
-}
-
/* TODO: soll hier weg */
extern struct attrib_type at_shiptrail;
diff --git a/src/kernel/config.h b/src/kernel/config.h
index 13c552c84..c7fd0f225 100644
--- a/src/kernel/config.h
+++ b/src/kernel/config.h
@@ -101,7 +101,6 @@ extern "C" {
/* ------------------------------------------------------------- */
void add_translation(struct critbit_tree **cb, const char *str, int i);
void init_translations(const struct locale *lang, int ut, const char * (*string_cb)(int i), int maxstrings);
- void init_locales(void);
int shipspeed(const struct ship *sh, const struct unit *u);
#define i2b(i) ((bool)((i)?(true):(false)))
@@ -171,7 +170,6 @@ extern "C" {
/* returns a value between [0..xpct_2], generated with two dice */
int distribute(int old, int new_value, int n);
- void init_locales(void);
void init_locale(struct locale *lang);
int newunitid(void);
diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c
index b6d6ece6b..d09aaf6ff 100644
--- a/src/kernel/jsonconf.c
+++ b/src/kernel/jsonconf.c
@@ -636,14 +636,24 @@ static void json_races(cJSON *json) {
}
}
-static void json_configs(cJSON *json) {
+const char * json_relpath;
+
+static void json_include(cJSON *json) {
cJSON *child;
if (json->type != cJSON_Array) {
log_error("config is not a json array: %d", json->type);
return;
}
for (child = json->child; child; child = child->next) {
- FILE *F = fopen(child->valuestring, "rt");
+ FILE *F;
+ if (json_relpath) {
+ char name[MAX_PATH];
+ _snprintf(name, sizeof(name), "%s/%s", json_relpath, child->valuestring);
+ F = fopen(name, "rt");
+ }
+ else {
+ F = fopen(child->valuestring, "rt");
+ }
if (F) {
cJSON *config;
char *data;
@@ -668,6 +678,7 @@ void json_config(cJSON *json) {
log_error("config is not a json object: %d", json->type);
return;
}
+ reset_locales();
for (child=json->child;child;child=child->next) {
if (strcmp(child->string, "races")==0) {
json_races(child);
@@ -675,8 +686,8 @@ void json_config(cJSON *json) {
else if (strcmp(child->string, "items") == 0) {
json_items(child);
}
- else if (strcmp(child->string, "config") == 0) {
- json_configs(child);
+ else if (strcmp(child->string, "include") == 0) {
+ json_include(child);
}
else if (strcmp(child->string, "ships") == 0) {
json_ships(child);
@@ -705,6 +716,5 @@ void json_config(cJSON *json) {
log_error("config contains unknown attribute %s", child->string);
}
}
- init_locales();
}
diff --git a/src/kernel/jsonconf.h b/src/kernel/jsonconf.h
index 9d0f1467e..6940386e9 100644
--- a/src/kernel/jsonconf.h
+++ b/src/kernel/jsonconf.h
@@ -18,7 +18,8 @@ extern "C" {
struct cJSON;
void json_config(struct cJSON *str);
-
+ extern const char * json_relpath;
+
#ifdef __cplusplus
}
#endif
diff --git a/src/kernel/jsonconf.test.c b/src/kernel/jsonconf.test.c
index b7fabc3e3..7a401b8f7 100644
--- a/src/kernel/jsonconf.test.c
+++ b/src/kernel/jsonconf.test.c
@@ -10,6 +10,7 @@
#include "race.h"
#include "ship.h"
#include "spell.h"
+#include "order.h"
#include "terrain.h"
#include "util/language.h"
#include
@@ -295,7 +296,7 @@ static void test_buildings(CuTest * tc)
static void test_configs(CuTest * tc)
{
- const char * data = "{\"config\": [ \"test.json\" ] }";
+ const char * data = "{\"include\": [ \"test.json\" ] }";
FILE *F;
cJSON *json = cJSON_Parse(data);
@@ -416,6 +417,26 @@ static void test_strings(CuTest * tc)
CuAssertStrEquals(tc, "LERNEN", locale_string(lang, "study"));
}
+static void test_infinitive_from_config(CuTest *tc) {
+ char buffer[32];
+ struct locale *lang;
+ struct order *ord;
+ const char * data = "{\"keywords\": { \"de\" : { \"study\" : [ \"LERNE\", \"LERNEN\" ] }}}";
+
+ cJSON *json = cJSON_Parse(data);
+ CuAssertPtrNotNull(tc, json);
+ 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));
+
+ ord = create_order(K_STUDY, lang, "");
+ CuAssertStrEquals(tc, "LERNE", get_command(ord, buffer, sizeof(buffer)));
+ test_cleanup();
+}
+
CuSuite *get_jsonconf_suite(void)
{
CuSuite *suite = CuSuiteNew();
@@ -433,6 +454,7 @@ CuSuite *get_jsonconf_suite(void)
SUITE_ADD_TEST(suite, test_strings);
SUITE_ADD_TEST(suite, test_spells);
SUITE_ADD_TEST(suite, test_flags);
+ SUITE_ADD_TEST(suite, test_infinitive_from_config);
return suite;
}
diff --git a/src/kernel/save.c b/src/kernel/save.c
index c52eae383..6f443598a 100644
--- a/src/kernel/save.c
+++ b/src/kernel/save.c
@@ -1460,6 +1460,7 @@ int readgame(const char *filename, int backup)
storage store;
FILE *F;
+ init_locales();
log_printf(stdout, "- reading game data from %s\n", filename);
sprintf(path, "%s/%s", datapath(), filename);
diff --git a/src/laws.c b/src/laws.c
index 2b9171083..038c9a550 100755
--- a/src/laws.c
+++ b/src/laws.c
@@ -4562,10 +4562,10 @@ int init_data(const char *filename, const char *catalog)
{
int l;
l = read_xml(filename, catalog);
+ reset_locales();
if (l) {
return l;
}
- init_locales();
if (turn < 0) {
turn = first_turn;
}
diff --git a/src/util/language.c b/src/util/language.c
index c3e997553..1e8cd1a4b 100644
--- a/src/util/language.c
+++ b/src/util/language.c
@@ -243,8 +243,32 @@ void *get_translation(const struct locale *lang, const char *str, int index) {
return NULL;
}
-void free_locales(void)
+const char *localenames[] = {
+ "de", "en",
+ NULL
+};
+
+extern void init_locale(struct locale *lang);
+
+static int locale_init = 0;
+
+void init_locales(void)
{
+ int l;
+ if (locale_init) return;
+ for (l = 0; localenames[l]; ++l) {
+ struct locale *lang = get_or_create_locale(localenames[l]);
+ init_locale(lang);
+ }
+ locale_init = 1;
+}
+
+void reset_locales(void) {
+ locale_init = 0;
+}
+
+void free_locales(void) {
+ locale_init = 0;
while (locales) {
int i;
locale * next = locales->next;
@@ -262,4 +286,4 @@ void free_locales(void)
locales = next;
}
memset(lstrs, 0, sizeof(lstrs)); // TODO: does this data need to be free'd?
-}
\ No newline at end of file
+}
diff --git a/src/util/language.h b/src/util/language.h
index 7083dec1f..5dd35c7b2 100644
--- a/src/util/language.h
+++ b/src/util/language.h
@@ -29,7 +29,9 @@ extern "C" {
/** managing multiple locales: **/
extern struct locale *get_locale(const char *name);
extern struct locale *get_or_create_locale(const char *key);
- extern void free_locales(void);
+ void init_locales(void);
+ void free_locales(void);
+ void reset_locales(void);
/** operations on locales: **/
extern void locale_setstring(struct locale *lang, const char *key,