simplified sue of localized parameter-strings in messages

This commit is contained in:
Enno Rehling 2007-05-28 20:04:42 +00:00
parent b5d6b0876e
commit 5ca0e5cd8a
4 changed files with 21 additions and 22 deletions

View File

@ -1110,7 +1110,8 @@ recruit_archetype(unit * u, order * ord)
if (a==NULL) a = a_add(&u->building->attribs, a_new(&at_recruit)); if (a==NULL) a = a_add(&u->building->attribs, a_new(&at_recruit));
a->data.i += n*arch->size; a->data.i += n*arch->size;
} }
ADDMSG(&u->faction->msgs, msg_message("recruit_archetype", "unit archetype", u, arch->name)); ADDMSG(&u->faction->msgs, msg_message("recruit_archetype",
"unit amount archetype", u, n, arch->name));
return n; return n;
} else switch(n) { } else switch(n) {
case ENOMATERIALS: case ENOMATERIALS:

View File

@ -757,7 +757,7 @@ static void
eval_trail(struct opstack ** stack, const void * userdata) /* (int, int) -> int */ eval_trail(struct opstack ** stack, const void * userdata) /* (int, int) -> int */
{ {
const struct faction * f = (const struct faction *)userdata; const struct faction * f = (const struct faction *)userdata;
const struct locale * lang = (const struct locale*)opop(stack).v; const struct locale * lang = f?f->locale:default_locale;
const struct region * r = (const struct region*)opop(stack).v; const struct region * r = (const struct region*)opop(stack).v;
const char * trail = trailinto(r, lang); const char * trail = trailinto(r, lang);
const char * rn = f_regionid_s(r, f); const char * rn = f_regionid_s(r, f);

View File

@ -454,20 +454,11 @@ eval_int(opstack ** stack, const void * userdata)
static void static void
eval_localize(opstack ** stack, const void * userdata) /* (string, locale) -> string */ eval_localize(opstack ** stack, const void * userdata) /* (string, locale) -> string */
{ {
const struct locale *lang = (const struct locale *)opop_v(stack); const struct faction * f = (const struct faction *)userdata;
const struct locale *lang = f?f->locale:default_locale;
const char *c = (const char *)opop_v(stack); const char *c = (const char *)opop_v(stack);
c = locale_string(lang, c); c = locale_string(lang, c);
opush_v(stack, strcpy(balloc(strlen(c)+1), c)); opush_v(stack, strcpy(balloc(strlen(c)+1), c));
unused(userdata);
}
static void
eval_locale(opstack ** stack, const void * userdata) /* (string) -> locale */
{
const char *c = (const char *)opop_v(stack);
struct locale * lang = find_locale(c);
opush_v(stack, lang);
unused(userdata);
} }
void void
@ -481,7 +472,6 @@ translation_init(void)
add_function("if", &eval_if); add_function("if", &eval_if);
add_function("isnull", &eval_isnull); add_function("isnull", &eval_isnull);
add_function("localize", &eval_localize); add_function("localize", &eval_localize);
add_function("locale", &eval_locale);
} }
void void

View File

@ -714,9 +714,8 @@
<type> <type>
<arg name="region" type="region"/> <arg name="region" type="region"/>
</type> </type>
<text locale="de">$trail($region,$locale("de"))</text> <text locale="de">$trail($region)</text>
<text locale="fr">$trail($region,$locale("en"))</text> <text locale="en">$trail($region)</text>
<text locale="en">$trail($region,$locale("en"))</text>
</message> </message>
<message name="nr_migrants" section="nr"> <message name="nr_migrants" section="nr">
<type> <type>
@ -814,9 +813,8 @@
<arg name="dir" type="int"/> <arg name="dir" type="int"/>
<arg name="region" type="region"/> <arg name="region" type="region"/>
</type> </type>
<text locale="de">"Im $direction($dir) der Region liegt $trail($region,$locale("de"))"</text> <text locale="de">"Im $direction($dir) der Region liegt $trail($region)"</text>
<text locale="fr">"To the $direction($dir) lies $trail($region,$locale("en"))"</text> <text locale="en">"To the $direction($dir) lies $trail($region)"</text>
<text locale="en">"To the $direction($dir) lies $trail($region,$locale("en"))"</text>
</message> </message>
<message name="nr_market_price" section="nr"> <message name="nr_market_price" section="nr">
<type> <type>
@ -2704,8 +2702,8 @@
<arg name="herb" type="resource"/> <arg name="herb" type="resource"/>
<arg name="region" type="region"/> <arg name="region" type="region"/>
</type> </type>
<text locale="de">"$unit($unit) in $region($region) stellt fest, dass es hier $localize($amount,$locale("de")) $resource($herb,$amount) gibt."</text> <text locale="de">"$unit($unit) in $region($region) stellt fest, dass es hier $localize($amount) $resource($herb,0) gibt."</text>
<text locale="en">"$unit($unit) discovers that $localize($amount,$locale("en")) $resource($herb,$amount) grow in $region($region)."</text> <text locale="en">"$unit($unit) discovers that $localize($amount) $resource($herb,0) grow in $region($region)."</text>
</message> </message>
<message name="destroy_partial" section="events"> <message name="destroy_partial" section="events">
<type> <type>
@ -7266,4 +7264,14 @@
<text locale="en">"A message from $unit($unit): '$message'"</text> <text locale="en">"A message from $unit($unit): '$message'"</text>
</message> </message>
<message name="recruit_archetype" section="events">
<type>
<arg name="unit" type="unit"/>
<arg name="archetype" type="string"/>
<arg name="amount" type="int"/>
</type>
<text locale="de">"$unit($unit) rekrutiert $int($amount) $localize($archetype)."</text>
<text locale="en">"$unit($unit) recruits $int($amount) $localize($archetype)."</text>
</message>
</messages> </messages>