diff --git a/bin_win32/libiconv2.dll b/bin_win32/libiconv2.dll new file mode 100644 index 00000000..747073f1 Binary files /dev/null and b/bin_win32/libiconv2.dll differ diff --git a/bin_win32/libintl3.dll b/bin_win32/libintl3.dll new file mode 100644 index 00000000..ec11e6b1 Binary files /dev/null and b/bin_win32/libintl3.dll differ diff --git a/packages/locale/de/LC_MESSAGES/AC.mo b/packages/locale/de/LC_MESSAGES/AC.mo new file mode 100644 index 00000000..725f790c Binary files /dev/null and b/packages/locale/de/LC_MESSAGES/AC.mo differ diff --git a/source/locale/AC.pot b/source/locale/AC.pot new file mode 100644 index 00000000..b5b665e3 --- /dev/null +++ b/source/locale/AC.pot @@ -0,0 +1,46 @@ +# 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: 2009-08-12 20:23+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: R:\projects\actioncube\_svn\trunk\ac\source\src\main.cpp:614 +msgid "hello world\n" +msgstr "" + + +msgid "Multiplayer" +msgstr "" + +msgid "Singleplayer" +msgstr "" + +msgid "Settings" +msgstr "" + +msgid "Demo" +msgstr "" + +msgid "Editing" +msgstr "" + +msgid "Help" +msgstr "" + +msgid "About" +msgstr "" + +msgid "Quit" +msgstr "" diff --git a/source/locale/de/LC_MESSAGES/AC.mo b/source/locale/de/LC_MESSAGES/AC.mo new file mode 100644 index 00000000..725f790c Binary files /dev/null and b/source/locale/de/LC_MESSAGES/AC.mo differ diff --git a/source/locale/de/LC_MESSAGES/AC.po b/source/locale/de/LC_MESSAGES/AC.po new file mode 100644 index 00000000..5c47f721 --- /dev/null +++ b/source/locale/de/LC_MESSAGES/AC.po @@ -0,0 +1,42 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) rabid viper productions +# FIRST AUTHOR blah, 2009 +# +msgid "" +msgstr "" +"Project-Id-Version: AC\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2009-08-12 20:23+0200\n" +"PO-Revision-Date: 2009-08-12 20:23+0200\n" +"Last-Translator: dude \n" +"Language-Team: German \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "About" +msgstr "Info" + +msgid "Demo" +msgstr "Demo" + +msgid "Editing" +msgstr "Editieren" + +msgid "Help" +msgstr "Hilfe" + +msgid "Multiplayer" +msgstr "Mehrspieler" + +msgid "Quit" +msgstr "Beenden" + +msgid "Settings" +msgstr "Einstellungen" + +msgid "Singleplayer" +msgstr "Einzelspieler" + +msgid "hello world\n" +msgstr "HALLO WELT\n" diff --git a/source/locale/de_build_mo.bat b/source/locale/de_build_mo.bat new file mode 100644 index 00000000..880b08a3 --- /dev/null +++ b/source/locale/de_build_mo.bat @@ -0,0 +1,3 @@ +msgfmt -c -v -o de\lc_messages\AC.mo de\lc_messages\AC.po +copy /Y de\lc_messages\AC.mo ..\..\packages\locale\de\lc_messages\AC.mo +pause \ No newline at end of file diff --git a/source/locale/de_update_po.bat b/source/locale/de_update_po.bat new file mode 100644 index 00000000..586c2628 --- /dev/null +++ b/source/locale/de_update_po.bat @@ -0,0 +1,2 @@ +msgmerge.exe -s -U de\lc_messages\AC.po AC.pot +pause \ No newline at end of file diff --git a/source/src/cube.h b/source/src/cube.h index b41eac86..189f2a64 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -9,6 +9,7 @@ #include "weapon.h" #include "entity.h" #include "world.h" +#include "i18n.h" #ifndef STANDALONE #include "command.h" diff --git a/source/src/i18n.cpp b/source/src/i18n.cpp new file mode 100644 index 00000000..2b7fae16 --- /dev/null +++ b/source/src/i18n.cpp @@ -0,0 +1,15 @@ +// internationalization and localization + +#include "pch.h" +#include "cube.h" + +i18nmanager::i18nmanager(const char *domain, const char *basepath) : domain(domain), basepath(basepath) +{ + locale = setlocale(LC_ALL, ""); // use current default locale + bindtextdomain(domain, basepath); // set base path + textdomain(domain); + + printf("current locale: %s\n", locale); + + printf(_("hello world\n")); // test output +} \ No newline at end of file diff --git a/source/src/i18n.h b/source/src/i18n.h new file mode 100644 index 00000000..2a8aa380 --- /dev/null +++ b/source/src/i18n.h @@ -0,0 +1,12 @@ +// internationalization and localization + +// localization manager +struct i18nmanager +{ + const char *basepath; + const char *domain; + char *locale; + + i18nmanager(const char *domain, const char *basepath); // initialize locale system + +}; diff --git a/source/src/main.cpp b/source/src/main.cpp index f3718e9c..0578a313 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -606,6 +606,8 @@ int main(int argc, char **argv) } if(!quitdirectly) { + i18nmanager i18n("AC", path("packages/locale", true)); + initing = NOT_INITING; initlog("sdl"); diff --git a/source/src/menus.cpp b/source/src/menus.cpp index a95fe95b..679e6032 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -158,7 +158,7 @@ struct mitemmanual : mitem virtual void render(int x, int y, int w) { mitem::render(x, y, w); - draw_text(text, x, y); + draw_text(_(text), x, y); } virtual void focus(bool on) diff --git a/source/src/tools.h b/source/src/tools.h index 41fda40d..7ed5cf69 100644 --- a/source/src/tools.h +++ b/source/src/tools.h @@ -638,7 +638,15 @@ inline char *newstring(const char *s) { return newstring(s, strlen(s)) inline char *newstringbuf() { return newstring(_MAXDEFSTR-1); } inline char *newstringbuf(const char *s) { return newstring(s, _MAXDEFSTR-1); } -#define _(STRING) gettext(STRING) +inline char *_gettext(const char *msgid) +{ + if(msgid && msgid[0] != '\0') + return gettext(msgid); + else + return ""; +} + +#define _(s) _gettext(s) extern const char *timestring(bool local = false, const char *fmt = NULL); extern const char *asctime(); diff --git a/source/vcpp/cube.vcproj b/source/vcpp/cube.vcproj index 1d18c4ff..0d6241bd 100644 --- a/source/vcpp/cube.vcproj +++ b/source/vcpp/cube.vcproj @@ -569,6 +569,10 @@ RelativePath="..\src\hudgun.h" > + + @@ -1769,6 +1773,10 @@ /> + +