[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2984 - in branches/pingus_sdl: . src src/components src/ti
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r2984 - in branches/pingus_sdl: . src src/components src/tinygettext |
Date: |
Fri, 17 Aug 2007 17:39:19 +0200 |
Author: grumbel
Date: 2007-08-17 17:39:18 +0200 (Fri, 17 Aug 2007)
New Revision: 2984
Modified:
branches/pingus_sdl/TODO
branches/pingus_sdl/src/components/pingus_counter.cpp
branches/pingus_sdl/src/fps_counter.cpp
branches/pingus_sdl/src/game_time.cpp
branches/pingus_sdl/src/gettext.cpp
branches/pingus_sdl/src/gettext.h
branches/pingus_sdl/src/pingus_main.cpp
branches/pingus_sdl/src/tinygettext/dictionary.cpp
branches/pingus_sdl/src/tinygettext/dictionary.hpp
branches/pingus_sdl/src/tinygettext/dictionary_manager.cpp
branches/pingus_sdl/src/tinygettext/dictionary_manager.hpp
branches/pingus_sdl/src/tinygettext/po_file_reader.cpp
branches/pingus_sdl/src/tinygettext/po_file_reader.hpp
Log:
- fixed latin-2 and latin-9 support
Modified: branches/pingus_sdl/TODO
===================================================================
--- branches/pingus_sdl/TODO 2007-08-17 14:38:08 UTC (rev 2983)
+++ branches/pingus_sdl/TODO 2007-08-17 15:39:18 UTC (rev 2984)
@@ -42,6 +42,8 @@
- GroundMap tiles are currently RGBA, while in reality they are just
RGB with a colorkey, room for optimization
+- implement xschema-like language to check for syntax errors in the level files
+
Roadmap for Pingus 0.7.0
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -58,8 +60,6 @@
- remove all the remaining unneeded debuging std::cout's
-- Latin-2 and Latin-9 aren't not working, see language tr, cs, sr
-
- src/components/pingus_counter.hpp font should be fixed-width/monospace
- forgein languages break many parts of the GUI (font align, mostly worldmap)
Modified: branches/pingus_sdl/src/components/pingus_counter.cpp
===================================================================
--- branches/pingus_sdl/src/components/pingus_counter.cpp 2007-08-17
14:38:08 UTC (rev 2983)
+++ branches/pingus_sdl/src/components/pingus_counter.cpp 2007-08-17
15:39:18 UTC (rev 2984)
@@ -46,7 +46,7 @@
World* world = server->get_world();
- snprintf(str, 128, _("Released:%3d/%-3d Out:%3d Saved:%3d/%-3d"),
+ snprintf(str, 128, _("Released:%3d/%-3d Out:%3d Saved:%3d/%-3d").c_str(),
world->get_pingus()->get_number_of_released(),
world->get_pingus()->get_number_of_allowed(),
world->get_pingus()->get_number_of_alive(),
Modified: branches/pingus_sdl/src/fps_counter.cpp
===================================================================
--- branches/pingus_sdl/src/fps_counter.cpp 2007-08-17 14:38:08 UTC (rev
2983)
+++ branches/pingus_sdl/src/fps_counter.cpp 2007-08-17 15:39:18 UTC (rev
2984)
@@ -41,7 +41,7 @@
{
font = Fonts::pingus_small;
start_time = SDL_GetTicks();
- strcat(fps_string, _("unknown"));
+ strcat(fps_string, "");
fps_count = 0;
}
Modified: branches/pingus_sdl/src/game_time.cpp
===================================================================
--- branches/pingus_sdl/src/game_time.cpp 2007-08-17 14:38:08 UTC (rev
2983)
+++ branches/pingus_sdl/src/game_time.cpp 2007-08-17 15:39:18 UTC (rev
2984)
@@ -61,15 +61,15 @@
std::string
GameTime::ticks_to_realtime_string(int ticks)
{
- const int time_str_size = 20;
- char time_str[time_str_size];
-
if (ticks == -1)
{
- snprintf(time_str, time_str_size, _("unlimited"));
+ return _("unlimited");
}
else
{
+ const int time_str_size = 20;
+ char time_str[time_str_size];
+
int total_seconds = ticks * game_speed / 1000;
int seconds = total_seconds % 60;
int minutes = total_seconds / 60;
@@ -80,8 +80,9 @@
seconds = 0;
snprintf(time_str, time_str_size, "%2d:%02d", minutes, seconds);
+
+ return time_str;
}
- return time_str;
}
Modified: branches/pingus_sdl/src/gettext.cpp
===================================================================
--- branches/pingus_sdl/src/gettext.cpp 2007-08-17 14:38:08 UTC (rev 2983)
+++ branches/pingus_sdl/src/gettext.cpp 2007-08-17 15:39:18 UTC (rev 2984)
@@ -17,8 +17,18 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#include "tinygettext/dictionary_manager.hpp"
+#include "tinygettext/dictionary.hpp"
#include "gettext.h"
TinyGetText::DictionaryManager dictionary_manager;
+std::string _(const std::string& msg) {
+ return dictionary_manager.get_dictionary().translate(msg);
+}
+
+std::string N_(const std::string& msg, const std::string& msg_pl, int num) {
+ return dictionary_manager.get_dictionary().translate(msg, msg_pl, num);
+}
+
/* EOF */
Modified: branches/pingus_sdl/src/gettext.h
===================================================================
--- branches/pingus_sdl/src/gettext.h 2007-08-17 14:38:08 UTC (rev 2983)
+++ branches/pingus_sdl/src/gettext.h 2007-08-17 15:39:18 UTC (rev 2984)
@@ -20,12 +20,9 @@
#ifndef HEADER_GETTEXT_HXX
#define HEADER_GETTEXT_HXX
-#include "tinygettext/dictionary_manager.hpp"
-#include "tinygettext/dictionary.hpp"
+#include <string>
-extern TinyGetText::DictionaryManager dictionary_manager;
+std::string _(const std::string& msg);
+std::string _(const std::string& msg, const std::string& msg_pl, int num);
-#define _(String)
dictionary_manager.get_dictionary().translate(String).c_str()
-#define N_(id, id2, num) dictionary_manager.get_dictionary().translate(id,
di2, num).c_str()
-
#endif /* HEADER_GETTEXT_HXX */
Modified: branches/pingus_sdl/src/pingus_main.cpp
===================================================================
--- branches/pingus_sdl/src/pingus_main.cpp 2007-08-17 14:38:08 UTC (rev
2983)
+++ branches/pingus_sdl/src/pingus_main.cpp 2007-08-17 15:39:18 UTC (rev
2984)
@@ -32,6 +32,7 @@
#include <physfs.h>
#include "lisp/lisp.hpp"
#include "lisp/parser.hpp"
+#include "string_util.hpp"
#include "sexpr_file_reader.hpp"
#include "SDL.h"
@@ -44,7 +45,7 @@
//#include <ClanLib/gui.h>
#include "gettext.h"
-
+#include "tinygettext/dictionary_manager.hpp"
#include "command_line.hpp"
#include "gui/screen_manager.hpp"
@@ -89,6 +90,7 @@
#pragma warning( disable : 4996 )
#endif
+extern TinyGetText::DictionaryManager dictionary_manager;
void
signal_handler(int signo)
@@ -97,30 +99,30 @@
{
case SIGSEGV:
puts("\n,------------------------------------------------------------------------");
- puts(_("| segfault_handler: caught a SIGSEGV."));
- puts ("|");
- puts(_("| Woops, Pingus just crashed, congratulations you've found a
bug."));
- puts(_("| Please write a little bug report to <address@hidden>, include
information"));
- puts(_("| where exacly the SIGSEGV occurred and how to reproduce it."));
- puts(_("| Also try to include a backtrace, you can get it by doing:"));
- puts ("|");
- puts ("| $ gdb pingus core");
- puts ("| (gdb) bt");
- puts ("| ...");
- puts ("|");
- puts(_("| If that doesn't work, try this:"));
- puts ("|");
- puts ("| $ gdb pingus");
- puts ("| (gdb) r");
- puts(_("| [play until it crashes again]"));
- puts ("| ...");
- puts ("|");
- puts
("'------------------------------------------------------------------------\n");
+ puts("| segfault_handler: caught a SIGSEGV.");
+ puts("|");
+ puts("| Woops, Pingus just crashed, congratulations you've found a
bug.");
+ puts("| Please write a little bug report to <address@hidden>, include
information");
+ puts("| where exacly the SIGSEGV occurred and how to reproduce it.");
+ puts("| Also try to include a backtrace, you can get it by doing:");
+ puts("|");
+ puts("| $ gdb pingus core");
+ puts("| (gdb) bt");
+ puts("| ...");
+ puts("|");
+ puts("| If that doesn't work, try this:");
+ puts("|");
+ puts("| $ gdb pingus");
+ puts("| (gdb) r");
+ puts("| [play until it crashes again]");
+ puts("| ...");
+ puts("|");
+
puts("'------------------------------------------------------------------------\n");
break;
case SIGINT:
puts("\n,------------------------------------------------------------------------");
- puts (_("| Warning: Pingus recieved a SIGINT, exiting now."));
+ puts("| Warning: Pingus recieved a SIGINT, exiting now.");
puts("`------------------------------------------------------------------------\n");
break;
@@ -243,7 +245,7 @@
_("Enable software cursor"));
argp.add_option(342, "no-cfg-file", "",
_("Don't read ~/.pingus/config"));
- argp.add_option(347, "config-file", "", _("FILE"),
+ argp.add_option(347, "config-file", _("FILE"),
_("Read config from FILE (default: ~/.pingus/config) reduce
CPU usage, "
"might speed up the game on slower machines"));
argp.add_option(360, "controller", "FILE",
@@ -632,24 +634,6 @@
// dictionary_manager.set_language("de");
dictionary_manager.add_directory(path_manager.complete("po/"));
- std::string language =
dictionary_manager.get_dictionary().get_language().code;
-
- if(language == "cs" || language == "sr")
- {
- dictionary_manager.set_charset("ISO-8859-2");
- Fonts::encoding = "iso-8859-2";
- }
- else if(language == "tr")
- {
- dictionary_manager.set_charset("ISO-8859-9");
- Fonts::encoding = "iso-8859-9";
- }
- else
- {
- dictionary_manager.set_charset("ISO-8859-1");
- Fonts::encoding = "iso-8859-1";
- }
-
if (maintainer_mode)
std::cout << "BasePath: " << path_manager.get_base_path () << std::endl;
}
@@ -667,24 +651,27 @@
std::cout.put('=');
std::cout << std::endl;
- std::cout << _("language: ") <<
dictionary_manager.get_dictionary().get_language().name << std::endl;
+ std::cout << "language: " <<
dictionary_manager.get_dictionary().get_language().name << std::endl;
+ Fonts::encoding =
StringUtil::to_lower(dictionary_manager.get_dictionary().get_charset());
+ std::cout << "font encoding: " << Fonts::encoding << std::endl;
+
if (sound_enabled)
- std::cout << _("sound support: enabled") << std::endl;
+ std::cout << "sound support: enabled" << std::endl;
else
- std::cout << _("sound support: disabled") << std::endl;
+ std::cout << "sound support: disabled" << std::endl;
if (music_enabled)
- std::cout << _("music support: enabled") << std::endl;
+ std::cout << "music support: enabled" << std::endl;
else
- std::cout << _("music support: disabled") << std::endl;
+ std::cout << "music support: disabled" << std::endl;
- std::cout << _("resolution: ") << screen_width << "x" <<
screen_height << std::endl;
- std::cout << _("fullscreen: ")
- << (fullscreen_enabled ? _(" enabled") : _("disabled"))
+ std::cout << "resolution: " << screen_width << "x" <<
screen_height << std::endl;
+ std::cout << "fullscreen: "
+ << (fullscreen_enabled ? " enabled" : "disabled")
<< std::endl;
- //std::cout << _("refresh rate: ") << refresh_rate << std::endl;
- std::cout << _("using OpenGL: ") << use_opengl << std::endl;
+ //std::cout << "refresh rate: " << refresh_rate << std::endl;
+ std::cout << "using OpenGL: " << use_opengl << std::endl;
std::cout << std::endl;
}
Modified: branches/pingus_sdl/src/tinygettext/dictionary.cpp
===================================================================
--- branches/pingus_sdl/src/tinygettext/dictionary.cpp 2007-08-17 14:38:08 UTC
(rev 2983)
+++ branches/pingus_sdl/src/tinygettext/dictionary.cpp 2007-08-17 15:39:18 UTC
(rev 2984)
@@ -27,10 +27,16 @@
}
Dictionary::Dictionary()
- : language(lang_en)
+ : language(lang_en), charset("ISO-8859-1")
{
}
+void
+Dictionary::set_charset(const std::string& charset_)
+{
+ charset = charset_;
+}
+
std::string
Dictionary::get_charset() const
{
@@ -38,12 +44,6 @@
}
void
-Dictionary::set_charset(const std::string& charset_)
-{
- charset = charset_;
-}
-
-void
Dictionary::set_language(const LanguageDef& lang)
{
language = lang;
Modified: branches/pingus_sdl/src/tinygettext/dictionary.hpp
===================================================================
--- branches/pingus_sdl/src/tinygettext/dictionary.hpp 2007-08-17 14:38:08 UTC
(rev 2983)
+++ branches/pingus_sdl/src/tinygettext/dictionary.hpp 2007-08-17 15:39:18 UTC
(rev 2984)
@@ -50,9 +50,7 @@
/** Return the charset used for this dictionary */
std::string get_charset() const;
- /** Set a charset for this dictionary, this will NOT convert stuff,
- it is for information only, you have to convert stuff yourself
- when you add it with \a add_translation() */
+ /** Set a charset for this dictionary, this does not convert anything */
void set_charset(const std::string& charset);
/** Set the language that is used for this dictionary, this is
Modified: branches/pingus_sdl/src/tinygettext/dictionary_manager.cpp
===================================================================
--- branches/pingus_sdl/src/tinygettext/dictionary_manager.cpp 2007-08-17
14:38:08 UTC (rev 2983)
+++ branches/pingus_sdl/src/tinygettext/dictionary_manager.cpp 2007-08-17
15:39:18 UTC (rev 2984)
@@ -40,7 +40,8 @@
}
DictionaryManager::DictionaryManager()
- : current_dict(&empty_dict)
+ : empty_dict(lang_en, "ISO-8859-1"),
+ current_dict(&empty_dict)
{
parseLocaleAliases();
// setup language from environment vars
@@ -101,12 +102,9 @@
}
else // Dictionary for languages lang isn't loaded, so we load it
{
- //std::cout << "get_dictionary: " << lang << std::endl;
Dictionary& dict = dictionaries[lang];
dict.set_language(get_language_def(lang));
- if(charset != "")
- dict.set_charset(charset);
for (SearchPath::iterator p = search_path.begin(); p !=
search_path.end(); ++p)
{
@@ -179,14 +177,6 @@
}
void
-DictionaryManager::set_charset(const std::string& charset)
-{
- dictionaries.clear(); // changing charset invalidates cache
- this->charset = charset;
- set_language(language);
-}
-
-void
DictionaryManager::set_language_alias(const std::string& alias,
const std::string& language)
{
Modified: branches/pingus_sdl/src/tinygettext/dictionary_manager.hpp
===================================================================
--- branches/pingus_sdl/src/tinygettext/dictionary_manager.hpp 2007-08-17
14:38:08 UTC (rev 2983)
+++ branches/pingus_sdl/src/tinygettext/dictionary_manager.hpp 2007-08-17
15:39:18 UTC (rev 2984)
@@ -32,17 +32,17 @@
class DictionaryManager
{
private:
+ Dictionary empty_dict;
+
typedef std::map<std::string, Dictionary> Dictionaries;
Dictionaries dictionaries;
typedef std::vector<std::string> SearchPath;
SearchPath search_path;
typedef std::map<std::string, std::string> Aliases;
Aliases language_aliases;
- std::string charset;
std::string language;
Dictionary* current_dict;
- Dictionary empty_dict;
-
+
public:
DictionaryManager();
@@ -57,9 +57,6 @@
/** Set a language based on a four? letter country code */
void set_language(const std::string& langspec);
- /** Set a charset that will be set on the returned dictionaries */
- void set_charset(const std::string& charset);
-
/** Define an alias for a language */
void set_language_alias(const std::string& alias, const std::string& lang);
Modified: branches/pingus_sdl/src/tinygettext/po_file_reader.cpp
===================================================================
--- branches/pingus_sdl/src/tinygettext/po_file_reader.cpp 2007-08-17
14:38:08 UTC (rev 2983)
+++ branches/pingus_sdl/src/tinygettext/po_file_reader.cpp 2007-08-17
15:39:18 UTC (rev 2984)
@@ -42,6 +42,12 @@
state = WANT_MSGID;
line_num = 0;
tokenize_po(in);
+
+ if (dict.get_charset().empty())
+ {
+ std::cout << "POFileReader: Error: charset not declared in .po file,
fallback to ISO-8859-1" << std::endl;
+ dict.set_charset("ISO-8859-1");
+ }
}
void
@@ -64,22 +70,10 @@
for(Lines::iterator i = lines.begin(); i != lines.end(); ++i)
{
if (has_prefix(*i, "Content-Type: text/plain; charset=")) {
- from_charset = i->substr(strlen("Content-Type: text/plain; charset="));
+ dict.set_charset(i->substr(strlen("Content-Type: text/plain;
charset=")));
+ break;
}
- }
-
- if (from_charset.empty() || from_charset == "CHARSET")
- {
- std::cerr << "Error: Charset not specified for .po, fallback to
ISO-8859-1" << std::endl;
- from_charset = "ISO-8859-1";
- }
-
- to_charset = dict.get_charset();
- if (to_charset.empty())
- { // No charset requested from the dict, so we use the one from the .po
- to_charset = from_charset;
- dict.set_charset(from_charset);
- }
+ }
}
void
@@ -126,8 +120,7 @@
}
else
{
- dict.add_translation(current_msgid,
- IConv::convert(token.content, from_charset,
to_charset));
+ dict.add_translation(current_msgid, token.content);
}
state = WANT_MSGID;
}
@@ -148,7 +141,7 @@
}
else
{
- msgstr_plural[num] = IConv::convert(token.content, from_charset,
to_charset);
+ msgstr_plural[num] = token.content;
}
}
else
Modified: branches/pingus_sdl/src/tinygettext/po_file_reader.hpp
===================================================================
--- branches/pingus_sdl/src/tinygettext/po_file_reader.hpp 2007-08-17
14:38:08 UTC (rev 2983)
+++ branches/pingus_sdl/src/tinygettext/po_file_reader.hpp 2007-08-17
15:39:18 UTC (rev 2984)
@@ -37,9 +37,6 @@
Dictionary& dict;
- std::string from_charset;
- std::string to_charset;
-
std::string current_msgid;
std::string current_msgid_plural;
std::map<int, std::string> msgstr_plural;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2984 - in branches/pingus_sdl: . src src/components src/tinygettext,
grumbel at BerliOS <=