From bab71f8f0b31552c94a6127398826fa4446060ad Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Thu, 3 Jun 2004 17:41:22 +0000 Subject: [PATCH] Added more strings to be translated. In some places for doing the aligment spaces were used. I fixed a couple of places, but there are more there. This is a good time to remove this hacks. We have to define some policy about what should be translatable. IMO, error messages should not be translated. Only if they are telling the user what should he do. Warnings maybe should be translated. SVN-Revision: 1404 --- src/gameloop.cpp | 31 +++++++++++++------------ src/menu.cpp | 29 +++++++++++------------ src/setup.cpp | 70 ++++++++++++++++++++++++++++---------------------------- src/title.cpp | 13 ++++++----- src/worldmap.cpp | 15 ++++++------ 5 files changed, 81 insertions(+), 77 deletions(-) diff --git a/src/gameloop.cpp b/src/gameloop.cpp index 3667ae4b3..5a5aab025 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -55,6 +55,7 @@ #include "resources.h" #include "background.h" #include "tilemap.h" +#include "gettext.h" GameSession* GameSession::current_ = 0; @@ -159,7 +160,7 @@ GameSession::levelintro(void) LAYER_FOREGROUND1); context.draw_text_center(white_small_text, - std::string("by ") + level->get_author(), + std::string(_("by ")) + level->get_author(), Vector(0, 400), LAYER_FOREGROUND1); context.do_drawing(); @@ -519,7 +520,7 @@ GameSession::draw() context->draw_filled_rect( Vector(0,0), Vector(screen->w, screen->h), Color(rand() % 50, rand() % 50, rand() % 50, 128), LAYER_FOREGROUND1); - context->draw_text_center(blue_text, "PAUSE - Press 'P' To Play", + context->draw_text_center(blue_text, _("PAUSE - Press 'P' To Play"), Vector(0, 230), LAYER_FOREGROUND1+2); } @@ -698,35 +699,35 @@ GameSession::drawstatus(DrawingContext& context) char str[60]; snprintf(str, 60, "%d", player_status.score); - context.draw_text(white_text, "SCORE", Vector(0, 0), LAYER_FOREGROUND1); + context.draw_text(white_text, _("SCORE"), Vector(0, 0), LAYER_FOREGROUND1); context.draw_text(gold_text, str, Vector(96, 0), LAYER_FOREGROUND1); if(st_gl_mode == ST_GL_TEST) { - context.draw_text(white_text, "Press ESC To Return", Vector(0,20), + context.draw_text(white_text, _("Press ESC To Return"), Vector(0,20), LAYER_FOREGROUND1); } if(!time_left.check()) { - context.draw_text_center(white_text, "TIME's UP", Vector(0, 0), + context.draw_text_center(white_text, _("TIME's UP"), Vector(0, 0), LAYER_FOREGROUND1); } else if (time_left.get_left() > TIME_WARNING || (global_frame_counter % 10) < 5) { sprintf(str, "%d", time_left.get_left() / 1000 ); - context.draw_text_center(white_text, "TIME", + context.draw_text_center(white_text, _("TIME"), Vector(0, 0), LAYER_FOREGROUND1); context.draw_text_center(gold_text, str, Vector(4*16, 0), LAYER_FOREGROUND1); } sprintf(str, "%d", player_status.distros); - context.draw_text(white_text, "COINS", - Vector(screen->w - white_text->get_text_width("COINS "), 0), + context.draw_text(white_text, _("COINS"), + Vector(screen->w - white_text->get_text_width(_("COINS"))+white_text->get_text_width(str), 0), LAYER_FOREGROUND1); context.draw_text(gold_text, str, Vector(screen->w - gold_text->get_text_width("99"), 0),LAYER_FOREGROUND1); - context.draw_text(white_text, "LIVES", - Vector(screen->w - white_text->get_text_width("LIVES "), 20), + context.draw_text(white_text, _("LIVES"), + Vector(screen->w - white_text->get_text_width(_("LIVES"))+white_text->get_text_width(str), 20), LAYER_FOREGROUND1); if (player_status.lives >= 5) { @@ -763,13 +764,13 @@ GameSession::drawresultscreen(void) DrawingContext context; currentsector->background->draw(context); - context.draw_text_center(blue_text, "Result:", Vector(0, 200), + context.draw_text_center(blue_text, _("Result:"), Vector(0, 200), LAYER_FOREGROUND1); - sprintf(str, "SCORE: %d", player_status.score); + sprintf(str, _("SCORE: %d"), player_status.score); context.draw_text_center(gold_text, str, Vector(0, 224), LAYER_FOREGROUND1); - sprintf(str, "COINS: %d", player_status.distros); + sprintf(str, _("COINS: %d"), player_status.distros); context.draw_text_center(gold_text, str, Vector(0, 256), LAYER_FOREGROUND1); context.do_drawing(); @@ -798,10 +799,10 @@ std::string slotinfo(int slot) if (!title.empty()) snprintf(tmp,1024,"Slot %d - %s",slot, title.c_str()); else - snprintf(tmp, 1024,"Slot %d - Savegame",slot); + snprintf(tmp, 1024,_("Slot %d - Savegame"),slot); } else - sprintf(tmp,"Slot %d - Free",slot); + sprintf(tmp,_("Slot %d - Free"),slot); return tmp; } diff --git a/src/menu.cpp b/src/menu.cpp index 352b66d82..9932ed669 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -40,6 +40,7 @@ #include "leveleditor.h" #include "timer.h" #include "high_scores.h" +#include "gettext.h" #define FLICK_CURSOR_TIME 500 @@ -72,8 +73,8 @@ bool confirm_dialog(Surface *background, std::string text) Menu* dialog = new Menu; dialog->additem(MN_DEACTIVE, text,0,0); dialog->additem(MN_HL,"",0,0); - dialog->additem(MN_ACTION,"Yes",0,0,true); - dialog->additem(MN_ACTION,"No",0,0,false); + dialog->additem(MN_ACTION,_("Yes"),0,0,true); + dialog->additem(MN_ACTION,_("No"),0,0,false); dialog->additem(MN_HL,"",0,0); Menu::set_current(dialog); @@ -252,40 +253,40 @@ void Menu::get_controlfield_key_into_input(MenuItem *item) switch(*item->int_p) { case SDLK_UP: - item->change_input("Up cursor"); + item->change_input(_("Up cursor")); break; case SDLK_DOWN: - item->change_input("Down cursor"); + item->change_input(_("Down cursor")); break; case SDLK_LEFT: - item->change_input("Left cursor"); + item->change_input(_("Left cursor")); break; case SDLK_RIGHT: - item->change_input("Right cursor"); + item->change_input(_("Right cursor")); break; case SDLK_RETURN: - item->change_input("Return"); + item->change_input(_("Return")); break; case SDLK_SPACE: - item->change_input("Space"); + item->change_input(_("Space")); break; case SDLK_RSHIFT: - item->change_input("Right Shift"); + item->change_input(_("Right Shift")); break; case SDLK_LSHIFT: - item->change_input("Left Shift"); + item->change_input(_("Left Shift")); break; case SDLK_RCTRL: - item->change_input("Right Control"); + item->change_input(_("Right Control")); break; case SDLK_LCTRL: - item->change_input("Left Control"); + item->change_input(_("Left Control")); break; case SDLK_RALT: - item->change_input("Right Alt"); + item->change_input(_("Right Alt")); break; case SDLK_LALT: - item->change_input("Left Alt"); + item->change_input(_("Left Alt")); break; default: { diff --git a/src/setup.cpp b/src/setup.cpp index c3b9461ef..3a2774f0c 100644 --- a/src/setup.cpp +++ b/src/setup.cpp @@ -392,60 +392,60 @@ void st_menu(void) main_menu->additem(MN_ACTION, _("Credits"),0,0, MNID_CREDITS); main_menu->additem(MN_ACTION, _("Quit"),0,0, MNID_QUITMAINMENU); - options_menu->additem(MN_LABEL,"Options",0,0); + options_menu->additem(MN_LABEL,_("Options"),0,0); options_menu->additem(MN_HL,"",0,0); #ifndef NOOPENGL options_menu->additem(MN_TOGGLE,"OpenGL",use_gl,0, MNID_OPENGL); #else - options_menu->additem(MN_DEACTIVE,"OpenGL (not supported)",use_gl, 0, MNID_OPENGL); + options_menu->additem(MN_DEACTIVE,_("OpenGL (not supported)"),use_gl, 0, MNID_OPENGL); #endif - options_menu->additem(MN_TOGGLE,"Fullscreen",use_fullscreen,0, MNID_FULLSCREEN); + options_menu->additem(MN_TOGGLE,_("Fullscreen"),use_fullscreen,0, MNID_FULLSCREEN); if(audio_device) { - options_menu->additem(MN_TOGGLE,"Sound ", use_sound,0, MNID_SOUND); - options_menu->additem(MN_TOGGLE,"Music ", use_music,0, MNID_MUSIC); + options_menu->additem(MN_TOGGLE,_("Sound "), use_sound,0, MNID_SOUND); + options_menu->additem(MN_TOGGLE,_("Music "), use_music,0, MNID_MUSIC); } else { - options_menu->additem(MN_DEACTIVE,"Sound ", false,0, MNID_SOUND); - options_menu->additem(MN_DEACTIVE,"Music ", false,0, MNID_MUSIC); + options_menu->additem(MN_DEACTIVE,_("Sound "), false,0, MNID_SOUND); + options_menu->additem(MN_DEACTIVE,_("Music "), false,0, MNID_MUSIC); } - options_menu->additem(MN_TOGGLE,"Show FPS ",show_fps,0, MNID_SHOWFPS); - options_menu->additem(MN_GOTO,"Keyboard Setup",0,options_keys_menu); + options_menu->additem(MN_TOGGLE,_("Show FPS "),show_fps,0, MNID_SHOWFPS); + options_menu->additem(MN_GOTO,_("Keyboard Setup"),0,options_keys_menu); if(use_joystick) - options_menu->additem(MN_GOTO,"Joystick Setup",0,options_joystick_menu); + options_menu->additem(MN_GOTO,_("Joystick Setup"),0,options_joystick_menu); options_menu->additem(MN_HL,"",0,0); - options_menu->additem(MN_BACK,"Back",0,0); + options_menu->additem(MN_BACK,_("Back"),0,0); - options_keys_menu->additem(MN_LABEL,"Key Setup",0,0); + options_keys_menu->additem(MN_LABEL,_("Key Setup"),0,0); options_keys_menu->additem(MN_HL,"",0,0); - options_keys_menu->additem(MN_CONTROLFIELD_KB,"Left move", 0,0, 0,&keymap.left); - options_keys_menu->additem(MN_CONTROLFIELD_KB,"Right move", 0,0, 0,&keymap.right); - options_keys_menu->additem(MN_CONTROLFIELD_KB,"Jump", 0,0, 0,&keymap.jump); - options_keys_menu->additem(MN_CONTROLFIELD_KB,"Duck", 0,0, 0,&keymap.duck); - options_keys_menu->additem(MN_CONTROLFIELD_KB,"Activate", 0, 0, 0, + options_keys_menu->additem(MN_CONTROLFIELD_KB,_("Left move"), 0,0, 0,&keymap.left); + options_keys_menu->additem(MN_CONTROLFIELD_KB,_("Right move"), 0,0, 0,&keymap.right); + options_keys_menu->additem(MN_CONTROLFIELD_KB,_("Jump"), 0,0, 0,&keymap.jump); + options_keys_menu->additem(MN_CONTROLFIELD_KB,_("Duck"), 0,0, 0,&keymap.duck); + options_keys_menu->additem(MN_CONTROLFIELD_KB,_("Activate"), 0, 0, 0, &keymap.activate); - options_keys_menu->additem(MN_CONTROLFIELD_KB,"Power/Run", 0,0, 0,&keymap.fire); + options_keys_menu->additem(MN_CONTROLFIELD_KB,_("Power/Run"), 0,0, 0,&keymap.fire); options_keys_menu->additem(MN_HL,"",0,0); - options_keys_menu->additem(MN_BACK,"Back",0,0); + options_keys_menu->additem(MN_BACK,_("Back"),0,0); if(use_joystick) { - options_joystick_menu->additem(MN_LABEL,"Joystick Setup",0,0); + options_joystick_menu->additem(MN_LABEL,_("Joystick Setup"),0,0); options_joystick_menu->additem(MN_HL,"",0,0); //options_joystick_menu->additem(MN_CONTROLFIELD_JS,"X axis", 0,0, 0,&joystick_keymap.x_axis); //options_joystick_menu->additem(MN_CONTROLFIELD_JS,"Y axis", 0,0, 0,&joystick_keymap.y_axis); - options_joystick_menu->additem(MN_CONTROLFIELD_JS,"A button", 0,0, 0,&joystick_keymap.a_button); - options_joystick_menu->additem(MN_CONTROLFIELD_JS,"B button", 0,0, 0,&joystick_keymap.b_button); + options_joystick_menu->additem(MN_CONTROLFIELD_JS,_("A button"), 0,0, 0,&joystick_keymap.a_button); + options_joystick_menu->additem(MN_CONTROLFIELD_JS,_("B button"), 0,0, 0,&joystick_keymap.b_button); //options_joystick_menu->additem(MN_CONTROLFIELD_JS,"Start", 0,0, 0,&joystick_keymap.start_button); //options_joystick_menu->additem(MN_CONTROLFIELD_JS,"DeadZone", 0,0, 0,&joystick_keymap.dead_zone); options_joystick_menu->additem(MN_HL,"",0,0); - options_joystick_menu->additem(MN_BACK,"Back",0,0); + options_joystick_menu->additem(MN_BACK,_("Back"),0,0); } - load_game_menu->additem(MN_LABEL,"Start Game",0,0); + load_game_menu->additem(MN_LABEL,_("Start Game"),0,0); load_game_menu->additem(MN_HL,"",0,0); load_game_menu->additem(MN_DEACTIVE,"Slot 1",0,0, 1); load_game_menu->additem(MN_DEACTIVE,"Slot 2",0,0, 2); @@ -453,9 +453,9 @@ void st_menu(void) load_game_menu->additem(MN_DEACTIVE,"Slot 4",0,0, 4); load_game_menu->additem(MN_DEACTIVE,"Slot 5",0,0, 5); load_game_menu->additem(MN_HL,"",0,0); - load_game_menu->additem(MN_BACK,"Back",0,0); + load_game_menu->additem(MN_BACK,_("Back"),0,0); - save_game_menu->additem(MN_LABEL,"Save Game",0,0); + save_game_menu->additem(MN_LABEL,_("Save Game"),0,0); save_game_menu->additem(MN_HL,"",0,0); save_game_menu->additem(MN_DEACTIVE,"Slot 1",0,0, 1); save_game_menu->additem(MN_DEACTIVE,"Slot 2",0,0, 2); @@ -465,21 +465,21 @@ void st_menu(void) save_game_menu->additem(MN_HL,"",0,0); save_game_menu->additem(MN_BACK,"Back",0,0); - game_menu->additem(MN_LABEL,"Pause",0,0); + game_menu->additem(MN_LABEL,_("Pause"),0,0); game_menu->additem(MN_HL,"",0,0); - game_menu->additem(MN_ACTION,"Continue",0,0,MNID_CONTINUE); - game_menu->additem(MN_GOTO,"Options",0,options_menu); + game_menu->additem(MN_ACTION,_("Continue"),0,0,MNID_CONTINUE); + game_menu->additem(MN_GOTO,_("Options"),0,options_menu); game_menu->additem(MN_HL,"",0,0); - game_menu->additem(MN_ACTION,"Abort Level",0,0,MNID_ABORTLEVEL); + game_menu->additem(MN_ACTION,_("Abort Level"),0,0,MNID_ABORTLEVEL); - worldmap_menu->additem(MN_LABEL,"Pause",0,0); + worldmap_menu->additem(MN_LABEL,_("Pause"),0,0); worldmap_menu->additem(MN_HL,"",0,0); - worldmap_menu->additem(MN_ACTION,"Continue",0,0,MNID_RETURNWORLDMAP); - worldmap_menu->additem(MN_GOTO,"Options",0,options_menu); + worldmap_menu->additem(MN_ACTION,_("Continue"),0,0,MNID_RETURNWORLDMAP); + worldmap_menu->additem(MN_GOTO,_("Options"),0,options_menu); worldmap_menu->additem(MN_HL,"",0,0); - worldmap_menu->additem(MN_ACTION,"Quit Game",0,0,MNID_QUITWORLDMAP); + worldmap_menu->additem(MN_ACTION,_("Quit Game"),0,0,MNID_QUITWORLDMAP); - highscore_menu->additem(MN_TEXTFIELD,"Enter your name:",0,0); + highscore_menu->additem(MN_TEXTFIELD,_("Enter your name:"),0,0); } void update_load_save_game_menu(Menu* pmenu) diff --git a/src/title.cpp b/src/title.cpp index 75fe2c6ee..fef24cf6b 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -52,6 +52,7 @@ #include "sector.h" #include "tilemap.h" #include "resources.h" +#include "gettext.h" static Surface* bkg_title; static Surface* logo; @@ -87,7 +88,7 @@ void generate_contrib_menu() free_contrib_menu(); - contrib_menu->additem(MN_LABEL,"Contrib Levels",0,0); + contrib_menu->additem(MN_LABEL,_("Contrib Levels"),0,0); contrib_menu->additem(MN_HL,"",0,0); for (int i = 0; i < level_subsets.num_items; ++i) @@ -100,7 +101,7 @@ void generate_contrib_menu() } contrib_menu->additem(MN_HL,"",0,0); - contrib_menu->additem(MN_BACK,"Back",0,0); + contrib_menu->additem(MN_BACK,_("Back"),0,0); string_list_free(&level_subsets); } @@ -137,7 +138,7 @@ void check_contrib_menu() } contrib_subset_menu->additem(MN_HL,"",0,0); - contrib_subset_menu->additem(MN_BACK, "Back", 0, 0); + contrib_subset_menu->additem(MN_BACK, _("Back"), 0, 0); titlesession->get_current_sector()->activate(); titlesession->set_current(); @@ -272,11 +273,11 @@ void title(void) LAYER_FOREGROUND1+1); context.draw_text(white_small_text, - " SuperTux " VERSION "\n" + _(" SuperTux " VERSION "\n" "Copyright (c) 2003 SuperTux Devel Team\n" "This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n" "are welcome to redistribute it under certain conditions; see the file COPYING\n" - "for details.\n", Vector(0, screen->h - 70), LAYER_FOREGROUND1); + "for details.\n"), Vector(0, screen->h - 70), LAYER_FOREGROUND1); /* Don't draw menu, if quit is true */ Menu* menu = Menu::current(); @@ -323,7 +324,7 @@ void title(void) { int slot = menu->get_active_item_id(); char str[1024]; - sprintf(str,"Are you sure you want to delete slot %d?", slot); + sprintf(str,_("Are you sure you want to delete slot %d?"), slot); if(confirm_dialog(bkg_title, str)) { diff --git a/src/worldmap.cpp b/src/worldmap.cpp index 2988acf0d..32f674703 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -33,6 +33,7 @@ #include "worldmap.h" #include "sound_manager.h" #include "resources.h" +#include "gettext.h" namespace WorldMapNS { @@ -720,14 +721,14 @@ WorldMap::update(float delta) context.draw_gradient(Color (0, 255, 0), Color (255, 0, 255), LAYER_BACKGROUND0); - context.draw_text_center(blue_text, "GAMEOVER", + context.draw_text_center(blue_text, _("GAMEOVER"), Vector(0, 200), LAYER_FOREGROUND1); - sprintf(str, "SCORE: %d", player_status.score); + sprintf(str, _("SCORE: %d"), player_status.score); context.draw_text_center(gold_text, str, Vector(0, 224), LAYER_FOREGROUND1); - sprintf(str, "COINS: %d", player_status.distros); + sprintf(str, _("COINS: %d"), player_status.distros); context.draw_text_center(gold_text, str, Vector(0, screen->w - 32), LAYER_FOREGROUND1); @@ -846,17 +847,17 @@ WorldMap::draw_status(DrawingContext& context) char str[80]; sprintf(str, "%d", player_status.score); - context.draw_text(white_text, "SCORE", Vector(0, 0), LAYER_FOREGROUND1); + context.draw_text(white_text, _("SCORE"), Vector(0, 0), LAYER_FOREGROUND1); context.draw_text(gold_text, str, Vector(96, 0), LAYER_FOREGROUND1); sprintf(str, "%d", player_status.distros); - context.draw_text(white_text, "COINS", Vector(screen->w/2 - 16*5, 0), + context.draw_text(white_text, _("COINS"), Vector(screen->w/2 - 16*5, 0), LAYER_FOREGROUND1); context.draw_text(gold_text, str, Vector(screen->w/2 + (16*5)/2, 0), LAYER_FOREGROUND1); - context.draw_text(white_text, "LIVES", - Vector(screen->w - white_text->get_text_width("LIVES")*2, 0), + context.draw_text(white_text, _("LIVES"), + Vector(screen->w - white_text->get_text_width(_("LIVES"))*2, 0), LAYER_FOREGROUND1); if (player_status.lives >= 5) { -- 2.11.0