mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-23 07:27:07 +00:00
refactored basicrep and parrep: genderrep to avoid repeated lines in both %y0 and %yINDEX, no more need for special case when noun not found
This commit is contained in:
parent
f69fce0050
commit
fe68186e5a
221
language.cpp
221
language.cpp
@ -99,7 +99,7 @@ string choose3(int g, string a, string b, string c) {
|
||||
if(g == GEN_M || g == GEN_O) return a;
|
||||
if(g == GEN_F) return b;
|
||||
if(g == GEN_N) return c;
|
||||
return "unknown genus";
|
||||
return "?" + a;
|
||||
}
|
||||
|
||||
string choose4(int g, string a, string b, string c, string d) {
|
||||
@ -107,7 +107,7 @@ string choose4(int g, string a, string b, string c, string d) {
|
||||
if(g == GEN_F) return b;
|
||||
if(g == GEN_N) return c;
|
||||
if(g == GEN_O) return d;
|
||||
return "unknown genus";
|
||||
return "?" + a;
|
||||
}
|
||||
|
||||
set<string> warnshown;
|
||||
@ -118,8 +118,66 @@ EX bool translation_exists(const string& x) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void basicrep(string& x) {
|
||||
/** replace gender-based codes in x, based on gender genus; some gender-based codes need to know the word (nom) */
|
||||
void genderrep(string& x, string w, int genus, string nom) {
|
||||
#if CAP_TRANS
|
||||
int l = lang();
|
||||
if(l == 1) {
|
||||
rep(x, "%łem"+w, choose3(genus, "łem", "łam", "łom"));
|
||||
rep(x, "%łeś"+w, choose3(genus, "łeś", "łaś", "łoś"));
|
||||
rep(x, "%łeś"+w, choose3(genus, "łeś", "łaś", "łoś"));
|
||||
rep(x, "%ął"+w, choose3(genus, "ął", "ęła", "ęło"));
|
||||
rep(x, "%ąłeś"+w, choose3(genus, "ąłeś", "ęłaś", "ęłoś"));
|
||||
rep(x, "%ógł"+w, choose3(genus, "ógł", "ogła", "ogło"));
|
||||
rep(x, "%ł"+w, choose3(genus, "ł", "ła", "ło"));
|
||||
rep(x, "%y"+w, choose3(genus, "y", "a", "e"));
|
||||
rep(x, "%ya"+w, choose3(genus, "y", "a", "e"));
|
||||
rep(x, "%yą"+w, choose4(genus, "ego", "ą", "e", "y"));
|
||||
rep(x, "%oa"+w, choose3(genus, "", "a", "o"));
|
||||
rep(x, "%ymą"+w, choose3(genus, "ym", "ą", "ym"));
|
||||
rep(x, "%go"+w, choose3(genus, "go", "ją", "je"));
|
||||
rep(x, "%aka"+w, choose3(genus, "a", "ka", "a"));
|
||||
}
|
||||
|
||||
if(l == 3) {
|
||||
rep(x, "%l"+w, choose3(genus, "l", "la", "lo"));
|
||||
rep(x, "%d"+w, choose3(genus, "", "a", "o"));
|
||||
rep(x, "%ý"+w, choose3(genus, "ý", "á", "é"));
|
||||
rep(x, "%el"+w, choose3(genus, "el", "la", "lo"));
|
||||
rep(x, "%ůj"+w, choose4(genus, "ého", "ou", "é", "ůj"));
|
||||
rep(x, "%ým"+w, choose3(genus, "ým", "ou", "ým"));
|
||||
rep(x, "%ho"+w, choose3(genus, "ho", "ji", "ho"));
|
||||
rep(x, "%ého"+w, choose3(genus, "ého", "ou", "ého"));
|
||||
}
|
||||
|
||||
if(l == 4) {
|
||||
rep(x, "%E"+w, choose3(genus, "", "а", "о"));
|
||||
rep(x, "%A"+w, choose3(genus, "ый", "ая", "ое"));
|
||||
rep(x, "%c"+w, choose3(genus, "ся", "ась", ""));
|
||||
rep(x, "%y"+w, choose3(genus, "ый", "ая", "ое"));
|
||||
}
|
||||
|
||||
if(l == 5) {
|
||||
rep(x, "%Der"+w, genus == -1 ? "The" : choose3(genus, "Der", "Die", "Das"));
|
||||
rep(x, "%der"+w, genus == -1 ? "the" : choose3(genus, "der", "die", "das"));
|
||||
rep(x, "%den"+w, genus == -1 ? "the" : choose3(genus, "den", "die", "das"));
|
||||
rep(x, "%dem"+w, genus == -1 ? "the" : choose3(genus, "dem", "der", "dem"));
|
||||
}
|
||||
|
||||
if(l == 6) {
|
||||
rep(x, "%oa"+w, choose4(genus, "o", "a", "os", "as"));
|
||||
rep(x, "%seu"+w, choose4(genus, "seu", "sua", "seus", "suas"));
|
||||
rep(x, "%na"+w, choose4(genus, "o", "a", "os", "as") + " " + nom);
|
||||
rep(x, "%Na"+w, choose4(genus, "O", "A", "Os", "As") + " " + nom);
|
||||
rep(x, "%g"+w, choose4(genus, "do", "da", "dos", "das")+ " " + nom);
|
||||
rep(x, "%d"+w, choose4(genus, "ao", "à", "aos", "às")+ " " + nom);
|
||||
rep(x, "%l"+w, choose4(genus, "no", "na", "nos", "nas")+ " " + nom);
|
||||
rep(x, "%abl"+w, choose4(genus, "pelo", "pela", "pelos", "pelas")+ " " + nom);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void basicrep(string& x) {
|
||||
#if CAP_TRANS
|
||||
const sentence *s = findInHashTable(x, all_sentences);
|
||||
if(!s && !warnshown.count(x)) {
|
||||
@ -133,26 +191,7 @@ void basicrep(string& x) {
|
||||
if(s) x = s->xlat[l-1];
|
||||
}
|
||||
|
||||
if(l == 1) {
|
||||
rep(x, "%łeś0", choose3(playergender(), "łeś", "łaś", "łoś"));
|
||||
rep(x, "%ąłeś0", choose3(playergender(), "ąłeś", "ęłaś", "ęłoś"));
|
||||
rep(x, "%ógł0", choose3(playergender(), "ógł", "ogła", "ogło"));
|
||||
rep(x, "%ł0", choose3(playergender(), "ł", "ła", "ło"));
|
||||
rep(x, "%y0", choose3(playergender(), "y", "a", "e"));
|
||||
}
|
||||
|
||||
if(l == 3) {
|
||||
rep(x, "%l0", choose3(playergender(), "l", "la", "lo"));
|
||||
rep(x, "%d0", choose3(playergender(), "", "a", "o"));
|
||||
}
|
||||
|
||||
if(l == 4) {
|
||||
rep(x, "%E0", choose3(playergender(), "", "а", "о"));
|
||||
rep(x, "%A0", choose3(playergender(), "ый", "ая", "ое"));
|
||||
rep(x, "%c0", choose3(playergender(), "ся", "ась", ""));
|
||||
rep(x, "%y0", choose3(playergender(), "ый", "ая", "ое"));
|
||||
}
|
||||
|
||||
genderrep(x, "0", playergender(), "");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -160,133 +199,53 @@ void parrep(string& x, string w, stringpar p) {
|
||||
#if CAP_TRANS
|
||||
int l = lang();
|
||||
const fullnoun *N = findInHashTable(p.v, all_nouns);
|
||||
noun dummy;
|
||||
auto &data = N ? N->n[l-1] : dummy;
|
||||
if(!N) {
|
||||
dummy.nom = dummy.nomp = dummy.acc = dummy.abl = p.v.c_str();
|
||||
dummy.genus = -1;
|
||||
}
|
||||
|
||||
genderrep(x, w, data.genus, data.nom);
|
||||
|
||||
if(l == 1) {
|
||||
if(N) {
|
||||
rep(x, "%"+w, N->n[0].nom);
|
||||
rep(x, "%P"+w, N->n[0].nomp);
|
||||
rep(x, "%a"+w, N->n[0].acc);
|
||||
rep(x, "%abl"+w, N->n[0].abl);
|
||||
rep(x, "%ł"+w, choose3(N->n[0].genus, "ł", "ła", "ło"));
|
||||
rep(x, "%łem"+w, choose3(N->n[0].genus, "łem", "łam", "łom"));
|
||||
rep(x, "%łeś"+w, choose3(N->n[0].genus, "łeś", "łaś", "łoś"));
|
||||
rep(x, "%ął"+w, choose3(N->n[0].genus, "ął", "ęła", "ęło"));
|
||||
rep(x, "%ya"+w, choose3(N->n[0].genus, "y", "a", "e"));
|
||||
rep(x, "%yą"+w, choose4(N->n[0].genus, "ego", "ą", "e", "y"));
|
||||
rep(x, "%oa"+w, choose3(N->n[0].genus, "", "a", "o"));
|
||||
rep(x, "%ymą"+w, choose3(N->n[0].genus, "ym", "ą", "ym"));
|
||||
rep(x, "%go"+w, choose3(N->n[0].genus, "go", "ją", "je"));
|
||||
rep(x, "%aka"+w, choose3(N->n[0].genus, "a", "ka", "a"));
|
||||
}
|
||||
else {
|
||||
rep(x,"%"+w, p.v);
|
||||
rep(x, "%P"+w, p.v);
|
||||
rep(x, "%a"+w, p.v);
|
||||
rep(x, "%abl"+w, p.v);
|
||||
rep(x, "%ł"+w, choose3(0, "ł", "ła", "ło"));
|
||||
}
|
||||
rep(x, "%"+w, data.nom);
|
||||
rep(x, "%P"+w, data.nomp);
|
||||
rep(x, "%a"+w, data.acc);
|
||||
rep(x, "%abl"+w, data.abl);
|
||||
}
|
||||
if(l == 2) {
|
||||
if(N) {
|
||||
rep(x, "%"+w, N->n[1].nom);
|
||||
rep(x, "%P"+w, N->n[1].nomp);
|
||||
rep(x, "%a"+w, N->n[1].acc);
|
||||
rep(x, "%abl"+w, N->n[1].abl);
|
||||
}
|
||||
else {
|
||||
rep(x,"%"+w,p.v);
|
||||
rep(x, "%P"+w, p.v);
|
||||
rep(x, "%a"+w, p.v);
|
||||
rep(x, "%abl"+w, p.v);
|
||||
}
|
||||
}
|
||||
if(l == 3) {
|
||||
if(N) {
|
||||
rep(x, "%"+w, N->n[2].nom);
|
||||
rep(x, "%P"+w, N->n[2].nomp);
|
||||
rep(x, "%a"+w, N->n[2].acc);
|
||||
rep(x, "%abl"+w, N->n[2].abl);
|
||||
rep(x, "%ý"+w, choose3(N->n[2].genus, "ý", "á", "é"));
|
||||
rep(x, "%l"+w, choose3(N->n[2].genus, "l", "la", "lo"));
|
||||
rep(x, "%el"+w, choose3(N->n[2].genus, "el", "la", "lo"));
|
||||
rep(x, "%ůj"+w, choose4(N->n[2].genus, "ého", "ou", "é", "ůj"));
|
||||
rep(x, "%ým"+w, choose3(N->n[2].genus, "ým", "ou", "ým"));
|
||||
rep(x, "%ho"+w, choose3(N->n[2].genus, "ho", "ji", "ho"));
|
||||
rep(x, "%ého"+w, choose3(N->n[2].genus, "ého", "ou", "ého"));
|
||||
|
||||
rep(x, "%"+w, data.nom);
|
||||
rep(x, "%P"+w, data.nomp);
|
||||
rep(x, "%a"+w, data.acc);
|
||||
rep(x, "%abl"+w, data.abl);
|
||||
if(p.v == "Mirror Image")
|
||||
rep(x, "%s"+w, "se");
|
||||
if(p.v == "Mirage")
|
||||
rep(x, "%s"+w, "s");
|
||||
}
|
||||
else {
|
||||
rep(x,"%"+w,p.v);
|
||||
rep(x, "%P"+w, p.v);
|
||||
rep(x, "%a"+w, p.v);
|
||||
rep(x, "%abl"+w, p.v);
|
||||
}
|
||||
}
|
||||
if(l == 4) {
|
||||
if(N) {
|
||||
rep(x, "%"+w, N->n[3].nom);
|
||||
rep(x, "%P"+w, N->n[3].nomp);
|
||||
rep(x, "%a"+w, N->n[3].acc);
|
||||
rep(x, "%abl"+w, N->n[3].abl);
|
||||
rep(x, "%E"+w, choose3(N->n[3].genus, "", "а", "о"));
|
||||
rep(x, "%A"+w, choose3(N->n[3].genus, "ый", "ую", "ое"));
|
||||
rep(x, "%c"+w, choose3(N->n[3].genus, "ся", "ась", ""));
|
||||
rep(x, "%y"+w, choose3(N->n[3].genus, "ый", "ая", "ое"));
|
||||
}
|
||||
else {
|
||||
rep(x,"%"+w,p.v);
|
||||
rep(x, "%P"+w, p.v);
|
||||
rep(x, "%a"+w, p.v);
|
||||
rep(x, "%abl"+w, p.v);
|
||||
}
|
||||
rep(x, "%"+w, data.nom);
|
||||
rep(x, "%P"+w, data.nomp);
|
||||
rep(x, "%a"+w, data.acc);
|
||||
rep(x, "%abl"+w, data.abl);
|
||||
}
|
||||
if(l == 5) {
|
||||
if(N) {
|
||||
rep(x, "%"+w, N->n[4].nom);
|
||||
rep(x, "%P"+w, N->n[4].nomp);
|
||||
rep(x, "%a"+w, N->n[4].acc);
|
||||
rep(x, "%abl"+w, N->n[4].abl);
|
||||
rep(x, "%d"+w, N->n[4].abl); // Dativ (which equals Ablative in German)
|
||||
rep(x, "%Der"+w, choose3(N->n[4].genus, "Der", "Die", "Das"));
|
||||
rep(x, "%der"+w, choose3(N->n[4].genus, "der", "die", "das"));
|
||||
rep(x, "%den"+w, choose3(N->n[4].genus, "den", "die", "das"));
|
||||
rep(x, "%dem"+w, choose3(N->n[4].genus, "dem", "der", "dem"));
|
||||
}
|
||||
else {
|
||||
rep(x,"%"+w,p.v);
|
||||
rep(x, "%P"+w, p.v);
|
||||
rep(x, "%a"+w, p.v);
|
||||
rep(x, "%abl"+w, p.v);
|
||||
rep(x, "%Der"+w, "The");
|
||||
rep(x, "%der"+w, "the");
|
||||
rep(x, "%den"+w, "the");
|
||||
}
|
||||
rep(x, "%"+w, data.nom);
|
||||
rep(x, "%P"+w, data.nomp);
|
||||
rep(x, "%a"+w, data.acc);
|
||||
rep(x, "%abl"+w, data.abl);
|
||||
rep(x, "%d"+w, data.abl); // Dativ (which equals Ablative in German)
|
||||
}
|
||||
if(l == 6) {
|
||||
if(N) {
|
||||
rep(x, "%"+w, N->n[5].nom);
|
||||
rep(x, "%P"+w, N->n[5].nomp);
|
||||
rep(x, "%na"+w, choose4(N->n[5].genus, "o", "a", "os", "as") + " " + N->n[5].nom);
|
||||
rep(x, "%Na"+w, choose4(N->n[5].genus, "O", "A", "Os", "As") + " " + N->n[5].nom);
|
||||
rep(x, "%oa"+w, choose4(N->n[5].genus, "o", "a", "os", "as"));
|
||||
rep(x, "%g"+w, choose4(N->n[5].genus, "do", "da", "dos", "das")+ " " + N->n[5].nom);
|
||||
rep(x, "%d"+w, choose4(N->n[5].genus, "ao", "à", "aos", "às")+ " " + N->n[5].nom);
|
||||
rep(x, "%l"+w, choose4(N->n[5].genus, "no", "na", "nos", "nas")+ " " + N->n[5].nom);
|
||||
rep(x, "%abl"+w, choose4(N->n[5].genus, "pelo", "pela", "pelos", "pelas")+ " " + N->n[5].nom);
|
||||
rep(x, "%seu"+w, choose4(N->n[5].genus, "seu", "sua", "seus", "suas"));
|
||||
}
|
||||
else {
|
||||
rep(x, "%"+w,p.v);
|
||||
rep(x, "%P"+w, p.v);
|
||||
rep(x, "%na"+w, p.v);
|
||||
rep(x, "%g"+w, p.v);
|
||||
rep(x, "%d"+w, p.v);
|
||||
rep(x, "%l"+w, p.v);
|
||||
rep(x, "%abl"+w, p.v);
|
||||
}
|
||||
rep(x, "%"+w, data.nom);
|
||||
rep(x, "%P"+w, data.nomp);
|
||||
}
|
||||
#endif
|
||||
if(true) {
|
||||
|
Loading…
Reference in New Issue
Block a user