Skip to content

Commit

Permalink
Fix use of plural/singular translation (ihhub#4858)
Browse files Browse the repository at this point in the history
  • Loading branch information
a1exsh authored Jan 1, 2022
1 parent 83b7b51 commit 984cc8c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 57 deletions.
2 changes: 1 addition & 1 deletion src/fheroes2/kingdom/kingdom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ void Kingdoms::AddTributeEvents( CapturedObjects & captureobj, const uint32_t da
if ( objectCount > 1 ) {
event.title = std::to_string( objectCount );
event.title += ' ';
event.title += MP2::getPluralObjectName( objectType, objectCount );
event.title += MP2::StringObject( objectType, objectCount );
}
else {
event.title = MP2::StringObject( objectType );
Expand Down
24 changes: 4 additions & 20 deletions src/fheroes2/maps/mp2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ bool MP2::isHiddenForPuzzle( uint8_t tileset, uint8_t index )
return ( icnID < 22 || icnID == 46 || ( icnID == 56 && index == 140 ) );
}

const char * MP2::StringObject( const MapObjectType objectType )
const char * MP2::StringObject( const MapObjectType objectType, const int count )
{
switch ( objectType ) {
case OBJ_ZERO:
Expand All @@ -216,7 +216,7 @@ const char * MP2::StringObject( const MapObjectType objectType )
return _( "Lighthouse" );
case OBJN_WATERWHEEL:
case OBJ_WATERWHEEL:
return _( "Water Wheel" );
return _n( "Water Wheel", "Water Wheels", count );
case OBJN_MINES:
case OBJ_MINES:
return _( "Mines" );
Expand All @@ -243,7 +243,7 @@ const char * MP2::StringObject( const MapObjectType objectType )
return _( "Wagon Camp" );
case OBJN_WINDMILL:
case OBJ_WINDMILL:
return _( "Windmill" );
return _n( "Windmill", "Windmills", count );
case OBJN_RNDTOWN:
case OBJ_RNDTOWN:
return _( "Random Town" );
Expand Down Expand Up @@ -461,7 +461,7 @@ const char * MP2::StringObject( const MapObjectType objectType )
case OBJ_BOTTLE:
return _( "Bottle" );
case OBJ_MAGICGARDEN:
return _( "Magic Garden" );
return _n( "Magic Garden", "Magic Gardens", count );
case OBJ_RNDARTIFACT1:
return _( "Random Artifact - Treasure" );
case OBJ_RNDARTIFACT2:
Expand Down Expand Up @@ -644,22 +644,6 @@ const char * MP2::StringObject( const MapObjectType objectType )
return nullptr;
}

const char * MP2::getPluralObjectName( const MapObjectType objectType, const size_t count )
{
switch ( objectType ) {
case OBJ_WATERWHEEL:
return _n( "Water Wheel", "Water Wheels", count );
case OBJ_WINDMILL:
return _n( "Windmill", "Windmills", count );
case OBJ_MAGICGARDEN:
return _n( "Magic Garden", "Magic Gardens", count );
default:
break;
}

return StringObject( objectType );
}

bool MP2::isDayLife( const MapObjectType objectType )
{
// TODO: list day object life
Expand Down
5 changes: 1 addition & 4 deletions src/fheroes2/maps/mp2.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,7 @@ namespace MP2
// Return Icn ID related to this tileset value.
int GetICNObject( const uint8_t tileset );

const char * StringObject( const MapObjectType objectType );

// This function returns plural forms only for certain object types.
const char * getPluralObjectName( const MapObjectType objectType, const size_t count );
const char * StringObject( const MapObjectType objectType, const int count = 1 );

bool isHiddenForPuzzle( uint8_t tileset, uint8_t index );

Expand Down
34 changes: 2 additions & 32 deletions src/fheroes2/resource/artifact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,35 +189,6 @@ namespace

{ 0, 0, TYPE0, "Unknown", "Unknown" },
} };

const char * GetPluralDescription( const Artifact & art, u32 count )
{
switch ( art.GetID() ) {
case Artifact::ENCHANTED_HOURGLASS:
return _n( "The %{name} extends the duration of all your spells by %{count} turn.", "The %{name} extends the duration of all your spells by %{count} turns.",
count );
case Artifact::WIZARD_HAT:
return _n( "The %{name} increases the duration of your spells by %{count} turn.", "The %{name} increases the duration of your spells by %{count} turns.",
count );
case Artifact::POWER_RING:
return _n( "The %{name} returns %{count} extra power point/turn to your hero.", "The %{name} returns %{count} extra power points/turn to your hero.", count );
case Artifact::ENDLESS_POUCH_SULFUR:
return _n( "The %{name} provides %{count} unit of sulfur per day.", "The %{name} provides %{count} units of sulfur per day.", count );
case Artifact::ENDLESS_VIAL_MERCURY:
return _n( "The %{name} provides %{count} unit of mercury per day.", "The %{name} provides %{count} units of mercury per day.", count );
case Artifact::ENDLESS_POUCH_GEMS:
return _n( "The %{name} provides %{count} unit of gems per day.", "The %{name} provides %{count} units of gems per day.", count );
case Artifact::ENDLESS_CORD_WOOD:
return _n( "The %{name} provides %{count} unit of wood per day.", "The %{name} provides %{count} units of wood per day.", count );
case Artifact::ENDLESS_CART_ORE:
return _n( "The %{name} provides %{count} unit of ore per day.", "The %{name} provides %{count} units of ore per day.", count );
case Artifact::ENDLESS_POUCH_CRYSTAL:
return _n( "The %{name} provides %{count} unit of crystal per day.", "The %{name} provides %{count} units of crystal per day.", count );
default:
break;
}
return _( artifacts[art.GetID()].description );
}
}

Artifact::Artifact( int art )
Expand Down Expand Up @@ -271,15 +242,14 @@ int Artifact::Type( void ) const

std::string Artifact::GetDescription( void ) const
{
u32 count = ExtraValue();
std::string str = GetPluralDescription( *this, count );
std::string str = _( artifacts[id].description );

StringReplace( str, "%{name}", GetName() );

if ( id == Artifact::SPELL_SCROLL )
StringReplace( str, "%{spell}", Spell( ext ).GetName() );
else
StringReplace( str, "%{count}", count );
StringReplace( str, "%{count}", ExtraValue() );

return str;
}
Expand Down

0 comments on commit 984cc8c

Please sign in to comment.