SubDir TOP ;
+if $(XGETTEXT) != ""
+{
+ actions XGetText
+ {
+ $(XGETTEXT) $(XGETTEXT_FLAGS) --keyword='_:1' -o $(<) $(>)
+ }
+ rule MakePot
+ {
+ if $(>) {
+ XGetText $(<) : $(>) ;
+ Depends $(<) : $(>) ;
+ Depends all : $(<) ;
+ }
+ }
+} else {
+ rule MakePot
+ { }
+}
+
# Decend into subdirs
SubInclude TOP lib ;
SubInclude TOP src ;
# add some additional files to package
Package INSTALL NEWS README COPYING AUTHORS ChangeLog ;
-if $(XGETTEXT) != ""
-{
-
- actions MakePot
- {
- $(XGETTEXT) --keyword='_:1' --c++ -o $(<) $(>)
- }
- MakePot supertux.pot : $(TRANSLATABLE_SOURCES) ;
- Depends supertux.pot : $(TRANSLATABLE_SOURCES) ;
- MakeLocate supertux.pot : data/locale ;
- Depends all : supertux.pot ;
-}
+MakePot data/locale/supertux.pot : $(TRANSLATABLE_SOURCES) ;
+XGETTEXT_FLAGS on data/locale/supertux.pot += --language=C++ ;
levels/test
levels/world1
levels/world2
- levels/worldmap
;
for p in $(LEVELPATHS) {
InstallData [ Wildcard $(p) : info *.stl *.stwm ] : $(p) ;
+
+ local translatable_lisp = [ Wildcard $(p) : info *.stl *.stwm ] ;
+ SEARCH on $(translatable_lisp) = $(SEARCH_SOURCE) ;
+ MakePot $(SUBDIR)/$(p)/messages.pot : $(translatable_lisp) ;
+ XGETTEXT_FLAGS on $(SUBDIR)/$(p)/messages.pot += --language=Lisp ;
}
InstallData [ Wildcard *.txt ] ;
InstallData [ Wildcard music : *.mod *.ogg ] : music ;
--- /dev/null
+# German translations for bonus package
+# German messages for bonus.
+# Copyright (C) 2004 THE bonus'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the bonus package.
+# <matze@braunis.de>, 2004.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: bonus 1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2004-12-02 02:33+0100\n"
+"PO-Revision-Date: 2004-12-02 02:34+0100\n"
+"Last-Translator: <matze@braunis.de>\n"
+"Language-Team: German <de@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: data/levels/bonus1/wansti-level1.stl:5
+msgid "Semi-Frozen"
+msgstr "Halb-Gefroren"
+
+#: data/levels/bonus1/worldmap.stwm:4
+msgid "Bonus Island I"
+msgstr "Bonusinsel I"
+
+#: data/levels/bonus1/worldmap.stwm:131
+msgid "You found a secret place!"
+msgstr "Du hast ein Versteck gefunden!"
+
+#: data/levels/bonus1/worldmap.stwm:137
+msgid "Hint: Use igloos to get back here."
+msgstr "Tip: Benutze die Igloos um hierher zurück zu kommen."
+
+#: data/levels/bonus1/worldmap.stwm:145
+msgid "Warp to Matr1x' Sector"
+msgstr "Zu Matr1x' Sektor beamen"
+
+#: data/levels/bonus1/worldmap.stwm:151
+msgid "Warp to Thompson's Domain"
+msgstr "Zu Thompsons Bereich beamen"
+
+#: data/levels/bonus1/worldmap.stwm:157
+msgid "Warp to the SuperTux Team Island"
+msgstr "Zur SuperTux Team Insel beamen"
+
+#: data/levels/bonus1/worldmap.stwm:163
+msgid "Warp to Abednego's Area"
+msgstr "Zu Abednegos Zone beamen"
+
+#: data/levels/bonus1/worldmap.stwm:169
+msgid "Warp to Torfi's Territory"
+msgstr "Zu Torfis Territorium beamen"
+
+#: data/levels/bonus1/worldmap.stwm:175
+msgid "Leave Matrix' Sector"
+msgstr "Matrix Sektor verlassen"
+
+#: data/levels/bonus1/worldmap.stwm:181
+msgid "Leave Thompson's Domain"
+msgstr "Thompsons Bereich verlassen"
+
+#: data/levels/bonus1/worldmap.stwm:187
+msgid "Leave SuperTux Team Island"
+msgstr "SuperTux Team Insel verlassen"
+
+#: data/levels/bonus1/worldmap.stwm:193
+msgid "Leave Abednego's Area"
+msgstr "Abednegos Zone verlassen"
+
+#: data/levels/bonus1/worldmap.stwm:199
+msgid "Leave Torfi's Territory"
+msgstr "Torfis Territorium verlassen"
+
+#: data/levels/bonus1/worldmap.stwm:207
+msgid "Warp home"
+msgstr "Nach Hause beamen"
(supertux-level
(version 1)
(author "SuperTux Team")
- (name "Semi-Frozen")
+ (name (_ "Semi-Frozen"))
(width 500)
(height 15)
(start_pos_x 100)
;; Generated with Flexlay Editor
(supertux-worldmap
(properties
- (name "Bonus Island I")
+ (name (_ "Bonus Island I"))
(start_pos_x 35)
(start_pos_y 2))
(tilemap
(level (name "wansti-level5.stl")
(x 50)
(y 22))
-
- (special-tile (map-message "You found a secret place!")
+ (special-tile (map-message (_ "You found a secret place!"))
(x 33)
(y 39) (passive-message #t)
(apply-to-direction "west-north-south"))
- (special-tile (map-message "Hint: Use igloos to get back here.")
+ (special-tile (map-message
+ (_ "Hint: Use igloos to get back here."))
(x 35)
(y 5) (passive-message #t)
(apply-to-direction "north"))
(special-tile
(x 33)
(y 8)
- (map-message "Warp to Matr1x' Sector")
+ (map-message (_ "Warp to Matr1x' Sector"))
(teleport-to-x 20)
(teleport-to-y 14))
(special-tile
(x 31)
(y 8)
- (map-message "Warp to Thompson's Domain")
+ (map-message (_ "Warp to Thompson's Domain"))
(teleport-to-x 34)
(teleport-to-y 18))
(special-tile
(x 35)
(y 8)
- (map-message "Warp to the SuperTux Team Island")
+ (map-message (_ "Warp to the SuperTux Team Island"))
(teleport-to-x 51)
(teleport-to-y 10))
(special-tile
(x 37)
(y 8)
- (map-message "Warp to Abednego's Area")
+ (map-message (_ "Warp to Abednego's Area"))
(teleport-to-x 15)
(teleport-to-y 31))
(special-tile
(x 39)
(y 8)
- (map-message "Warp to Torfi's Territory")
+ (map-message (_ "Warp to Torfi's Territory"))
(teleport-to-x 56)
(teleport-to-y 33))
(special-tile
(x 19)
(y 24)
- (map-message "Leave Matrix' Sector")
+ (map-message (_ "Leave Matrix' Sector"))
(teleport-to-x 32)
(teleport-to-y 37))
(special-tile
(x 35)
(y 26)
- (map-message "Leave Thompson's Domain")
+ (map-message (_ "Leave Thompson's Domain"))
(teleport-to-x 35)
(teleport-to-y 2))
(special-tile
(x 54)
(y 25)
- (map-message "Leave SuperTux Team Island")
+ (map-message (_ "Leave SuperTux Team Island"))
(teleport-to-x 35)
(teleport-to-y 2))
(special-tile
(x 18)
(y 43)
- (map-message "Leave Abednego's Area")
+ (map-message (_ "Leave Abednego's Area"))
(teleport-to-x 35)
(teleport-to-y 2))
(special-tile
(x 60)
(y 43)
- (map-message "Leave Torfi's Territory")
+ (map-message (_ "Leave Torfi's Territory"))
(teleport-to-x 35)
(teleport-to-y 2))
(special-tile
(x 27)
(y 39)
- (map-message "Warp home")
+ (map-message (_ "Warp home"))
(teleport-to-x 35)
(teleport-to-y 2))
;SuperTux-Level
(supertux-level
(version 1)
- (name "The long cave")
+ (name (_ "The long cave"))
(author "Torfi Gunnarsson")
(music "cave.mod")
(background "cave2.jpg")
;SuperTux-Level
(supertux-level
(version 1)
- (name "Hello World")
+ (name (_ "Menu Level"))
(author "unknown author")
(music "theme.mod")
(background "arctis.jpg")
(supertux-level
(version 2)
- (name "Sector Test")
+ (name (_ "Sector Test"))
(author "Matthias Braun")
(time 500)
(sector
--- /dev/null
+# German translations for world package
+# German messages for world.
+# Copyright (C) 2004 THE world'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the world package.
+# <matze@braunis.de>, 2004.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: world 1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2004-12-02 02:10+0100\n"
+"PO-Revision-Date: 2004-12-02 02:25+0100\n"
+"Last-Translator: <matze@braunis.de>\n"
+"Language-Team: German <de@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: data/levels/world1/level1.stl:5
+msgid "Welcome to Antarctica"
+msgstr "Willkommen in Antarktika"
+
+#: data/levels/world1/level2.stl:5
+msgid "The Journey Begins"
+msgstr "Die Reise Beginnt"
(supertux-level
(version 1)
(author "SuperTux Team")
- (name "Welcome to Antarctica")
+ (name (_ "Welcome to Antarctica"))
(name-pt_PT "Bem-vindo à Antártida")
(name-de "Willkommen in Antarctica")
(name-es "Bienvenido a la Antártida")
(supertux-level
(version 1)
(author "SuperTux Team")
- (name "The Journey Begins")
+ (name (_ "The Journey Begins"))
(name-pt_PT "A Aventura Começa")
(name-de "Das Abenteuer beginnt")
(name-es "La aventura comienza")
(supertux-level
(version 1)
(author "SuperTux Team")
- (name "Via Nostalgica")
+ (name (_ "Via Nostalgica"))
(width 390)
(height 19)
(start_pos_x 100)
(supertux-level
(version 1)
(author "SuperTux Team")
- (name "Iceberg Fortress")
+ (name (_ "Iceberg Fortress"))
(width 550)
(height 105)
(start_pos_x 100)
;; Generated by Flexlay Editor
(supertux-level
(version 2)
- (name "Forest Level 1")
+ (name (_ "Forest Level 1"))
(author "SuperTux Team")
(time 999)
(sector
return sdirs;
}
+std::string FileSystem::dirname(const std::string& filename)
+{
+ std::string::size_type p = filename.find_last_of('/');
+ if(p == std::string::npos)
+ return "";
+
+ return filename.substr(0, p+1);
+}
+
void Setup::init(const std::string& _package_name,
const std::string& _package_symbol_name,
const std::string& _package_version)
static std::set<std::string> read_directory(const std::string& pathname);
static std::set<std::string> dsubdirs(const std::string& rel_path, const std::string& expected_file);
static std::set<std::string> dfiles(const std::string& rel_path, const std::string& glob, const std::string& exception_str);
+
+ static std::string dirname(const std::string& filename);
};
/// All you need to get an application up and running
#include <stdexcept>
#include <fstream>
#include <cassert>
+#include <iostream>
+#include "app/setup.h"
+#include "app/tinygettext.h"
#include "parser.h"
#include "lisp.h"
namespace lisp
{
-Parser::Parser()
- : lexer(0)
+Parser::Parser(bool translate)
+ : lexer(0), dictionary_manager(0), dictionary(0)
{
+ if(translate) {
+ dictionary_manager = new TinyGetText::DictionaryManager();
+ }
}
Parser::~Parser()
{
delete lexer;
+ delete dictionary_manager;
}
Lisp*
msg << "Parser problem: Couldn't open file '" << filename << "'.";
throw std::runtime_error(msg.str());
}
+
+ if(dictionary_manager) {
+ dictionary_manager->add_directory(SuperTux::FileSystem::dirname(filename));
+ dictionary = & (dictionary_manager->get_dictionary());
+ }
+
return parse(in);
}
break;
}
+ if(token == Lexer::TOKEN_SYMBOL &&
+ strcmp(lexer->getString(), "_") == 0) {
+ // evaluate translation function (_ str) in place here
+ token = lexer->getNextToken();
+ if(token != Lexer::TOKEN_STRING)
+ throw new std::runtime_error("Expected string after '(_'");
+
+ result = new Lisp(Lisp::TYPE_STRING);
+ if(dictionary) {
+ std::string translation = dictionary->translate(lexer->getString());
+ std::cout << "Translated '" << lexer->getString() << "' -> '"
+ << translation << "'\n";
+ result->v.string = new char[translation.size()+1];
+ memcpy(result->v.string, translation.c_str(), translation.size()+1);
+ } else {
+ size_t len = strlen(lexer->getString()) + 1;
+ result->v.string = new char[len];
+ memcpy(result->v.string, lexer->getString(), len);
+ }
+ token = lexer->getNextToken();
+ if(token != Lexer::TOKEN_CLOSE_PAREN)
+ throw new std::runtime_error("Expected ')' after '(_ string'");
+ break;
+ }
+
Lisp* cur = result;
do {
cur->v.cons.car = read();
#include <string>
#include "lexer.h"
+namespace TinyGetText {
+class Dictionary;
+class DictionaryManager;
+}
+
namespace lisp
{
class Parser
{
public:
- Parser();
+ Parser(bool translate = true);
~Parser();
Lisp* parse(const std::string& filename);
Lisp* read();
Lexer* lexer;
+ TinyGetText::DictionaryManager* dictionary_manager;
+ TinyGetText::Dictionary* dictionary;
Lexer::TokenType token;
};
void
WorldMap::load_map()
{
- std::string::size_type p = map_filename.find_last_of('/');
- if(p == std::string::npos)
- levels_path = "";
- else
- levels_path = map_filename.substr(0, p+1);
+ levels_path = FileSystem::dirname(map_filename);
try {
lisp::Parser parser;