|
|
@ -38,15 +38,18 @@ using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace DFHack::Simple;
|
|
|
|
using namespace DFHack::Simple;
|
|
|
|
|
|
|
|
using namespace df::enums;
|
|
|
|
|
|
|
|
|
|
|
|
#include "DataDefs.h"
|
|
|
|
#include "DataDefs.h"
|
|
|
|
#include "df/world.h"
|
|
|
|
#include "df/world.h"
|
|
|
|
|
|
|
|
#include "df/d_init.h"
|
|
|
|
|
|
|
|
|
|
|
|
using df::global::world;
|
|
|
|
using df::global::world;
|
|
|
|
|
|
|
|
using df::global::d_init;
|
|
|
|
|
|
|
|
|
|
|
|
bool Translation::IsValid ()
|
|
|
|
bool Translation::IsValid ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return (world->raws.language.words.size() > 0) && (world->raws.language.translations.size() > 0);
|
|
|
|
return (world && (world->raws.language.words.size() > 0) && (world->raws.language.translations.size() > 0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Translation::readName(t_name & name, df::language_name * source)
|
|
|
|
bool Translation::readName(t_name & name, df::language_name * source)
|
|
|
@ -78,50 +81,78 @@ bool Translation::copyName(df::language_name * source, df::language_name * targe
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void addNameWord (string &out, const string &word)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (word.empty())
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
string upper = word;
|
|
|
|
|
|
|
|
upper[0] = toupper(upper[0]);
|
|
|
|
|
|
|
|
if (out.length() > 0)
|
|
|
|
|
|
|
|
out.append(" ");
|
|
|
|
|
|
|
|
out.append(upper);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string Translation::TranslateName(const df::language_name * name, bool inEnglish)
|
|
|
|
string Translation::TranslateName(const df::language_name * name, bool inEnglish)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string out;
|
|
|
|
string out;
|
|
|
|
|
|
|
|
string word;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!name->first_name.empty())
|
|
|
|
|
|
|
|
addNameWord(out, name->first_name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!name->nickname.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
word = "`" + name->nickname + "'";
|
|
|
|
|
|
|
|
switch (d_init ? d_init->nickname_dwarf : d_init_nickname::CENTRALIZE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case d_init_nickname::REPLACE_ALL:
|
|
|
|
|
|
|
|
out = word;
|
|
|
|
|
|
|
|
return out;
|
|
|
|
|
|
|
|
case d_init_nickname::REPLACE_FIRST:
|
|
|
|
|
|
|
|
out = "";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case d_init_nickname::CENTRALIZE:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
addNameWord(out, word);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(!inEnglish)
|
|
|
|
if (!inEnglish)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (name->words[0] >= 0 || name->words[1] >= 0)
|
|
|
|
if (name->words[0] >= 0 || name->words[1] >= 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
word.clear();
|
|
|
|
if (name->words[0] >= 0)
|
|
|
|
if (name->words[0] >= 0)
|
|
|
|
out.append(*world->raws.language.translations[name->language]->words[name->words[0]]);
|
|
|
|
word.append(*world->raws.language.translations[name->language]->words[name->words[0]]);
|
|
|
|
if (name->words[1] >= 0)
|
|
|
|
if (name->words[1] >= 0)
|
|
|
|
out.append(*world->raws.language.translations[name->language]->words[name->words[1]]);
|
|
|
|
word.append(*world->raws.language.translations[name->language]->words[name->words[1]]);
|
|
|
|
out[0] = toupper(out[0]);
|
|
|
|
addNameWord(out, word);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (name->words[5] >= 0)
|
|
|
|
if (name->words[5] >= 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string word;
|
|
|
|
word.clear();
|
|
|
|
for (int i = 2; i <= 5; i++)
|
|
|
|
for (int i = 2; i <= 5; i++)
|
|
|
|
if (name->words[i] >= 0)
|
|
|
|
if (name->words[i] >= 0)
|
|
|
|
word.append(*world->raws.language.translations[name->language]->words[name->words[i]]);
|
|
|
|
word.append(*world->raws.language.translations[name->language]->words[name->words[i]]);
|
|
|
|
word[0] = toupper(word[0]);
|
|
|
|
addNameWord(out, word);
|
|
|
|
if (out.length() > 0)
|
|
|
|
|
|
|
|
out.append(" ");
|
|
|
|
|
|
|
|
out.append(word);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (name->words[6] >= 0)
|
|
|
|
if (name->words[6] >= 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string word = *world->raws.language.translations[name->language]->words[name->words[6]];
|
|
|
|
word.clear();
|
|
|
|
|
|
|
|
word.append(*world->raws.language.translations[name->language]->words[name->words[6]]);
|
|
|
|
word[0] = toupper(word[0]);
|
|
|
|
addNameWord(out, word);
|
|
|
|
if (out.length() > 0)
|
|
|
|
|
|
|
|
out.append(" ");
|
|
|
|
|
|
|
|
out.append(word);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (name->words[0] >= 0 || name->words[1] >= 0)
|
|
|
|
if (name->words[0] >= 0 || name->words[1] >= 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
word.clear();
|
|
|
|
if (name->words[0] >= 0)
|
|
|
|
if (name->words[0] >= 0)
|
|
|
|
out.append(world->raws.language.words[name->words[0]]->forms[name->parts_of_speech[0].value]);
|
|
|
|
word.append(world->raws.language.words[name->words[0]]->forms[name->parts_of_speech[0].value]);
|
|
|
|
if (name->words[1] >= 0)
|
|
|
|
if (name->words[1] >= 0)
|
|
|
|
out.append(world->raws.language.words[name->words[1]]->forms[name->parts_of_speech[1].value]);
|
|
|
|
word.append(world->raws.language.words[name->words[1]]->forms[name->parts_of_speech[1].value]);
|
|
|
|
out[0] = toupper(out[0]);
|
|
|
|
addNameWord(out, word);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (name->words[5] >= 0)
|
|
|
|
if (name->words[5] >= 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -129,14 +160,11 @@ string Translation::TranslateName(const df::language_name * name, bool inEnglish
|
|
|
|
out.append(" the");
|
|
|
|
out.append(" the");
|
|
|
|
else
|
|
|
|
else
|
|
|
|
out.append("The");
|
|
|
|
out.append("The");
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 2; i <= 5; i++)
|
|
|
|
for (int i = 2; i <= 5; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (name->words[i] >= 0)
|
|
|
|
if (name->words[i] >= 0)
|
|
|
|
{
|
|
|
|
addNameWord(out, world->raws.language.words[name->words[i]]->forms[name->parts_of_speech[i].value]);
|
|
|
|
string word = world->raws.language.words[name->words[i]]->forms[name->parts_of_speech[i].value];
|
|
|
|
|
|
|
|
word[0] = toupper(word[0]);
|
|
|
|
|
|
|
|
out.append(" " + word);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (name->words[6] >= 0)
|
|
|
|
if (name->words[6] >= 0)
|
|
|
@ -146,10 +174,9 @@ string Translation::TranslateName(const df::language_name * name, bool inEnglish
|
|
|
|
else
|
|
|
|
else
|
|
|
|
out.append("Of");
|
|
|
|
out.append("Of");
|
|
|
|
|
|
|
|
|
|
|
|
string word = world->raws.language.words[name->words[6]]->forms[name->parts_of_speech[6].value];
|
|
|
|
addNameWord(out, world->raws.language.words[name->words[6]]->forms[name->parts_of_speech[6].value]);
|
|
|
|
word[0] = toupper(word[0]);
|
|
|
|
|
|
|
|
out.append(" " + word);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return out;
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|