forked from github/server
1. nrmessage is locale-independent, uses locale_getstring
2. unique strings: rename aurapotion50 message. delete unused bithday_firework definitions.
This commit is contained in:
parent
9ca945cb2c
commit
7a10a58605
|
@ -1688,12 +1688,6 @@
|
|||
<string name="mallornseed_p">
|
||||
<text locale="de">Mallornsamen</text>
|
||||
</string>
|
||||
<string name="birthday_firework">
|
||||
<text locale="de">Feuerwerk</text>
|
||||
</string>
|
||||
<string name="birthday_firework_p">
|
||||
<text locale="de">Feuerwerke</text>
|
||||
</string>
|
||||
<string name="lebkuchenherz">
|
||||
<text locale="de">Lebkuchenherz mit der Aufschrift 'Erz und
|
||||
Stein, das ist fein'</text>
|
||||
|
|
|
@ -874,12 +874,6 @@
|
|||
<string name="mallornseed_p">
|
||||
<text locale="en">mallorn seeds</text>
|
||||
</string>
|
||||
<string name="birthday_firework">
|
||||
<text locale="en">firework</text>
|
||||
</string>
|
||||
<string name="birthday_firework_p">
|
||||
<text locale="en">fireworks</text>
|
||||
</string>
|
||||
<string name="lebkuchenherz">
|
||||
<text locale="en">gingerbread heart</text>
|
||||
</string>
|
||||
|
|
|
@ -881,12 +881,6 @@
|
|||
<string name="mallornseed_p">
|
||||
<text locale="fr">graines de mallorn</text>
|
||||
</string>
|
||||
<string name="birthday_firework">
|
||||
<text locale="fr">feu d'artifice</text>
|
||||
</string>
|
||||
<string name="birthday_firework_p">
|
||||
<text locale="fr">feux d'artifice</text>
|
||||
</string>
|
||||
<string name="lebkuchenherz">
|
||||
<text locale="fr">coeur de pain d'épices</text>
|
||||
</string>
|
||||
|
|
|
@ -750,38 +750,6 @@
|
|||
<text locale="de">"$unit($unit) hat Glück und findet einen Hort von $int($amount) $resource($item,$amount)."</text>
|
||||
<text locale="en">"$unit($unit) luckily finds a cache of $int($amount) $resource($item,$amount)."</text>
|
||||
</message>
|
||||
<message name="birthday_firework_noname_local" section="events">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
</type>
|
||||
<text locale="de">"$unit($unit) brennt ein großes Feuerwerk ab und Kaskaden bunter Sterne, leuchtende Wasserfälle aus Licht und strahlende Feuerdrachen erhellen den Himmel."</text>
|
||||
<text locale="en">"A large firework is visible all over the sky."</text>
|
||||
</message>
|
||||
<message name="birthday_firework_noname" section="events">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
<arg name="region" type="region"/>
|
||||
</type>
|
||||
<text locale="de">"In $region($region) wird ein großes Feuerwerk abgebrannt, welches noch hier zu bewundern ist. Kaskaden bunter Sterne, leuchtende Wasserfälle aus Licht und strahlende Feuerdrachen erhellen den Himmel."</text>
|
||||
<text locale="en">"A large firework, visible all over the sky, has been started in $region($region)."</text>
|
||||
</message>
|
||||
<message name="birthday_firework_local" section="events">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
<arg name="name" type="string"/>
|
||||
</type>
|
||||
<text locale="de">"Zur Feier des Geburtstags von ${name} brennt $unit($unit) ein großes Feuerwerk ab. Kaskaden bunter Sterne, leuchtende Wasserfälle aus Licht und strahlende Feuerdrachen erhellen den Himmel."</text>
|
||||
<text locale="en">"A large firework in honor of ${name} is visible all over the sky."</text>
|
||||
</message>
|
||||
<message name="birthday_firework" section="events">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
<arg name="region" type="region"/>
|
||||
<arg name="name" type="string"/>
|
||||
</type>
|
||||
<text locale="de">"Zur Feier des Geburtstags von ${name} wird in $region($region) ein großes Feuerwerk abgebrannt, welches noch hier zu bewundern ist. Kaskaden bunter Sterne, leuchtende Wasserfälle aus Licht und strahlende Feuerdrachen erhellen den Himmel."</text>
|
||||
<text locale="en">"A large firework in honor of ${name}, visible all over the sky, has been started in $region($region)."</text>
|
||||
</message>
|
||||
<message name="battle_critical" section="battle">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
|
@ -7628,7 +7596,7 @@
|
|||
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - The $ship($ship) will now be faster."</text>
|
||||
</message>
|
||||
|
||||
<message name="aurapotion50" section="magic">
|
||||
<message name="aurapotion50_effect" section="magic">
|
||||
<type>
|
||||
<arg name="unit" type="unit"/>
|
||||
<arg name="region" type="region"/>
|
||||
|
|
|
@ -86,7 +86,7 @@ function test_aurapotion50()
|
|||
turn_begin()
|
||||
turn_process()
|
||||
assert_equal(0, u:get_item("aurapotion50"))
|
||||
assert_equal(1, f:count_msg_type('aurapotion50'))
|
||||
assert_equal(1, f:count_msg_type('aurapotion50_effect'))
|
||||
assert_equal(50, u.aura)
|
||||
turn_end()
|
||||
end
|
||||
|
|
|
@ -924,12 +924,6 @@ static void export_locale(const struct locale *lang, const char *name) {
|
|||
export_strings(lang, F);
|
||||
fclose(F);
|
||||
}
|
||||
sprintf(fname, "messages.%2s.po", name);
|
||||
F = fopen(fname, "wt");
|
||||
if (F) {
|
||||
export_messages(lang, F, NULL);
|
||||
fclose(F);
|
||||
}
|
||||
}
|
||||
|
||||
static int tolua_export_locales(lua_State *L) {
|
||||
|
|
|
@ -512,14 +512,14 @@ static void report_crtypes(FILE * F, const struct locale *lang)
|
|||
for (i = 0; i != MTMAXHASH; ++i) {
|
||||
struct known_mtype *kmt;
|
||||
for (kmt = mtypehash[i]; kmt; kmt = kmt->nexthash) {
|
||||
const struct nrmessage_type *nrt = nrt_find(lang, kmt->mtype);
|
||||
const struct nrmessage_type *nrt = nrt_find(kmt->mtype);
|
||||
if (nrt) {
|
||||
char buffer[DISPLAYSIZE];
|
||||
int hash = (int)kmt->mtype->key;
|
||||
assert(hash > 0);
|
||||
fprintf(F, "MESSAGETYPE %d\n", hash);
|
||||
fputc('\"', F);
|
||||
fputs(str_escape(nrt_string(nrt), buffer, sizeof(buffer)), F);
|
||||
fputs(str_escape(nrt_string(nrt, lang), buffer, sizeof(buffer)), F);
|
||||
fputs("\";text\n", F);
|
||||
fprintf(F, "\"%s\";section\n", nrt_section(nrt));
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ int amount, struct order *ord)
|
|||
|
||||
change_spellpoints(u, 50);
|
||||
|
||||
ADDMSG(&u->faction->msgs, msg_message("aurapotion50",
|
||||
ADDMSG(&u->faction->msgs, msg_message("aurapotion50_effect",
|
||||
"unit region command", u, u->region, ord));
|
||||
|
||||
use_pooled(u, itype->rtype, GET_DEFAULT, 1);
|
||||
|
|
|
@ -30,38 +30,26 @@
|
|||
#define NRT_MAXHASH 1021
|
||||
static nrmessage_type *nrtypes[NRT_MAXHASH];
|
||||
|
||||
const char *nrt_string(const struct nrmessage_type *type)
|
||||
const char *nrt_string(const struct nrmessage_type *nrt, const struct locale *lang)
|
||||
{
|
||||
if (type->string) {
|
||||
return type->string;
|
||||
}
|
||||
return locale_get(type->lang, type->mtype->name);
|
||||
return locale_getstring(lang, nrt->mtype->name);
|
||||
}
|
||||
|
||||
nrmessage_type *nrt_find(const struct locale * lang,
|
||||
const struct message_type * mtype)
|
||||
nrmessage_type *nrt_find(const struct message_type * mtype)
|
||||
{
|
||||
nrmessage_type *found = NULL;
|
||||
unsigned int hash = mtype->key % NRT_MAXHASH;
|
||||
nrmessage_type *type = nrtypes[hash];
|
||||
while (type) {
|
||||
if (type->mtype == mtype) {
|
||||
if (found == NULL)
|
||||
if (found == NULL) {
|
||||
found = type;
|
||||
else if (type->lang == NULL)
|
||||
found = type;
|
||||
if (lang == type->lang) {
|
||||
found = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
type = type->next;
|
||||
}
|
||||
if (!found) {
|
||||
log_warning("could not find nr-type %s for locale %s\n", mtype->name, locale_name(lang));
|
||||
}
|
||||
if (lang && found && found->lang != lang) {
|
||||
log_warning("could not find nr-type %s for locale %s, using %s\n", mtype->name, locale_name(lang), locale_name(found->lang));
|
||||
log_warning("could not find nr-type %s\n", mtype->name);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
@ -100,12 +88,11 @@ const nrsection *section_add(const char *name)
|
|||
}
|
||||
|
||||
void
|
||||
nrt_register(const struct message_type *mtype, const struct locale *lang,
|
||||
const char *string, int level, const char *section)
|
||||
nrt_register(const struct message_type *mtype, const char *section)
|
||||
{
|
||||
unsigned int hash = mtype->key % NRT_MAXHASH;
|
||||
nrmessage_type *nrt = nrtypes[hash];
|
||||
while (nrt && (nrt->lang != lang || nrt->mtype != mtype)) {
|
||||
while (nrt && nrt->mtype != mtype) {
|
||||
nrt = nrt->next;
|
||||
}
|
||||
if (nrt) {
|
||||
|
@ -117,10 +104,8 @@ const char *string, int level, const char *section)
|
|||
char zNames[256];
|
||||
char *c = zNames;
|
||||
nrt = malloc(sizeof(nrmessage_type));
|
||||
nrt->lang = lang;
|
||||
nrt->mtype = mtype;
|
||||
nrt->next = nrtypes[hash];
|
||||
nrt->level = level;
|
||||
if (section) {
|
||||
const nrsection *s = section_find(section);
|
||||
if (s == NULL) {
|
||||
|
@ -131,8 +116,6 @@ const char *string, int level, const char *section)
|
|||
else
|
||||
nrt->section = NULL;
|
||||
nrtypes[hash] = nrt;
|
||||
assert(string && *string);
|
||||
nrt->string = str_strdup(string);
|
||||
*c = '\0';
|
||||
for (i = 0; i != mtype->nparameters; ++i) {
|
||||
if (i != 0)
|
||||
|
@ -147,11 +130,11 @@ size_t
|
|||
nr_render(const struct message *msg, const struct locale *lang, char *buffer,
|
||||
size_t size, const void *userdata)
|
||||
{
|
||||
struct nrmessage_type *nrt = nrt_find(lang, msg->type);
|
||||
struct nrmessage_type *nrt = nrt_find(msg->type);
|
||||
|
||||
if (nrt) {
|
||||
const char *m =
|
||||
translate(nrt_string(nrt), userdata, nrt->vars, msg->parameters);
|
||||
translate(nrt_string(nrt, lang), userdata, nrt->vars, msg->parameters);
|
||||
if (m) {
|
||||
return str_strlcpy((char *)buffer, m, size);
|
||||
}
|
||||
|
@ -164,15 +147,9 @@ size_t size, const void *userdata)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int nr_level(const struct message *msg)
|
||||
{
|
||||
nrmessage_type *nrt = nrt_find(NULL, msg->type);
|
||||
return nrt ? nrt->level : 0;
|
||||
}
|
||||
|
||||
const char *nr_section(const struct message *msg)
|
||||
{
|
||||
nrmessage_type *nrt = nrt_find(default_locale, msg->type);
|
||||
nrmessage_type *nrt = nrt_find(msg->type);
|
||||
return nrt ? nrt->section : NULL;
|
||||
}
|
||||
|
||||
|
@ -187,20 +164,8 @@ void free_nrmesssages(void) {
|
|||
while (nrtypes[i]) {
|
||||
nrmessage_type *nr = nrtypes[i];
|
||||
nrtypes[i] = nr->next;
|
||||
free(nr->string);
|
||||
free(nr->vars);
|
||||
free(nr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void export_messages(const struct locale * lang, FILE *F, const char *context) {
|
||||
int i;
|
||||
for (i = 0; i != NRT_MAXHASH; ++i) {
|
||||
nrmessage_type *nrt = nrtypes[i];
|
||||
while (nrt) {
|
||||
po_write_msg(F, nrt->mtype->name, nrt->string, context);
|
||||
nrt = nrt->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,21 +34,15 @@ extern "C" {
|
|||
|
||||
void free_nrmesssages(void);
|
||||
|
||||
void nrt_register(const struct message_type *mtype,
|
||||
const struct locale *lang, const char *script,
|
||||
int level, const char *section);
|
||||
struct nrmessage_type *nrt_find(const struct locale *,
|
||||
const struct message_type *);
|
||||
const char *nrt_string(const struct nrmessage_type *type);
|
||||
const char *nrt_section(const struct nrmessage_type *mt);
|
||||
void nrt_register(const struct message_type *mtype, const char *section);
|
||||
struct nrmessage_type *nrt_find(const struct message_type *);
|
||||
const char *nrt_string(const struct nrmessage_type *nrt, const struct locale *lang);
|
||||
const char *nrt_section(const struct nrmessage_type *nrt);
|
||||
|
||||
size_t nr_render(const struct message *msg, const struct locale *lang,
|
||||
char *buffer, size_t size, const void *userdata);
|
||||
int nr_level(const struct message *msg);
|
||||
const char *nr_section(const struct message *msg);
|
||||
|
||||
void export_messages(const struct locale * lang, FILE *F, const char *context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -7,11 +7,8 @@
|
|||
|
||||
typedef struct nrmessage_type {
|
||||
const struct message_type *mtype;
|
||||
const struct locale *lang;
|
||||
char *string;
|
||||
char *vars;
|
||||
struct nrmessage_type *next;
|
||||
int level;
|
||||
const char *section;
|
||||
} nrmessage_type;
|
||||
|
||||
|
|
|
@ -1368,6 +1368,8 @@ static int parse_messages(xmlDocPtr doc)
|
|||
if (propSection == NULL)
|
||||
propSection = BAD_CAST default_section;
|
||||
|
||||
nrt_register(mtype, (const char *)propSection);
|
||||
|
||||
/* strings */
|
||||
xpath->node = node;
|
||||
result = xmlXPathEvalExpression(BAD_CAST "text", xpath);
|
||||
|
@ -1380,8 +1382,7 @@ static int parse_messages(xmlDocPtr doc)
|
|||
xml_readtext(node, &lang, &propText);
|
||||
if (lang) {
|
||||
xml_cleanup_string(propText);
|
||||
nrt_register(mtype, lang, (const char *)propText, 0,
|
||||
(const char *)propSection);
|
||||
locale_setstring(lang, mtype->name, (const char *)propText);
|
||||
}
|
||||
xmlFree(propText);
|
||||
|
||||
|
|
Loading…
Reference in New Issue