Translating the familiar-description and moving some part to documentation.
This commit is contained in:
Enno Rehling 2007-04-08 07:43:39 +00:00
parent 81a89b8d47
commit d57e6724d1
5 changed files with 157 additions and 162 deletions

View File

@ -2083,7 +2083,7 @@ report_plaintext(const char * filename, report_context * ctx)
} }
if (!fval(r->terrain, SEA_REGION)) { if (!fval(r->terrain, SEA_REGION)) {
if (sh->coast != NODIRECTION) { if (sh->coast != NODIRECTION) {
scat(", "); scat(LOC(f->locale, "list_and"));
scat(LOC(f->locale, coasts[sh->coast])); scat(LOC(f->locale, coasts[sh->coast]));
} }
} }

View File

@ -584,9 +584,7 @@ sp_summon_familiar(castorder *co)
dh = 0; dh = 0;
dh1 = 0; dh1 = 0;
sprintf(buf, "%s ruft einen Vertrauten. %s können ", for (sk=0;sk<MAXSKILLS;sk++) {
unitname(mage), LOC(mage->faction->locale, rc_name(rc, 1)));
for(sk=0;sk<MAXSKILLS;sk++) {
if (rc->bonus[sk] > -5) dh++; if (rc->bonus[sk] > -5) dh++;
} }
for(sk=0;sk<MAXSKILLS;sk++) { for(sk=0;sk<MAXSKILLS;sk++) {
@ -596,7 +594,7 @@ sp_summon_familiar(castorder *co)
dh1 = 1; dh1 = 1;
} else { } else {
if (dh == 0) { if (dh == 0) {
scat(" und "); scat(LOC(mage->faction->locale, "list_and"));
} else { } else {
scat(", "); scat(", ");
} }
@ -604,23 +602,8 @@ sp_summon_familiar(castorder *co)
scat(skillname(sk, mage->faction->locale)); scat(skillname(sk, mage->faction->locale));
} }
} }
scat(" lernen."); ADDMSG(&mage->faction->msgs, msg_message("familiar_describe",
scat(" "); "mage race skills", mage, rc, buf));
scat("Der Vertraute verleiht dem Magier einen Bonus auf jedes Talent ");
scat("(ausgenommen Magie), welches der Vertraute beherrscht.");
scat(" ");
scat("Das spezielle Band zu seinem Vertrauten ermöglicht dem Magier ");
scat("auch, Sprüche durch diesen zu wirken. So gezauberte Sprüche ");
scat("wirken auf die Region des Vertrauten und brauchen keine Fernzauber ");
scat("zu sein. Die maximale Entfernung dafür entspricht dem Talent des ");
scat("Magiers. Einen Spruch durch das Vertrautenband zu richten ist ");
scat("jedoch gewissen Einschränkungen unterworfen. Die Stufe des Zaubers ");
scat("kann nicht größer als das Magietalent des Vertrauten oder das halbe ");
scat("Talent des Magiers sein. Auch verdoppeln sich die Kosten für den ");
scat("Spruch. (Um einen Zauber durch den Vertrauten zu wirken, gibt ");
scat("man statt dem Magier dem Vertrauten den Befehl ZAUBERE.)");
addmessage(r, mage->faction, buf, MSG_MAGIC, ML_INFO);
return cast_level; return cast_level;
} }

View File

@ -198,187 +198,185 @@ static const char * parse(opstack **, const char* in, const void *);
static const char * static const char *
parse_symbol(opstack ** stack, const char* in, const void * userdata) parse_symbol(opstack ** stack, const char* in, const void * userdata)
/* in is the symbol name and following text, starting after the $ /* in is the symbol name and following text, starting after the $
* result goes on the stack * result goes on the stack
*/ */
{ {
boolean braces = false; boolean braces = false;
char symbol[32]; char symbol[32];
char *cp = symbol; /* current position */ char *cp = symbol; /* current position */
if (*in=='{') { if (*in=='{') {
braces = true; braces = true;
++in; ++in;
} }
while (isalnum(*in) || *in=='.') *cp++ = *in++; while (isalnum(*in) || *in=='.') *cp++ = *in++;
*cp = '\0'; *cp = '\0';
/* symbol will now contain the symbol name */ /* symbol will now contain the symbol name */
if (*in=='(') { if (*in=='(') {
/* it's a function we need to parse /* it's a function we need to parse, start by reading the parameters */
* start by reading the parameters function * foo;
*/ while (*in != ')') {
function * foo; in = parse(stack, ++in, userdata); /* will push the result on the stack */
while (*in != ')') { if (in==NULL) return NULL;
in = parse(stack, ++in, userdata); /* will push the result on the stack */ }
if (in==NULL) return NULL; ++in;
} foo = find_function(symbol);
++in;
foo = find_function(symbol);
if (foo==NULL) { if (foo==NULL) {
log_error(("parser does not know about \"%s\" function.\n", symbol)); log_error(("parser does not know about \"%s\" function.\n", symbol));
return NULL; return NULL;
} }
foo->parse(stack, userdata); /* will pop parameters from stack (reverse order!) and push the result */ foo->parse(stack, userdata); /* will pop parameters from stack (reverse order!) and push the result */
} else { } else {
variable * var = find_variable(symbol); variable * var = find_variable(symbol);
if (braces && *in=='}') { if (braces && *in=='}') {
++in; ++in;
} }
/* it's a constant (variable is a misnomer, but heck, const was taken;)) */ /* it's a constant (variable is a misnomer, but heck, const was taken;)) */
if (var==NULL) { if (var==NULL) {
log_error(("parser does not know about \"%s\" variable.\n", symbol)); log_error(("parser does not know about \"%s\" variable.\n", symbol));
return NULL; return NULL;
} }
opush(stack, var->value); opush(stack, var->value);
} }
return in; return in;
} }
static const char * static const char *
parse_string(opstack ** stack, const char* in, const void * userdata) /* (char*) -> char* */ parse_string(opstack ** stack, const char* in, const void * userdata) /* (char*) -> char* */
{ {
char * c; char * c;
char * buffer = balloc(4*1024); char * buffer = balloc(4*1024);
const char * ic = in; const char * ic = in;
char * oc = buffer; char * oc = buffer;
/* mode flags */ /* mode flags */
boolean f_escape = false; boolean f_escape = false;
boolean bDone = false; boolean bDone = false;
variant var; variant var;
while (*ic && !bDone) { while (*ic && !bDone) {
if (f_escape) { if (f_escape) {
f_escape = false; f_escape = false;
switch (*ic) { switch (*ic) {
case 'n': case 'n':
*oc++='\n'; *oc++='\n';
break; break;
case 't': case 't':
*oc++='\t'; *oc++='\t';
break; break;
default: default:
*oc++=*ic; *oc++=*ic;
} }
} else { } else {
int ch = (unsigned char)(*ic); int ch = (unsigned char)(*ic);
switch (ch) { switch (ch) {
case '\\': case '\\':
f_escape = true; f_escape = true;
++ic; ++ic;
break; break;
case '"': case '"':
bDone = true; bDone = true;
++ic; ++ic;
break; break;
case '$': case '$':
ic = parse_symbol(stack, ++ic, userdata); ic = parse_symbol(stack, ++ic, userdata);
if (ic==NULL) return NULL; if (ic==NULL) return NULL;
c = (char*)opop_v(stack); c = (char*)opop_v(stack);
oc += strlen(strcpy(oc, c)); oc += strlen(strcpy(oc, c));
bfree(c); bfree(c);
break; break;
default: default:
*oc++=*ic++; *oc++=*ic++;
} }
} }
} }
*oc++ = '\0'; *oc++ = '\0';
bfree(oc); bfree(oc);
var.v = buffer; var.v = buffer;
opush(stack, var); opush(stack, var);
return ic; return ic;
} }
static const char * static const char *
parse_int(opstack ** stack, const char * in) parse_int(opstack ** stack, const char * in)
{ {
int k = 0; int k = 0;
int vz = 1; int vz = 1;
boolean ok = false; boolean ok = false;
variant var; variant var;
do { do {
switch (*in) { switch (*in) {
case '+': case '+':
++in; ++in;
break; break;
case '-': case '-':
++in; ++in;
vz=vz*-1; vz=vz*-1;
break; break;
default: default:
ok = true; ok = true;
} }
} while (!ok); } while (!ok);
while (isdigit(*in)) { while (isdigit(*in)) {
k = k * 10 + (*in++)-'0'; k = k * 10 + (*in++)-'0';
} }
var.i = k*vz; var.i = k*vz;
opush(stack, var); opush(stack, var);
return in; return in;
} }
static const char * static const char *
parse(opstack ** stack, const char* inn, const void * userdata) parse(opstack ** stack, const char* inn, const void * userdata)
{ {
const char * b = inn; const char * b = inn;
while (*b) { while (*b) {
switch (*b) { switch (*b) {
case '"': case '"':
return parse_string(stack, ++b, userdata); return parse_string(stack, ++b, userdata);
break; break;
case '$': case '$':
return parse_symbol(stack, ++b, userdata); return parse_symbol(stack, ++b, userdata);
break; break;
default: default:
if (isdigit(*b) || *b=='-' || *b=='+') { if (isdigit(*b) || *b=='-' || *b=='+') {
return parse_int(stack, b); return parse_int(stack, b);
} }
else ++b; else ++b;
} }
} }
log_error(("could not parse \"%s\". Probably invalid message syntax.", inn)); log_error(("could not parse \"%s\". Probably invalid message syntax.", inn));
return NULL; return NULL;
} }
const char * const char *
translate(const char* format, const void * userdata, const char* vars, variant args[]) translate(const char* format, const void * userdata, const char* vars, variant args[])
{ {
int i = 0; int i = 0;
const char *ic = vars; const char *ic = vars;
char symbol[32]; char symbol[32];
char *oc = symbol; char *oc = symbol;
opstack * stack = NULL; opstack * stack = NULL;
const char * rv; const char * rv;
brelease(); brelease();
free_variables(); free_variables();
assert(format); assert(format);
assert(*ic == 0 || isalnum(*ic)); assert(*ic == 0 || isalnum(*ic));
while (*ic) { while (*ic) {
*oc++ = *ic++; *oc++ = *ic++;
if (!isalnum(*ic)) { if (!isalnum(*ic)) {
variant x = args[i++]; variant x = args[i++];
*oc = '\0'; *oc = '\0';
oc = symbol; oc = symbol;
add_variable(strcpy(balloc(strlen(symbol)+1), symbol), x); add_variable(strcpy(balloc(strlen(symbol)+1), symbol), x);
while (*ic && !isalnum(*ic)) ++ic; while (*ic && !isalnum(*ic)) ++ic;
} }
} }
if (parse(&stack, format, userdata)==NULL) return NULL; if (parse(&stack, format, userdata)==NULL) return NULL;
rv = (const char*)opop(&stack).v; rv = (const char*)opop(&stack).v;
free(stack->begin); free(stack->begin);
free(stack); free(stack);
return rv; return rv;

View File

@ -6837,4 +6837,9 @@
<text locale="de">bewacht die Region</text> <text locale="de">bewacht die Region</text>
<text locale="en">guards the region</text> <text locale="en">guards the region</text>
</string> </string>
<string name="list_and">
<text locale="de"> und </text>
<text locale="en"> and </text>
</string>
</strings> </strings>

View File

@ -1704,6 +1704,15 @@
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - $unit($mage) kann nicht genug Energie aufbringen, um diesen Spruch durch $unit($unit) zu wirken."</text> <text locale="de">"$unit($unit) in $region($region): '$order($command)' - $unit($mage) kann nicht genug Energie aufbringen, um diesen Spruch durch $unit($unit) zu wirken."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - $unit($mage) cannot raise enough energy to channel the spell through $unit($unit)."</text> <text locale="en">"$unit($unit) in $region($region): '$order($command)' - $unit($mage) cannot raise enough energy to channel the spell through $unit($unit)."</text>
</message> </message>
<message name="familiar_describe" section="magic">
<type>
<arg name="mage" type="unit"/>
<arg name="skills" type="string"/>
<arg name="race" type="race"/>
</type>
<text locale="de">"$unit($mage) ruft einen Vertrauten. $race($race, 0) können $skills lernen."</text>
<text locale="en">"$unit($mage) summons a familiar. $race($race, 0) can learn $skills."</text>
</message>
<message name="spell_resist" section="magic"> <message name="spell_resist" section="magic">
<type> <type>
<arg name="unit" type="unit"/> <arg name="unit" type="unit"/>