diff --git a/README_ES.md b/README_ES.md new file mode 100644 index 0000000..ddb888f --- /dev/null +++ b/README_ES.md @@ -0,0 +1,30 @@ + TRANSALTION TO SPANISH LANGUAGE +you should follow the following steps. + +1.INSTALL gettext + +http://archive.linuxfromscratch.org/lfs-museum/5.1-pre1/LFS-BOOK-5.1-PRE1-HTML/chapter06/gettext.html + +2. + +# xgettext --keyword=_ --language=C --add-comments --sort-output -o main.pot main.cpp + +3. + +# msginit -l es_AR.UTF-8 -o traslate/es_AR/main.po -i main.pot + +4. + +# msgfmt -c -v -o traslate/es_AR/main.mo traslate/es_AR/main.po + +5. +# sudo cp -v main.mo /usr/share/locale/es_AR/LC_MESSAGES/ +6. + +Insert the following lines in all the functions that there is text on + +setlocale(LC_ALL, ""); + +bindtextdomain("main", "/usr/share/locale"); + +textdomain("main"); diff --git a/Ui.cpp b/Ui.cpp index 867f33a..7f8c4a6 100644 --- a/Ui.cpp +++ b/Ui.cpp @@ -28,9 +28,16 @@ #include #include +#include +#include +#include +#include +#define _(STRING) gettext(STRING) + using namespace std; using namespace boost; + namespace Bastet{ Score &operator +=(Score &a, const Score &b){ @@ -111,13 +118,18 @@ namespace Bastet{ } Curses::Curses(){ + + setlocale(LC_ALL, ""); + bindtextdomain("main", "/usr/share/locale"); + textdomain("main"); + if(initscr()==NULL){ - fprintf(stderr,"bastet: error while initializing graphics (ncurses library).\n"); + fprintf(stderr,(_("bastet: error while initializing graphics (ncurses library).\n"))); exit(1); } if(!has_colors()){ endwin(); - fprintf(stderr,"bastet: no color support, sorry. Ask the author for a black and white version."); + fprintf(stderr,(_("bastet: no color support, sorry. Ask the author for a black and white version."))); exit(1); } @@ -302,6 +314,12 @@ namespace Bastet{ } void Ui::RedrawStatic(){ + + setlocale(LC_ALL, ""); + bindtextdomain("main", "/usr/share/locale"); + textdomain("main"); + + erase(); wrefresh(stdscr); _wellWin.RedrawBorder(); @@ -309,15 +327,15 @@ namespace Bastet{ _scoreWin.RedrawBorder(); wattrset((WINDOW*)_nextWin,COLOR_PAIR(17)); - mvwprintw(_nextWin,0,0," Next block:"); + mvwprintw(_nextWin,0,0,_(" Next block:")); wrefresh(_nextWin); wattrset((WINDOW*)_scoreWin,COLOR_PAIR(17)); - mvwprintw(_scoreWin,1,0,"Score:"); + mvwprintw(_scoreWin,1,0,_("Score:")); wattrset((WINDOW*)_scoreWin,COLOR_PAIR(18)); - mvwprintw(_scoreWin,3,0,"Lines:"); + mvwprintw(_scoreWin,3,0,_("Lines:")); wattrset((WINDOW*)_scoreWin,COLOR_PAIR(19)); - mvwprintw(_scoreWin,5,0,"Level:"); + mvwprintw(_scoreWin,5,0,_("Level:")); wrefresh(_scoreWin); } @@ -333,6 +351,10 @@ namespace Bastet{ time.tv_sec=0; time.tv_usec=delay[_level]; + + setlocale(LC_ALL, ""); + bindtextdomain("main", "/usr/share/locale"); + textdomain("main"); //assumes nodelay(stdscr,TRUE) has already been called BlockPosition p; @@ -376,7 +398,7 @@ namespace Bastet{ break; } else if(ch==keys->Pause){ - MessageDialog("Press SPACE or ENTER to resume the game"); + MessageDialog(_("Press SPACE or ENTER to resume the game")); RedrawStatic(); RedrawWell(w,b,p); nodelay(stdscr,TRUE); @@ -511,25 +533,32 @@ namespace Bastet{ void Ui::HandleHighScores(difficulty_t diff){ HighScores *hs=config.GetHighScores(diff); + setlocale(LC_ALL, ""); + bindtextdomain("main", "/usr/share/locale"); + textdomain("main"); + if(hs->Qualifies(_points)){ - string name=InputDialog(" Congratulations! You got a high score \n Please enter your name"); + string name=InputDialog(_(" Congratulations! You got a high score \n Please enter your name")); hs->InsertHighScore(_points,name); }else{ - MessageDialog("You did not get into\n" - "the high score list!\n" - "\n" - " Try again!\n" - ); + MessageDialog((_(" You did not get into \n the high score list! \n \n Try again!\n")));/*_("You did not get into\n" + "the high score list! \n" + "\n" + " Try again!\n" + ));*/ } } void Ui::ShowHighScores(difficulty_t diff){ HighScores *hs=config.GetHighScores(diff); string allscores; + setlocale(LC_ALL, ""); + bindtextdomain("main", "/usr/share/locale"); + textdomain("main"); if(diff==difficulty_normal) - allscores+="**Normal difficulty**\n"; + allscores+=(_("**Normal difficulty**\n")); else if(diff==difficulty_hard) - allscores+="**Hard difficulty**\n"; + allscores+=(_("**Hard difficulty**\n")); format fmt("%-20.20s %8d\n"); for(HighScores::reverse_iterator it=hs->rbegin();it!=hs->rend();++it){ allscores+=str(fmt % it->Scorer % it->Score); @@ -539,15 +568,20 @@ namespace Bastet{ void Ui::CustomizeKeys(){ Keys *keys=config.GetKeys(); + setlocale(LC_ALL, ""); + bindtextdomain("main", "/usr/share/locale"); + textdomain("main"); + string traslate = _("Press the key you wish to use for:"); /* content is passed to the variable traslate to use the translation function */ + format fmt( - "Press the key you wish to use for:\n\n" + traslate + "\n\n" "%=1.34s\n\n"); - keys->Down=KeyDialog(str(fmt % "move tetromino DOWN (soft-drop)")); - keys->Left=KeyDialog(str(fmt % "move tetromino LEFT")); - keys->Right=KeyDialog(str(fmt % "move tetromino RIGHT")); - keys->RotateCW=KeyDialog(str(fmt % "rotate tetromino CLOCKWISE")); - keys->RotateCCW=KeyDialog(str(fmt % "rotate tetromino COUNTERCLOCKWISE")); - keys->Drop=KeyDialog(str(fmt % "DROP tetromino (move down as much as possible immediately)")); - keys->Pause=KeyDialog(str(fmt % "PAUSE the game")); + keys->Down=KeyDialog(str(fmt % _("move tetromino DOWN (soft-drop)"))); + keys->Left=KeyDialog(str(fmt % _("move tetromino LEFT"))); + keys->Right=KeyDialog(str(fmt % _("move tetromino RIGHT"))); + keys->RotateCW=KeyDialog(str(fmt % _("rotate tetromino CLOCKWISE"))); + keys->RotateCCW=KeyDialog(str(fmt % _("rotate tetromino COUNTERCLOCKWISE"))); + keys->Drop=KeyDialog(str(fmt % _("DROP tetromino (move down as much as possible immediately)"))); + keys->Pause=KeyDialog(str(fmt % _("PAUSE the game"))); } } diff --git a/main.cpp b/main.cpp index ff922ed..002ee5a 100644 --- a/main.cpp +++ b/main.cpp @@ -25,6 +25,12 @@ #include #include +#include +#include +#include +#include +#define _(STRING) gettext(STRING) + using namespace Bastet; using namespace std; using namespace boost; @@ -32,10 +38,16 @@ using namespace boost::assign; int main(int argc, char **argv){ + +setlocale(LC_ALL, ""); +bindtextdomain("main", "/usr/share/locale"); +textdomain("main"); + Ui ui; while(1){ - int choice=ui.MenuDialog(list_of("Play! (normal version)")("Play! (harder version)")("View highscores")("Customize keys")("Quit")); + int choice=ui.MenuDialog(list_of(_("Play! (normal version)"))(_("Play! (harder version)"))(_("View highscores"))(_("Customize keys"))(_("Quit"))); + switch(choice){ case 0:{ //ui.ChooseLevel(); diff --git a/main.pot b/main.pot new file mode 100644 index 0000000..16836b6 --- /dev/null +++ b/main.pot @@ -0,0 +1,38 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-05-05 19:31-0300\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: main.cpp:49 +msgid "Customize keys" +msgstr "" + +#: main.cpp:49 +msgid "Play! (harder version)" +msgstr "" + +#: main.cpp:49 +msgid "Play! (normal version)" +msgstr "" + +#: main.cpp:49 +msgid "Quit" +msgstr "" + +#: main.cpp:49 +msgid "View highscores" +msgstr "" diff --git a/traslate/es_AR/main.mo b/traslate/es_AR/main.mo new file mode 100644 index 0000000..566f070 Binary files /dev/null and b/traslate/es_AR/main.mo differ diff --git a/traslate/es_AR/main.po b/traslate/es_AR/main.po new file mode 100644 index 0000000..c9ae32b --- /dev/null +++ b/traslate/es_AR/main.po @@ -0,0 +1,120 @@ +# Spanish translations for PACKAGE package +# Traducciones al español para el paquete PACKAGE. +# Copyright (C) 2018 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# facundo , 2018. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-05-05 19:31-0300\n" +"PO-Revision-Date: 2018-05-05 19:31-0300\n" +"Last-Translator: facundo \n" +"Language-Team: Argentinian\n" +"Language: es_AR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: main.cpp:49 +msgid "Customize keys" +msgstr "Personalizar claves" + +#: main.cpp:49 +msgid "Play! (harder version)" +msgstr "Jugar! (version dificil)" + +#: main.cpp:49 +msgid "Play! (normal version)" +msgstr "Jugar! (version normal)" + +#: main.cpp:49 +msgid "Quit" +msgstr "Salir" + +#: main.cpp:49 +msgid "View highscores" +msgstr "Ver mejores puntuaciones" + +#: Ui.cpp:127 +msgid "bastet: error while initializing graphics (ncurses library).\n" +msgstr "bastet: error al inicializar gráficos (biblioteca ncurses).\n" + +#:Ui.cpp:132 +msgid "bastet: no color support, sorry. Ask the author for a black and white version." +msgstr "bastet: sin soporte de color, lo siento. Pidale al autor una versión en blanco y negro." + +#: Ui.cpp:330 +msgid " Next block:" +msgstr "proxima pieza:" + +#: Ui.cpp:3334 +msgid "Score:" +msgstr "Puntos:" + +#: Ui.cpp:336 +msgid "Lines:" +msgstr "Lineas:" + +#: Ui.cpp:338 +msgid "Level:" +msgstr "Nivel:" + +#: Ui.cpp:401 +msgid "Press SPACE or ENTER to resume the game" +msgstr "Presione SPACE o ENTER para reanudar el juego" + +#:Ui.cpp:544 +msgid " You did not get into \n the high score list! \n \n Try again!\n" +msgstr " No ingresaste en la lista de puntajes altos! \n \n Intentalo de nuevo! \n" + +#: Ui.cpp:541 +msgid " Congratulations! You got a high score \n Please enter your name" +msgstr " Felicitaciones! Obtuviste puntaje alto, por favor ingresa tu nombre" + +#: Ui.cpp:559 +msgid "**Normal difficulty**\n" +msgstr "**Dificultad Normal**\n" + +#: Ui.cpp:561 +msgid "**Hard difficulty**\n" +msgstr "**Dificultad Dificil**\n" + +#: Ui.cpp:574 +msgid "Press the key you wish to use for:" +msgstr "Presione la tecla que desea usar para:" + +#: Ui.cpp:579 +msgid "move tetromino DOWN (soft-drop)" +msgstr "mover tetromino ABAJO (suave)" + +#: Ui.cpp:580 +msgid "move tetromino LEFT" +msgstr "mover tetromino IZQUIERDA" + +#: Ui.cpp:581 +msgid "move tetromino RIGHT" +msgstr "mover tetromino DERECHA" + +#: Ui.cpp:582 +msgid "rotate tetromino CLOCKWISE" +msgstr "rotar tetromino AGUJAS DEL RELOJ" + +#: Ui.cpp:583 +msgid "rotate tetromino COUNTERCLOCKWISE" +msgstr "rotar tetromino SENTIDO CONTRARIO AGUJAS DEL RELOJ" + +#: Ui.cpp:584 +msgid "DROP tetromino (move down as much as possible immediately)" +msgstr "SOLTAR tetromino (Bajar Rapido)" + +#: Ui.cpp:585 +msgid "PAUSE the game" +msgstr "PAUSA del Juego" + + + + + diff --git a/traslate/main.pot b/traslate/main.pot new file mode 100644 index 0000000..3b88ba4 --- /dev/null +++ b/traslate/main.pot @@ -0,0 +1,22 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-26 19:38-0300\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: main.cpp:39 +msgid "Play! (normal version)" +msgstr "" diff --git a/xgettext b/xgettext new file mode 100644 index 0000000..e69de29