|
|
@ -27,7 +27,7 @@ distribution.
|
|
|
|
#include <string>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <map>
|
|
|
|
#include <functional>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
#include "modules/Translation.h"
|
|
|
|
#include "modules/Translation.h"
|
|
|
|
#include "VersionInfo.h"
|
|
|
|
#include "VersionInfo.h"
|
|
|
@ -36,7 +36,6 @@ distribution.
|
|
|
|
#include "ModuleFactory.h"
|
|
|
|
#include "ModuleFactory.h"
|
|
|
|
#include "Core.h"
|
|
|
|
#include "Core.h"
|
|
|
|
#include "Error.h"
|
|
|
|
#include "Error.h"
|
|
|
|
#include "Debug.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace df::enums;
|
|
|
|
using namespace df::enums;
|
|
|
@ -45,16 +44,10 @@ using namespace df::enums;
|
|
|
|
#include "df/world.h"
|
|
|
|
#include "df/world.h"
|
|
|
|
#include "df/d_init.h"
|
|
|
|
#include "df/d_init.h"
|
|
|
|
|
|
|
|
|
|
|
|
using std::vector, std::string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using df::global::world;
|
|
|
|
using df::global::world;
|
|
|
|
using df::global::d_init;
|
|
|
|
using df::global::d_init;
|
|
|
|
using df::global::gametype;
|
|
|
|
using df::global::gametype;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DFHack {
|
|
|
|
|
|
|
|
DBG_DECLARE(core, translate, DebugCategory::LINFO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Translation::IsValid ()
|
|
|
|
bool Translation::IsValid ()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return (world && (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));
|
|
|
@ -174,23 +167,6 @@ string Translation::TranslateName(const df::language_name * name, bool inEnglish
|
|
|
|
CHECK_NULL_POINTER(name);
|
|
|
|
CHECK_NULL_POINTER(name);
|
|
|
|
|
|
|
|
|
|
|
|
string out;
|
|
|
|
string out;
|
|
|
|
|
|
|
|
|
|
|
|
auto fp = df::global::translate_name;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fp) {
|
|
|
|
|
|
|
|
DEBUG(translate).print("using df provided translate_name function\n");
|
|
|
|
|
|
|
|
typedef std::function<void(const df::language_name&, std::string&, bool, bool)> fun_type;
|
|
|
|
|
|
|
|
auto f = reinterpret_cast<fun_type*>(fp);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
(*f)(*name, out, inEnglish, onlyLastPart);
|
|
|
|
|
|
|
|
return out;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (...) {
|
|
|
|
|
|
|
|
WARN(translate).print("df provided translate_name function threw an exception, falling back\n");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEBUG(translate).print("using dfhack fallback translate_name function\n");
|
|
|
|
|
|
|
|
string word;
|
|
|
|
string word;
|
|
|
|
|
|
|
|
|
|
|
|
if (!onlyLastPart) {
|
|
|
|
if (!onlyLastPart) {
|
|
|
|