Merge pull request #3890 from DFHack/revert-3833-translate-name

Revert "use df's translate_name function if available"
develop
Myk 2023-10-15 22:05:51 -07:00 committed by GitHub
commit d38545032c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 24 deletions

@ -83,7 +83,6 @@ Template for new versions:
- unavailable tools are no longer listed in the tag indices in the online docs
## API
- Translate: will use DF's ``translate_name`` function, if available, instead of the DFHack emulation
## Lua
- added ``GRAY`` color aliases for ``GREY`` colors

@ -27,7 +27,6 @@ distribution.
#include <string>
#include <vector>
#include <map>
#include <functional>
#include "modules/Translation.h"
#include "VersionInfo.h"
@ -36,7 +35,6 @@ distribution.
#include "ModuleFactory.h"
#include "Core.h"
#include "Error.h"
#include "Debug.h"
using namespace DFHack;
using namespace df::enums;
@ -51,10 +49,6 @@ using df::global::world;
using df::global::d_init;
using df::global::gametype;
namespace DFHack {
DBG_DECLARE(core, translate, DebugCategory::LINFO);
}
bool Translation::IsValid ()
{
return (world && (world->raws.language.words.size() > 0) && (world->raws.language.translations.size() > 0));
@ -174,23 +168,6 @@ string Translation::TranslateName(const df::language_name * name, bool inEnglish
CHECK_NULL_POINTER(name);
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;
if (!onlyLastPart) {