Skip to content

Commit

Permalink
Merge pull request #4975 from myk002/myk_translate
Browse files Browse the repository at this point in the history
[Translation] default inEnglish to false to match Lua API
  • Loading branch information
myk002 authored Oct 3, 2024
2 parents 32ed4f6 + e5324e3 commit ac5da59
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/dev/Lua API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ can be omitted.

* ``dfhack.TranslateName(name[,in_english[,only_last_name]])``

Convert a language_name or only the last name part to string.
Convert a ``df.language_name`` (or only the last name part) to string.

* ``dfhack.df2utf(string)``

Expand Down
2 changes: 1 addition & 1 deletion library/include/modules/Translation.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ DFHACK_EXPORT void setNickname(df::language_name *name, std::string nick);
DFHACK_EXPORT std::string capitalize(const std::string &str, bool all_words = false);

// translate a name using the loaded dictionaries
DFHACK_EXPORT std::string TranslateName (const df::language_name * name, bool inEnglish = true,
DFHACK_EXPORT std::string TranslateName (const df::language_name * name, bool inEnglish = false,
bool onlyLastPart = false);
}
}
Expand Down
4 changes: 2 additions & 2 deletions library/modules/Items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,8 +709,8 @@ static string get_base_desc(df::item *item) {
if (auto name = Items::getBookTitle(item); !name.empty())
return name;
if (auto artifact = get_artifact(item); artifact && artifact->name.has_name)
return Translation::TranslateName(&artifact->name, false) +
", " + Translation::TranslateName(&artifact->name) +
return Translation::TranslateName(&artifact->name) +
", " + Translation::TranslateName(&artifact->name, true) +
" (" + get_item_type_str(item) + ")";
return Items::getDescription(item, 0, true);
}
Expand Down
6 changes: 3 additions & 3 deletions library/modules/Units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ string Units::getReadableName(df::historical_figure *hf) {
prof_name = "Ghostly " + prof_name;
}

string name = Translation::TranslateName(getVisibleName(hf), false);
string name = Translation::TranslateName(getVisibleName(hf));
return name.empty() ? prof_name : name + ", " + prof_name;
}

Expand All @@ -1154,7 +1154,7 @@ string Units::getReadableName(df::unit *unit) {
if (isTame(unit))
prof_name += " (" + getTameTag(unit) + ")";

string name = Translation::TranslateName(getVisibleName(unit), false);
string name = Translation::TranslateName(getVisibleName(unit));
return name.empty() ? prof_name : name + ", " + prof_name;
}

Expand Down Expand Up @@ -1676,7 +1676,7 @@ static string get_land_title(Units::NoblePosition *np)
if (site_link->flags.bits.land_for_holding && site_link->position_profile_id == np->assignment->id)
{
auto site = df::world_site::find(site_link->target);
return site ? " of " + Translation::TranslateName(&site->name) : "";
return site ? " of " + Translation::TranslateName(&site->name, true) : "";
}
return "";
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoslab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static void checkslabs(color_ostream &out)
)
{
createSlabJob(ghost);
auto fullName = Translation::TranslateName(&ghost->name, false);
auto fullName = Translation::TranslateName(&ghost->name);
out.print("Added slab order for ghost %s\n", fullName.c_str());
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/cleanowned.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ command_result df_cleanowned (color_ostream &out, vector <string> & parameters)
df::unit *owner = Items::getOwner(item);

if (owner)
out.print(", owner %s", DF2CONSOLE(Translation::TranslateName(&owner->name,false)).c_str());
out.print(", owner %s", DF2CONSOLE(Translation::TranslateName(&owner->name)).c_str());

if (!dry_run)
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/remotefortressreader/remotefortressreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ static command_result GetUnitListInside(color_ostream &stream, const BlockReques
size_info->set_length_base(unit->body.size_info.length_base);
if (unit->name.has_name)
{
send_unit->set_name(DF2UTF(Translation::TranslateName(Units::getVisibleName(unit))));
send_unit->set_name(DF2UTF(Translation::TranslateName(Units::getVisibleName(unit), true)));
}

auto appearance = send_unit->mutable_appearance();
Expand Down
2 changes: 1 addition & 1 deletion plugins/showmood.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ command_result df_showmood (color_ostream &out, vector <string> & parameters)
out.printerr("Dwarf with strange mood does not have a mood type!\n");
continue;
}
out.print("%s is currently ", DF2CONSOLE(out, Translation::TranslateName(&unit->name, false)).c_str());
out.print("%s is currently ", DF2CONSOLE(out, Translation::TranslateName(&unit->name)).c_str());
switch (unit->mood)
{
case mood_type::Macabre:
Expand Down
2 changes: 1 addition & 1 deletion plugins/strangemood.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
if (unit->job.current_job)
{
// TODO: cancel job
out.printerr("Chosen unit '%s' has active job, cannot start mood!\n", Translation::TranslateName(&unit->name, false).c_str());
out.printerr("Chosen unit '%s' has active job, cannot start mood!\n", Translation::TranslateName(&unit->name).c_str());
return CR_FAILURE;
}

Expand Down
6 changes: 3 additions & 3 deletions plugins/tailor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class Tailor {
{
DEBUG(cycle).print ("tailor: %s (size %d) worn by %s (size %d) needs replacement\n",
DF2CONSOLE(description).c_str(), isize,
DF2CONSOLE(Translation::TranslateName(&u->name, false)).c_str(), usize);
DF2CONSOLE(Translation::TranslateName(&u->name)).c_str(), usize);
needed[std::make_pair(ty, usize)] += 1;
ordered.insert(ty);
}
Expand All @@ -329,7 +329,7 @@ class Tailor {
"tailor: %s %s from %s.\n",
(confiscated ? "confiscated" : "could not confiscate"),
DF2CONSOLE(description).c_str(),
DF2CONSOLE(Translation::TranslateName(&u->name, false)).c_str()
DF2CONSOLE(Translation::TranslateName(&u->name)).c_str()
);
}

Expand All @@ -346,7 +346,7 @@ class Tailor {
TRACE(cycle).print("tailor: one %s of size %d needed to cover %s\n",
ENUM_KEY_STR(item_type, ty).c_str(),
usize,
DF2CONSOLE(Translation::TranslateName(&u->name, false)).c_str());
DF2CONSOLE(Translation::TranslateName(&u->name)).c_str());
needed[std::make_pair(ty, usize)] += 1;
}
}
Expand Down

0 comments on commit ac5da59

Please sign in to comment.