From 039ee159cb93816f603dcce05bd8c8f5ae04213c Mon Sep 17 00:00:00 2001 From: Steffen Mecke Date: Wed, 14 Jan 2015 16:13:08 +0100 Subject: [PATCH 1/2] a bunch of messages in the NR where not localized --- res/core/de/strings.xml | 37 +++++++++ res/core/messages.xml | 32 ++++++++ src/report.c | 172 +++++++++++++++++++--------------------- 3 files changed, 150 insertions(+), 91 deletions(-) diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index c233a507f..e2003f997 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -364,6 +364,43 @@ und im and to the + + Schemen der Regionen + Schemes of + + + sind erkennbar. + can be discerned. + + + Im + To the + + + und im + , and to the + + + , im + , to the + + + Die Region wird von + The region is guarded by + + + unbekannten Einheiten + unknown units + + + bewacht. + . + + + (im Bau) + (under construction) + + Einheit Unit diff --git a/res/core/messages.xml b/res/core/messages.xml index cbc5dd780..68f83f44b 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -924,6 +924,38 @@ "Auf dem Markt wird $resource($p1,0) feilgeboten." "The local market offers $resource($p1,0)." + + + + + + "Auf der Einheit $if($eq($left,1),"liegt","liegen") $int($left) Wirkung$if($eq($left,1),"","en") $resource($potion,1)." + "There are $int($left) use($eq($left,1),"s","") of $resource($potion,1) left." + + + + + + "Die Region ist im Besitz von $faction($faction)." + "The region is owned by $faction($faction)." + + + + + + + "$if($transparent," befindet sich"," versperrt") ${object} $if($transparent,""," die Sicht")." + "$if($transparent," there is"," sight is blocked by ") ${object}." + + + + + + + ", belagert von $int($soldiers) Personen$if($lt($diff,0),""," (abgeschnitten)")" + ", besieged by $int($soldiers) soldiers$if($lt($diff,0),""," (cut off)")" + + diff --git a/src/report.c b/src/report.c index efdb80268..98ba9c042 100644 --- a/src/report.c +++ b/src/report.c @@ -634,10 +634,10 @@ int indent) for (; a; a = a->next) { char buf[4096]; - + message *msg; + if (fval(a->type, ATF_CURSE)) { curse *c = (curse *)a->data.v; - message *msg; if (c->type->cansee) { self = c->type->cansee(viewer, obj, typ, c, self); @@ -654,13 +654,10 @@ int indent) else if (a->type == &at_effect && self) { effect_data *data = (effect_data *)a->data.v; if (data->value > 0) { - sprintf(buf, "Auf der Einheit lieg%s %d Wirkung%s %s.", - (data->value == 1 ? "t" : "en"), - data->value, - (data->value == 1 ? "" : "en"), - LOC(default_locale, resourcename(data->type->itype->rtype, 0))); - rnl(F); - rparagraph(F, buf, indent, 2, 0); + msg = msg_message("nr_potion_effect", "potion left", data->type->itype->rtype, data->value); + nr_render(msg, viewer->locale, buf, sizeof(buf), viewer); + rparagraph(F, buf, indent, 2, 0); + msg_release(msg); } } } @@ -828,37 +825,37 @@ static void prices(FILE * F, const region * r, const faction * f) for (dmd = r->land->demands; dmd; dmd = dmd->next) if (dmd->value > 0) { - m = msg_message("nr_market_price", "product price", - dmd->type->itype->rtype, dmd->value * dmd->type->price); - bytes = (int)nr_render(m, f->locale, bufp, size, f); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - msg_release(m); - n--; - if (n == 0) { - bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_end"), size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - } - else if (n == 1) { - bytes = (int)strlcpy(bufp, " ", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_final"), size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)strlcpy(bufp, " ", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - } - else { - bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_next"), size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)strlcpy(bufp, " ", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - } + m = msg_message("nr_market_price", "product price", + dmd->type->itype->rtype, dmd->value * dmd->type->price); + bytes = (int)nr_render(m, f->locale, bufp, size, f); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + msg_release(m); + n--; + if (n == 0) { + bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_end"), size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + } + else if (n == 1) { + bytes = (int)strlcpy(bufp, " ", size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_final"), size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + bytes = (int)strlcpy(bufp, " ", size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + } + else { + bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_next"), size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + bytes = (int)strlcpy(bufp, " ", size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + } } } /* Schreibe Paragraphen */ @@ -1099,10 +1096,12 @@ static void describe(FILE * F, const seen_region * sr, faction * f) if (rule_region_owners()) { const faction *owner = region_get_owner(r); + message *msg; + if (owner != NULL) { - // TODO: localization - bytes = _snprintf(bufp, size, " Die Region ist im Besitz von %s.", - factionname(owner)); + msg = msg_message("nr_region_owner", "faction", owner); + bytes = (int)nr_render(msg, f->locale, bufp, size, f); + msg_release(msg); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } @@ -1207,7 +1206,9 @@ static void describe(FILE * F, const seen_region * sr, faction * f) if (rl) { bufp = buf; size = sizeof(buf) - 1; - bytes = (int)strlcpy(bufp, "Schemen der Regionen ", size); + + // this localization might not work for every language but is fine for de and en + bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_schemes_prefix"), size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); rl2 = rl; @@ -1222,7 +1223,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f) WARN_STATIC_BUFFER(); } } - bytes = (int)strlcpy(bufp, " sind erkennbar.", size); + bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_schemes_postfix"), size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); free_regionlist(rl); @@ -1249,17 +1250,20 @@ static void describe(FILE * F, const seen_region * sr, faction * f) rnl(F); for (e = edges; e; e = e->next) { bool first = true; + message *msg; + bufp = buf; size = sizeof(buf) - 1; for (d = 0; d != MAXDIRECTIONS; ++d) { if (!e->exist[d]) continue; + // this localization might not work for every language but is fine for de and en if (first) - bytes = (int)strlcpy(bufp, "Im ", size); + bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_borderlist_prefix"), size); else if (e->lastd == d) - bytes = (int)strlcpy(bufp, " und im ", size); + bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_borderlist_lastfix"), size); else - bytes = (int)strlcpy(bufp, ", im ", size); + bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_borderlist_infix"), size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); bytes = (int)strlcpy(bufp, LOC(f->locale, directions[d]), size); @@ -1267,21 +1271,13 @@ static void describe(FILE * F, const seen_region * sr, faction * f) WARN_STATIC_BUFFER(); first = false; } - if (!e->transparent) - bytes = (int)strlcpy(bufp, " versperrt ", size); - else - bytes = (int)strlcpy(bufp, " befindet sich ", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)strlcpy(bufp, e->name, size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - if (!e->transparent) - bytes = (int)strlcpy(bufp, " die Sicht.", size); - else - bytes = (int)strlcpy(bufp, ".", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + // TODO name is localized? Works for roads anyway... + msg = msg_message("nr_borderlist_postfix", "transparent object", e->transparent, e->name); + bytes = (int)nr_render(msg, f->locale, bufp, size, f); + msg_release(msg); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + *bufp = 0; rparagraph(F, buf, 0, 0, 0); } @@ -1420,16 +1416,18 @@ static void durchreisende(FILE * F, const region * r, const faction * f) ++counter; if (u->ship != NULL) { #ifdef GERMAN_FLUFF_ENABLED - if (counter == 1) { - bytes = (int)strlcpy(bufp, "Die ", size); - } - else { - bytes = (int)strlcpy(bufp, "die ", size); - } - if (wrptr(&bufp, &size, bytes) != 0) { - WARN_STATIC_BUFFER(); - break; - } + if (strcmp("de", f->locale->name)==0) { + if (counter == 1) { + bytes = (int)strlcpy(bufp, "Die ", size); + } + else { + bytes = (int)strlcpy(bufp, "die ", size); + } + if (wrptr(&bufp, &size, bytes) != 0) { + WARN_STATIC_BUFFER(); + break; + } + } #endif bytes = (int)strlcpy(bufp, shipname(u->ship), size); } @@ -1827,7 +1825,7 @@ static void guards(FILE * F, const region * r, const faction * see) size_t size = sizeof(buf) - 1; int bytes; - bytes = (int)strlcpy(bufp, "Die Region wird von ", size); + bytes = (int)strlcpy(bufp, LOC(see->locale, "nr_guarding_prefix"), size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -1846,12 +1844,12 @@ static void guards(FILE * F, const region * r, const faction * see) bytes = (int)strlcpy(bufp, factionname(guardians[i]), size); } else { - bytes = (int)strlcpy(bufp, "unbekannten Einheiten", size); + bytes = (int)strlcpy(bufp, LOC(see->locale, "nr_guarding_unknown"), size); } if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } - bytes = (int)strlcpy(bufp, " bewacht.", size); + bytes = (int)strlcpy(bufp, LOC(see->locale, "nr_guarding_postfix"), size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); rnl(F); @@ -1984,6 +1982,7 @@ const faction * f) const char *name, *bname, *billusion = NULL; const struct locale *lang = NULL; char buffer[8192], *bufp = buffer; + message *msg; size_t size = sizeof(buffer) - 1; rnl(F); @@ -2014,26 +2013,17 @@ const faction * f) } if (b->size < b->type->maxsize) { - bytes = (int)strlcpy(bufp, " (im Bau)", size); + bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_building_inprogress"), size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } if (b->besieged > 0 && sr->mode >= see_lighthouse) { - bytes = (int)strlcpy(bufp, ", belagert von ", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)strlcpy(bufp, itoa10(b->besieged), size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)strlcpy(bufp, " Personen ", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - if (b->besieged >= b->size * SIEGEFACTOR) { - bytes = (int)strlcpy(bufp, "(abgeschnitten)", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - } + msg = msg_message("nr_building_besieged", "soldiers diff", b->besieged, b->besieged - b->size * SIEGEFACTOR); + bytes = (int)nr_render(msg, f->locale, bufp, size, f); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + msg_release(msg); } i = 0; if (b->display && b->display[0]) { From 5e4ea5a145f893e402881dac785655748c4c9c9b Mon Sep 17 00:00:00 2001 From: Steffen Mecke Date: Fri, 30 Jan 2015 20:43:40 +0100 Subject: [PATCH 2/2] fixed formatting errors --- src/report.c | 165 ++++++++++++++++++++++++++------------------------- 1 file changed, 85 insertions(+), 80 deletions(-) diff --git a/src/report.c b/src/report.c index 98ba9c042..4f385470f 100644 --- a/src/report.c +++ b/src/report.c @@ -634,8 +634,8 @@ int indent) for (; a; a = a->next) { char buf[4096]; - message *msg; - + message *msg; + if (fval(a->type, ATF_CURSE)) { curse *c = (curse *)a->data.v; @@ -654,10 +654,11 @@ int indent) else if (a->type == &at_effect && self) { effect_data *data = (effect_data *)a->data.v; if (data->value > 0) { - msg = msg_message("nr_potion_effect", "potion left", data->type->itype->rtype, data->value); - nr_render(msg, viewer->locale, buf, sizeof(buf), viewer); - rparagraph(F, buf, indent, 2, 0); - msg_release(msg); + msg = msg_message("nr_potion_effect", "potion left", + data->type->itype->rtype, data->value); + nr_render(msg, viewer->locale, buf, sizeof(buf), viewer); + rparagraph(F, buf, indent, 2, 0); + msg_release(msg); } } } @@ -823,41 +824,43 @@ static void prices(FILE * F, const region * r, const faction * f) if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); - for (dmd = r->land->demands; dmd; dmd = dmd->next) + for (dmd = r->land->demands; dmd; dmd = dmd->next){ if (dmd->value > 0) { - m = msg_message("nr_market_price", "product price", - dmd->type->itype->rtype, dmd->value * dmd->type->price); - bytes = (int)nr_render(m, f->locale, bufp, size, f); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - msg_release(m); - n--; - if (n == 0) { - bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_end"), size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - } - else if (n == 1) { - bytes = (int)strlcpy(bufp, " ", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_final"), size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)strlcpy(bufp, " ", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - } - else { - bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_next"), size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - bytes = (int)strlcpy(bufp, " ", size); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - } + m = msg_message("nr_market_price", "product price", + dmd->type->itype->rtype, dmd->value * dmd->type->price); + bytes = (int)nr_render(m, f->locale, bufp, size, f); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + msg_release(m); + n--; + if (n == 0) { + bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_end"), + size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + } else if (n == 1) { + bytes = (int)strlcpy(bufp, " ", size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_final"), + size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + bytes = (int)strlcpy(bufp, " ", size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + } else { + bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_trade_next"), + size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + bytes = (int)strlcpy(bufp, " ", size); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + } } } + } /* Schreibe Paragraphen */ *bufp = 0; rparagraph(F, buf, 0, 0, 0); @@ -1096,12 +1099,12 @@ static void describe(FILE * F, const seen_region * sr, faction * f) if (rule_region_owners()) { const faction *owner = region_get_owner(r); - message *msg; + message *msg; if (owner != NULL) { - msg = msg_message("nr_region_owner", "faction", owner); - bytes = (int)nr_render(msg, f->locale, bufp, size, f); - msg_release(msg); + msg = msg_message("nr_region_owner", "faction", owner); + bytes = (int)nr_render(msg, f->locale, bufp, size, f); + msg_release(msg); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } @@ -1207,7 +1210,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f) bufp = buf; size = sizeof(buf) - 1; - // this localization might not work for every language but is fine for de and en + // this localization might not work for every language but is fine for de and en bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_schemes_prefix"), size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); @@ -1250,14 +1253,14 @@ static void describe(FILE * F, const seen_region * sr, faction * f) rnl(F); for (e = edges; e; e = e->next) { bool first = true; - message *msg; + message *msg; bufp = buf; size = sizeof(buf) - 1; for (d = 0; d != MAXDIRECTIONS; ++d) { if (!e->exist[d]) continue; - // this localization might not work for every language but is fine for de and en + // this localization might not work for every language but is fine for de and en if (first) bytes = (int)strlcpy(bufp, LOC(f->locale, "nr_borderlist_prefix"), size); else if (e->lastd == d) @@ -1271,12 +1274,13 @@ static void describe(FILE * F, const seen_region * sr, faction * f) WARN_STATIC_BUFFER(); first = false; } - // TODO name is localized? Works for roads anyway... - msg = msg_message("nr_borderlist_postfix", "transparent object", e->transparent, e->name); - bytes = (int)nr_render(msg, f->locale, bufp, size, f); - msg_release(msg); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); + // TODO name is localized? Works for roads anyway... + msg = msg_message("nr_borderlist_postfix", "transparent object", + e->transparent, e->name); + bytes = (int)nr_render(msg, f->locale, bufp, size, f); + msg_release(msg); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); *bufp = 0; rparagraph(F, buf, 0, 0, 0); @@ -1416,18 +1420,18 @@ static void durchreisende(FILE * F, const region * r, const faction * f) ++counter; if (u->ship != NULL) { #ifdef GERMAN_FLUFF_ENABLED - if (strcmp("de", f->locale->name)==0) { - if (counter == 1) { - bytes = (int)strlcpy(bufp, "Die ", size); - } - else { - bytes = (int)strlcpy(bufp, "die ", size); - } - if (wrptr(&bufp, &size, bytes) != 0) { - WARN_STATIC_BUFFER(); - break; - } - } + if (strcmp("de", f->locale->name)==0) { + if (counter == 1) { + bytes = (int)strlcpy(bufp, "Die ", size); + } + else { + bytes = (int)strlcpy(bufp, "die ", size); + } + if (wrptr(&bufp, &size, bytes) != 0) { + WARN_STATIC_BUFFER(); + break; + } + } #endif bytes = (int)strlcpy(bufp, shipname(u->ship), size); } @@ -2019,11 +2023,12 @@ const faction * f) } if (b->besieged > 0 && sr->mode >= see_lighthouse) { - msg = msg_message("nr_building_besieged", "soldiers diff", b->besieged, b->besieged - b->size * SIEGEFACTOR); - bytes = (int)nr_render(msg, f->locale, bufp, size, f); - if (wrptr(&bufp, &size, bytes) != 0) - WARN_STATIC_BUFFER(); - msg_release(msg); + msg = msg_message("nr_building_besieged", "soldiers diff", b->besieged, + b->besieged - b->size * SIEGEFACTOR); + bytes = (int)nr_render(msg, f->locale, bufp, size, f); + if (wrptr(&bufp, &size, bytes) != 0) + WARN_STATIC_BUFFER(); + msg_release(msg); } i = 0; if (b->display && b->display[0]) { @@ -2562,21 +2567,21 @@ static void update_find(void) if (initial) for (r = regions; r; r = r->next) { - unit *u; - for (u = r->units; u; u = u->next) { - faction *lastf = u->faction; - unit *u2; - for (u2 = r->units; u2; u2 = u2->next) { - if (u2->faction == lastf || u2->faction == u->faction) - continue; - if (seefaction(u->faction, r, u2, 0)) { - faction *fv = visible_faction(u->faction, u2); - lastf = fv; - add_find(u->faction, u2, fv); + unit *u; + for (u = r->units; u; u = u->next) { + faction *lastf = u->faction; + unit *u2; + for (u2 = r->units; u2; u2 = u2->next) { + if (u2->faction == lastf || u2->faction == u->faction) + continue; + if (seefaction(u->faction, r, u2, 0)) { + faction *fv = visible_faction(u->faction, u2); + lastf = fv; + add_find(u->faction, u2, fv); + } } } } - } initial = false; }