Skip to content

Commit

Permalink
Translate stat name outside enum_to_string (#34172)
Browse files Browse the repository at this point in the history
* translate stat name outside enum_to_string

* styling
  • Loading branch information
Fris0uman authored and ZhilkinSerg committed Sep 22, 2019
1 parent 827ea24 commit 2878906
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
22 changes: 18 additions & 4 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2331,10 +2331,10 @@ std::string enum_to_string<Character::stat>( Character::stat data )
{
switch( data ) {
// *INDENT-OFF*
case Character::stat::STRENGTH: return pgettext("strength stat", "STR");
case Character::stat::DEXTERITY: return pgettext("dexterity stat", "DEX");
case Character::stat::INTELLIGENCE: return pgettext("intelligence stat", "INT");
case Character::stat::PERCEPTION: return pgettext("perception stat", "PER");
case Character::stat::STRENGTH: return "STR";
case Character::stat::DEXTERITY: return "DEX";
case Character::stat::INTELLIGENCE: return "INT";
case Character::stat::PERCEPTION: return "PER";

// *INDENT-ON*
case Character::stat::DUMMY_STAT:
Expand Down Expand Up @@ -3944,3 +3944,17 @@ void Character::set_fac_id( const std::string &my_fac_id )
{
fac_id = string_id<faction>( my_fac_id );
}

std::string get_stat_name( Character::stat Stat )
{
switch( Stat ) {
// *INDENT-OFF*
case Character::stat::STRENGTH: return pgettext("strength stat", "STR");
case Character::stat::DEXTERITY: return pgettext("dexterity stat", "DEX");
case Character::stat::INTELLIGENCE: return pgettext("intelligence stat", "INT");
case Character::stat::PERCEPTION: return pgettext("perception stat", "PER");

case Character::stat::DUMMY_STAT: return pgettext( "fake stat there's an error", "ERR" );
break;
}
}
3 changes: 2 additions & 1 deletion src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1036,5 +1036,6 @@ template<>
struct enum_traits<Character::stat> {
static constexpr Character::stat last = Character::stat::DUMMY_STAT;
};

/**Get translated name of a stat*/
std::string get_stat_name( Character::stat Stat );
#endif
3 changes: 1 addition & 2 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2726,8 +2726,7 @@ std::string item::info( std::vector<iteminfo> &info, const iteminfo_query *parts
info.push_back( iteminfo( "DESCRIPTION", _( "<bold>Stat Bonus:</bold> " ),
iteminfo::no_newline ) );
for( const auto &element : bid->stat_bonus ) {
info.push_back( iteminfo( "CBM", io::enum_to_string<Character::stat>( element.first ), " <num> ",
iteminfo::no_newline,
info.push_back( iteminfo( "CBM", get_stat_name( element.first ), " <num> ", iteminfo::no_newline,
element.second ) );
}

Expand Down

0 comments on commit 2878906

Please sign in to comment.