Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix footsteps translation #37402

Merged
merged 11 commits into from
Jan 27, 2020
3 changes: 1 addition & 2 deletions src/monstergenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,7 @@ void MonsterGenerator::load_species( const JsonObject &jo, const std::string &sr
void species_type::load( const JsonObject &jo, const std::string & )
{
optional( jo, was_loaded, "description", description );
optional( jo, was_loaded, "footsteps", footsteps, "footsteps." );
footsteps = _( footsteps );
optional( jo, was_loaded, "footsteps", footsteps, to_translation( "footsteps." ) );
const auto flag_reader = enum_flags_reader<m_flag> { "monster flag" };
optional( jo, was_loaded, "flags", flags, flag_reader );

Expand Down
4 changes: 2 additions & 2 deletions src/monstergenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ struct species_type {
species_id id;
bool was_loaded = false;
translation description;
std::string footsteps;
translation footsteps;
enum_bitset<m_flag> flags;
enum_bitset<mon_trigger> anger;
enum_bitset<mon_trigger> fear;
enum_bitset<mon_trigger> placate;
std::string get_footsteps() const {
return footsteps;
return footsteps.translated();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested translating the string in this function in #31493 (comment), but that was rejected. What has changed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can profile performance again, but I don't think anything was changed since that time. My opinion is that we still need to translate this string only once during loading from json (unless we do something with performance).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t know what to do now, so I’ll take off WIP status. I just wanted to add some translation tags first. But after the code review we got this. I did not notice any drawdowns in performance, but I have an i7 processor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to address possible performance issues later and merge it as is.

}

species_type(): id( species_id::NULL_ID() ) {
Expand Down
2 changes: 1 addition & 1 deletion src/mtype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,5 @@ std::string mtype::get_footsteps() const
for( const species_id &s : species ) {
return s.obj().get_footsteps();
}
return "footsteps.";
return _( "footsteps." );
}