Skip to content

Commit

Permalink
update Afrikaans translation
Browse files Browse the repository at this point in the history
and make updating translations easier

credits are now randomly aligned each time they’re shown

Co-authored-by: Hendrik Bezuidenhout @hendrikbez
  • Loading branch information
dougmencken committed May 9, 2024
1 parent 48b8db8 commit 0333d0b
Show file tree
Hide file tree
Showing 21 changed files with 386 additions and 349 deletions.
412 changes: 176 additions & 236 deletions gamedata/text/af_ZA.xml

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions gamedata/text/en_US.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<string font="big" color="cyan">The Reincarnation Fish</string>
<string font="big" color="orange">gives a chance</string>
<string font="big" color="cycling">to save the game</string>
<string font="big" color="orange">by touching SPACE</string>
<string font="big" color="orange">by touching Space</string>
</text>
<text alias="score">
<string>Score</string>
Expand Down Expand Up @@ -173,10 +173,10 @@
<text alias="final-text">
<string font="big" color="multicolor">The people praise you !</string>
<string></string>
<string font="plain" color="white">This way, my dear friend,</string>
<string font="plain" color="cyan">our two heroes put an end to the</string>
<string font="plain" color="orange">Blacktooth Emperor’s tyranny,</string>
<string font="plain" color="yellow">once and for all.</string>
<string color="white">This way, my dear friend,</string>
<string color="cyan">our two heroes put an end to the</string>
<string color="orange">Blacktooth Emperor’s tyranny,</string>
<string color="yellow">once and for all.</string>
</text>

</language>
10 changes: 5 additions & 5 deletions gamedata/text/fr_FR.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
<string font="big" color="cyan">Le poisson de réincarnation</string>
<string font="big" color="orange">donne une chance</string>
<string font="big" color="cycling">de sauvegarder le jeu</string>
<string font="big" color="orange">en touchant ESPACE</string>
<string font="big" color="orange">en touchant Espace</string>
</text>
<text alias="score">
<string>Score</string>
Expand Down Expand Up @@ -173,10 +173,10 @@
<text alias="final-text">
<string font="big" color="multicolor">Le peuple te exalte !</string>
<string></string>
<string font="plain" color="white">Ainsi, mon cher ami,</string>
<string font="plain" color="cyan">nos deux héros mettent fin à la</string>
<string font="plain" color="orange">tyrannie de l’Empereur de Blacktooth,</string>
<string font="plain" color="yellow">une fois pour toutes.</string>
<string color="white">Ainsi, mon cher ami,</string>
<string color="cyan">nos deux héros mettent fin à la</string>
<string color="orange">tyrannie de l’Empereur de Blacktooth,</string>
<string color="yellow">une fois pour toutes.</string>
</text>

</language>
16 changes: 8 additions & 8 deletions source/GameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void GameManager::pause ()
else if ( keyMoments.wasFishEaten( true ) )
{
gui::LanguageStrings* languageStrings = gui::GuiManager::getInstance().getLanguageStrings() ;
gui::LanguageText* text = languageStrings->getTranslatedStringByAlias( "save-game" );
gui::LanguageText* text = languageStrings->getTranslatedTextByAlias( "save-game" );
int textAtY = ( GamePreferences::getScreenHeight() >> 2 ) - 60 ;

gui::TextField ateFishText( GamePreferences::getScreenWidth(), "center" );
Expand All @@ -212,10 +212,10 @@ void GameManager::pause ()
for ( unsigned int i = 0; i < text->howManyLinesOfText (); i ++ )
{
const gui::LanguageLine & line = text->getNthLine( i );
ateFishText.appendText( line.getText(), line.isBigHeight(), line.getColor() );
ateFishText.appendText( line.getString(), line.isBigHeight(), line.getColor() );
}

text = languageStrings->getTranslatedStringByAlias( "confirm-resume" );
text = languageStrings->getTranslatedTextByAlias( "confirm-resume" );
textAtY += ateFishText.getHeightOfField () + 20 ;

gui::TextField resumeText( GamePreferences::getScreenWidth(), "center" );
Expand All @@ -224,7 +224,7 @@ void GameManager::pause ()
for ( unsigned int i = 0; i < text->howManyLinesOfText (); i ++ )
{
const gui::LanguageLine & line = text->getNthLine( i );
resumeText.appendText( line.getText(), line.isBigHeight(), line.getColor() );
resumeText.appendText( line.getString(), line.isBigHeight(), line.getColor() );
}

allegro::emptyKeyboardBuffer();
Expand Down Expand Up @@ -291,7 +291,7 @@ void GameManager::pause ()
SoundManager::getInstance().stopEverySound ();

gui::LanguageStrings* languageStrings = gui::GuiManager::getInstance().getLanguageStrings();
gui::LanguageText* text = languageStrings->getTranslatedStringByAlias( "confirm-quit" );
gui::LanguageText* text = languageStrings->getTranslatedTextByAlias( "confirm-quit" );
int textAtY = ( GamePreferences::getScreenHeight() >> 2 );

gui::TextField quitText( GamePreferences::getScreenWidth(), "center" );
Expand All @@ -300,10 +300,10 @@ void GameManager::pause ()
for ( unsigned int i = 0; i < text->howManyLinesOfText (); i ++ )
{
const gui::LanguageLine & line = text->getNthLine( i );
quitText.appendText( line.getText(), line.isBigHeight(), line.getColor() );
quitText.appendText( line.getString(), line.isBigHeight(), line.getColor() );
}

text = languageStrings->getTranslatedStringByAlias( "confirm-resume" );
text = languageStrings->getTranslatedTextByAlias( "confirm-resume" );
textAtY += quitText.getHeightOfField () + 20 ;

gui::TextField resumeText( GamePreferences::getScreenWidth(), "center" );
Expand All @@ -312,7 +312,7 @@ void GameManager::pause ()
for ( unsigned int i = 0; i < text->howManyLinesOfText (); i ++ )
{
const gui::LanguageLine & line = text->getNthLine( i );
resumeText.appendText( line.getText(), line.isBigHeight(), line.getColor() );
resumeText.appendText( line.getString(), line.isBigHeight(), line.getColor() );
}

bool quit = false ;
Expand Down
56 changes: 47 additions & 9 deletions source/gui/LanguageStrings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,58 @@
#include "util.hpp"
#include "ospaths.hpp"

#define DUMP_XML 1
#define DUMP_XML 0
#define DUMP_UPDATE_XML 1


namespace gui
{

LanguageStrings::LanguageStrings( const std::string & file, const std::string & fileWithGuaranteedStrings )
{
parseFile( ospaths::pathToFile( ospaths::sharePath() + "text", file ), this->strings );
parseFile( file, this->strings );

if ( file != fileWithGuaranteedStrings ) {
parseFile( ospaths::pathToFile( ospaths::sharePath() + "text", fileWithGuaranteedStrings ), this->backupStrings );
parseFile( fileWithGuaranteedStrings, this->backupStrings );
for ( unsigned int i = 0 ; i < backupStrings.size () ; i ++ )
backupStrings[ i ]->prefixWith( "_*" + fileWithGuaranteedStrings.substr( 0, 2 ) + "*_ " );
}

#if defined( DUMP_UPDATE_XML ) && DUMP_UPDATE_XML
std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl << std::endl ;

const char * linguonym = nilPointer ;
const char * iso = nilPointer ;

tinyxml2::XMLDocument translatedStringsXml ;
tinyxml2::XMLError result = translatedStringsXml.LoadFile( ospaths::pathToFile( ospaths::sharePath() + "text", file ).c_str () );
if ( result == tinyxml2::XML_SUCCESS ) {
tinyxml2::XMLElement * root = translatedStringsXml.FirstChildElement( "language" );
linguonym = root->Attribute( "name" );
iso = root->Attribute( "iso" );
}

std::cout << "<language" ;
if ( linguonym != nilPointer ) std::cout << " name=\"" << linguonym << "\"" ;
if ( iso != nilPointer ) std::cout << " iso=\"" << iso << "\"" ;
std::cout << ">" << std::endl << std::endl ;

for ( unsigned int i = 0 ; i < this->backupStrings.size () ; ++ i )
{
LanguageText * text = this->backupStrings[ i ];
const std::string & alias = text->getAlias() ;

for ( unsigned int j = 0 ; j < this->strings.size () ; ++ j )
if ( this->strings[ j ]->getAlias() == alias ) {
text = this->strings[ j ];
break ;
}

std::cout << text->toXml() << std::endl ;
}

std::cout << std::endl << "</language>" << std::endl ;
#endif
}

LanguageStrings::~LanguageStrings()
Expand All @@ -35,7 +72,7 @@ LanguageStrings::~LanguageStrings()
backupStrings.clear();
}

LanguageText* LanguageStrings::getTranslatedStringByAlias( const std::string & alias )
LanguageText* LanguageStrings::getTranslatedTextByAlias( const std::string & alias )
{
for ( size_t i = 0 ; i < strings.size () ; i ++ )
if ( strings[ i ]->getAlias() == alias ) return strings[ i ];
Expand All @@ -50,16 +87,17 @@ LanguageText* LanguageStrings::getTranslatedStringByAlias( const std::string & a

void LanguageStrings::parseFile( const std::string & fileName, std::vector< LanguageText * > & strings )
{
std::cout << "parsing \"" << fileName << "\"" << std::endl ;
std::string filePath = ospaths::pathToFile( ospaths::sharePath() + "text", fileName );
std::cout << "parsing \"" << fileName << "\" (" << filePath << ")" << std::endl ;

tinyxml2::XMLDocument languageXml ;
tinyxml2::XMLError result = languageXml.LoadFile( fileName.c_str () );
tinyxml2::XMLDocument translatedStringsXml ;
tinyxml2::XMLError result = translatedStringsXml.LoadFile( filePath.c_str () );
if ( result != tinyxml2::XML_SUCCESS ) {
std::cerr << "can’t parse language strings file \"" << fileName << "\"" << std::endl ;
std::cerr << "can’t parse language strings file \"" << fileName << "\" (" << filePath << ")" << std::endl ;
return ;
}

tinyxml2::XMLElement* root = languageXml.FirstChildElement( "language" );
tinyxml2::XMLElement* root = translatedStringsXml.FirstChildElement( "language" );

#if defined( DUMP_XML ) && DUMP_XML
std::cout << "<language" ;
Expand Down
2 changes: 1 addition & 1 deletion source/gui/LanguageStrings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LanguageStrings

~LanguageStrings( );

LanguageText * getTranslatedStringByAlias ( const std::string & alias ) ;
LanguageText * getTranslatedTextByAlias ( const std::string & alias ) ;

private:

Expand Down
37 changes: 25 additions & 12 deletions source/gui/LanguageText.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@ class LanguageLine

private:

std::string text ;
std::string line ;

std::string fontName ;

std::string color ;

public:

const std::string & getText() const { return this->text ; }
const std::string & getString () const { return this->line ; }

void setText( const std::string & newText ) { this->text = newText ; }
void setString( const std::string & newString ) { this->line = newString ; }

bool isBigHeight() const { return ( this->fontName == "big" ); }
bool isBigHeight () const { return this->fontName == "big" ; }

const std::string & getColor() const { return this->color ; }
const std::string & getColor () const { return this->color ; }

LanguageLine( const std::string & theText )
: text( theText )
LanguageLine( const std::string & theLine )
: line( theLine )
, fontName( "" )
, color( "" )
{}

LanguageLine( const std::string & theText, const std::string & whichFont, const std::string & whichColor )
: text( theText )
LanguageLine( const std::string & theLine, const std::string & whichFont, const std::string & whichColor )
: line( theLine )
, fontName( whichFont )
, color( whichColor )
{
Expand All @@ -64,7 +64,7 @@ class LanguageLine
if ( ! this->color.empty() ) out << " color=\"" << this->color << "\"" ;
out << ">" ;

if ( ! this->text.empty() ) out << this->text ;
if ( ! this->line.empty() ) out << this->line ;

out << "</" << tag << ">" ;

Expand Down Expand Up @@ -105,14 +105,27 @@ class LanguageText

const LanguageLine & getNthLine ( size_t number ) const { return this->lines[ number ] ; }

const std::string & getText () const { return this->getFirstLine().getText() ; }
std::string getText () const
{
unsigned int howManyLines = howManyLinesOfText() ;

if ( howManyLines == 0 ) return "" ;
if ( howManyLines == 1 ) return getFirstLine().getString () ;

std::ostringstream text ;
for ( unsigned int n = 0 ; n < howManyLines ; ++ n ) {
text << getNthLine( n ).getString() ;
if ( ( n + 1 ) < howManyLines ) text << std::endl ;
}
return text.str ();
}

unsigned int howManyLinesOfText () const { return this->lines.size() ; }

void prefixWith( const std::string & prefix )
{
for ( unsigned int i = 0 ; i < this->lines.size() ; ++ i )
this->lines[ i ].setText( prefix + this->lines[ i ].getText() );
this->lines[ i ].setString( prefix + this->lines[ i ].getString () );
}

std::string toXml( const std::string & tag = "text" ) const
Expand Down
10 changes: 5 additions & 5 deletions source/guiactions/CreateAudioMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ void CreateAudioMenu::act ()
{
LanguageStrings* languageStrings = GuiManager::getInstance().getLanguageStrings() ;

LanguageText* langStringEffects = languageStrings->getTranslatedStringByAlias( "soundfx" );
LanguageText* langStringMusic = languageStrings->getTranslatedStringByAlias( "music" );
LanguageText* langStringEffects = languageStrings->getTranslatedTextByAlias( "soundfx" );
LanguageText* langStringMusic = languageStrings->getTranslatedTextByAlias( "music" );

LanguageText* langStringRoomTunes = languageStrings->getTranslatedStringByAlias( "play-room-melodies" );
LanguageText* langStringRoomTunes = languageStrings->getTranslatedTextByAlias( "play-room-melodies" );

std::string yeah = languageStrings->getTranslatedStringByAlias( "yep" )-> getText ();
std::string nope = languageStrings->getTranslatedStringByAlias( "nope" )->getText ();
std::string yeah = languageStrings->getTranslatedTextByAlias( "yep" )-> getText ();
std::string nope = languageStrings->getTranslatedTextByAlias( "nope" )->getText ();

std::stringstream ss;

Expand Down
9 changes: 3 additions & 6 deletions source/guiactions/CreateCongratulationsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,22 @@ void CreateCongratulationsScreen::act ()
const std::string & pathToPictures = ospaths::sharePath() + GameManager::getInstance().getChosenGraphicsSet() ;
autouniqueptr< Picture > imageDuChapeau( Picture::loadPicture( ospaths::pathToFile( pathToPictures, "crown.png" ) ) );

// Head coronado
screen.addWidget( new PictureWidget( 192, 50, PicturePtr( new Picture( *imageDuChapeau ) ), "image du chapeau de Head" ) );
screen.addPictureOfHeadAt( 192, 100 );

// Heels coronado
screen.addWidget( new PictureWidget( 400, 50, PicturePtr( new Picture( *imageDuChapeau ) ), "image du chapeau de Heels" ) );
screen.addPictureOfHeelsAt( 400, 100 );
}

// texto final
LanguageStrings* languageStrings = GuiManager::getInstance().getLanguageStrings() ;
LanguageText* finalText = languageStrings->getTranslatedStringByAlias( "final-text" );
LanguageText* finalText = languageStrings->getTranslatedTextByAlias( "final-text" );
TextField* textField = new TextField( GamePreferences::getScreenWidth(), "center" );
textField->moveTo( 0, 180 );

for ( size_t i = 0; i < finalText->howManyLinesOfText(); i ++ )
{
for ( size_t i = 0; i < finalText->howManyLinesOfText(); i ++ ) {
const LanguageLine & line = finalText->getNthLine( i );
textField->appendText( line.getText(), line.isBigHeight(), line.getColor() );
textField->appendText( line.getString(), line.isBigHeight(), line.getColor() );
}

screen.addWidget( textField );
Expand Down
8 changes: 4 additions & 4 deletions source/guiactions/CreateEndScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ void CreateEndScreen::act ()

// the score reached by the player
unsigned int score = this->visitedRooms * 160 + this->liberatedPlanets * 10000 ;
Label* scoreLabel = new Label ( languageStrings->getTranslatedStringByAlias( "score" )->getText() + " " + util::number2string( score ),
Label* scoreLabel = new Label ( languageStrings->getTranslatedTextByAlias( "score" )->getText() + " " + util::number2string( score ),
Font::fontWithColor( "yellow" ) );
scoreLabel->moveTo( ( screenWidth - scoreLabel->getWidth() ) >> 1, labelsY );
screen.addWidget( scoreLabel );

// the number of the rooms visited
std::string exploredRooms = languageStrings->getTranslatedStringByAlias( "explored-rooms" )->getText();
std::string exploredRooms = languageStrings->getTranslatedTextByAlias( "explored-rooms" )->getText();
exploredRooms.replace( exploredRooms.find( "%d" ), 2, util::number2string( this->visitedRooms ) );
Label* rooms = new Label( exploredRooms, Font::fontWithColor( "cyan" ) );
rooms->moveTo( ( screenWidth - rooms->getWidth() ) >> 1, labelsY + leading );
screen.addWidget( rooms );

// the number of the planets liberated
std::string liberatedPlanets = languageStrings->getTranslatedStringByAlias( "liberated-planets" )->getText();
std::string liberatedPlanets = languageStrings->getTranslatedTextByAlias( "liberated-planets" )->getText();
liberatedPlanets.replace( liberatedPlanets.find( "%d" ), 2, util::number2string( this->liberatedPlanets ) );
Label* planets = new Label( liberatedPlanets, Font::fontWithColor( "white" ) );
planets->moveTo( ( screenWidth - planets->getWidth() ) >> 1, labelsY + leading + leading );
Expand All @@ -84,7 +84,7 @@ void CreateEndScreen::act ()
if ( score > bounds[ i ] )
{
TextField* result = new TextField( screenWidth, "center" );
result->appendText( languageStrings->getTranslatedStringByAlias( ranges[ i ] )->getText(), "big", "multicolor" );
result->appendText( languageStrings->getTranslatedTextByAlias( ranges[ i ] )->getText(), "big", "multicolor" );
result->moveTo( 0, resultY );
screen.addWidget( result );

Expand Down
2 changes: 1 addition & 1 deletion source/guiactions/CreateKeysMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void CreateKeysMenu::act ()
const std::string & theAction = userActions[ i ];
std::string xmlAction = ( theAction == "take&jump" ) ? "takeandjump" : theAction ;

Label* label = new Label( languageStrings->getTranslatedStringByAlias( xmlAction )->getText() );
Label* label = new Label( languageStrings->getTranslatedTextByAlias( xmlAction )->getText() );

std::string theKey = InputManager::getInstance().getUserKeyFor( theAction );
if ( theKey == "none" ) label->changeColor( "cyan" );
Expand Down
Loading

0 comments on commit 0333d0b

Please sign in to comment.