Fixed i18n on OS X too (may not work on PPC macs)

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4433 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2010-01-11 23:22:44 +00:00
parent 71616e256e
commit 1cd161e7d9
3 changed files with 51 additions and 11 deletions

View File

@@ -4,5 +4,5 @@ HEADER_SEARCH_PATHS = /usr/local/include /usr/include /usr/local/include/irrlich
OTHER_CFLAGS = -Wall -DHAVE_OGGVORBIS=1 -DHAS_SOCKLEN_T -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAS_POLL=1 -DHAS_FCNTL=1 -DHAS_INET_PTON=1 -DHAS_INET_NTOP=1 -DHAS_MSGHDR_FLAGS=1 -DENABLE_NLS=1 -DHAVE_GETTEXT=1 -DHAVE_GLUT=1 -DHAVE_IRRLICHT=1 -DPACKAGE="\"supertuxkart\"" -D__MACOSX__=1 -DHAVE_RTT=1
OTHER_LDFLAGS = -lirrlicht -liconv
OTHER_LDFLAGS = -lirrlicht -lintl
LIBRARY_SEARCH_PATHS = /usr/local/lib /usr/lib

View File

@@ -17,7 +17,6 @@
9507E96A0FC1C8C200BD2B92 /* GlutStuff.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9507E9490FC1C8C100BD2B92 /* GlutStuff.cpp */; };
9507E9700FC1C8C200BD2B92 /* RenderTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9507E9500FC1C8C200BD2B92 /* RenderTexture.cpp */; };
9507E9B70FC1CCE900BD2B92 /* stk.icns in Resources */ = {isa = PBXBuildFile; fileRef = 9507E9B60FC1CCE900BD2B92 /* stk.icns */; };
9507E9D00FC1CDCE00BD2B92 /* libintl.framework in Copy frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7F80FC1B63C00DB481B /* libintl.framework */; };
9507E9D10FC1CDCE00BD2B92 /* Ogg.framework in Copy frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7F90FC1B63C00DB481B /* Ogg.framework */; };
9507E9D20FC1CDCE00BD2B92 /* OpenAL.framework in Copy frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7FA0FC1B63C00DB481B /* OpenAL.framework */; };
9507E9DB0FC1CDD500BD2B92 /* Vorbis.framework in Copy frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7FB0FC1B63C00DB481B /* Vorbis.framework */; };
@@ -230,7 +229,6 @@
9551C8F90FC1B72500DB481B /* physical_object.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 95CA59F70F82FCB7003323DB /* physical_object.cpp */; };
9551C8FA0FC1B72500DB481B /* quad_set.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 951C357E0FC05BF400A48379 /* quad_set.cpp */; };
9551C8FB0FC1B72500DB481B /* quad_graph.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 951C35800FC05BF400A48379 /* quad_graph.cpp */; };
9551C9F00FC1B7EE00DB481B /* libintl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7F80FC1B63C00DB481B /* libintl.framework */; };
9551C9F10FC1B7EE00DB481B /* Ogg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7F90FC1B63C00DB481B /* Ogg.framework */; };
9551C9F20FC1B7EE00DB481B /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7FA0FC1B63C00DB481B /* OpenAL.framework */; };
9551C9F30FC1B7EE00DB481B /* Vorbis.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9551C7FB0FC1B63C00DB481B /* Vorbis.framework */; };
@@ -297,7 +295,6 @@
dstSubfolderSpec = 10;
files = (
9507E9DB0FC1CDD500BD2B92 /* Vorbis.framework in Copy frameworks */,
9507E9D00FC1CDCE00BD2B92 /* libintl.framework in Copy frameworks */,
9507E9D10FC1CDCE00BD2B92 /* Ogg.framework in Copy frameworks */,
9507E9D20FC1CDCE00BD2B92 /* OpenAL.framework in Copy frameworks */,
);
@@ -423,7 +420,6 @@
954E4C2A0FF98B6E0047FE3E /* billboard_animation.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = billboard_animation.hpp; path = ../../animations/billboard_animation.hpp; sourceTree = SOURCE_ROOT; };
954E4C2B0FF98B6E0047FE3E /* three_d_animation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = three_d_animation.cpp; path = ../../animations/three_d_animation.cpp; sourceTree = SOURCE_ROOT; };
954E4C2C0FF98B6E0047FE3E /* three_d_animation.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = three_d_animation.hpp; path = ../../animations/three_d_animation.hpp; sourceTree = SOURCE_ROOT; };
9551C7F80FC1B63C00DB481B /* libintl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libintl.framework; path = /Library/Frameworks/libintl.framework; sourceTree = "<absolute>"; };
9551C7F90FC1B63C00DB481B /* Ogg.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Ogg.framework; path = /Library/Frameworks/Ogg.framework; sourceTree = "<absolute>"; };
9551C7FA0FC1B63C00DB481B /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = /Library/Frameworks/OpenAL.framework; sourceTree = "<absolute>"; };
9551C7FB0FC1B63C00DB481B /* Vorbis.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Vorbis.framework; path = /Library/Frameworks/Vorbis.framework; sourceTree = "<absolute>"; };
@@ -1094,7 +1090,6 @@
9551CBD50FC1BB7600DB481B /* GLUT.framework in Frameworks */,
9551CBD60FC1BB7600DB481B /* Cocoa.framework in Frameworks */,
9551CBD70FC1BB7600DB481B /* OpenGL.framework in Frameworks */,
9551C9F00FC1B7EE00DB481B /* libintl.framework in Frameworks */,
9551C9F10FC1B7EE00DB481B /* Ogg.framework in Frameworks */,
9551C9F20FC1B7EE00DB481B /* OpenAL.framework in Frameworks */,
9551C9F30FC1B7EE00DB481B /* Vorbis.framework in Frameworks */,
@@ -1160,7 +1155,6 @@
isa = PBXGroup;
children = (
9551CBD90FC1BB9200DB481B /* AGL.framework */,
9551C7F80FC1B63C00DB481B /* libintl.framework */,
9551C7F90FC1B63C00DB481B /* Ogg.framework */,
9551C7FA0FC1B63C00DB481B /* OpenAL.framework */,
9551C7FB0FC1B63C00DB481B /* Vorbis.framework */,

View File

@@ -38,8 +38,12 @@
#include "io/file_manager.hpp"
// set to 1 to debug i18n
#define TRANSLATE_VERBOSE 0
Translations* translations=NULL;
bool remove_bom = false;
// ----------------------------------------------------------------------------
Translations::Translations()
@@ -55,9 +59,20 @@ Translations::Translations()
setlocale(LC_MESSAGES, "");
#endif
bindtextdomain (PACKAGE, file_manager->getTranslationDir().c_str());
if (sizeof(wchar_t) == 4) bind_textdomain_codeset(PACKAGE, "UTF-32");
else if (sizeof(wchar_t) == 2) bind_textdomain_codeset(PACKAGE, "UTF-16LE");
else assert(false);
if (sizeof(wchar_t) == 4)
{
// FIXME: will probably not work on PPC maccs
bind_textdomain_codeset(PACKAGE, "UTF-32LE");
}
else if (sizeof(wchar_t) == 2)
{
bind_textdomain_codeset(PACKAGE, "UTF-16LE");
}
else
{
fprintf(stderr, "Your wchar_t is neither 2 byte-long nor 4. What now??\n");
exit(1);
}
textdomain (PACKAGE);
#endif
@@ -68,7 +83,9 @@ const wchar_t* Translations::w_gettext(const char* original)
{
if (original[0] == '\0') return L"";
#if TRANSLATE_VERBOSE
std::cout << "Translating " << original << "\n";
#endif
#if ENABLE_NLS
const char* original_t = gettext(original);
@@ -76,13 +93,42 @@ const wchar_t* Translations::w_gettext(const char* original)
m_converted_string = core::stringw(original);
return m_converted_string.c_str();
#endif
/*
std::cout << "--> original_t==original ? " << (original_t==original) << std::endl;
int zeros = 0;
for (int n=0;; n+=1)
{
std::cout << original_t[n] << " (" << (unsigned)(original_t[n]) << ")\n";
if (original_t[n] == 0)
{
zeros++;
if (zeros >= 4) break;
}
else
{
zeros = 0;
}
}*/
if(original_t==original)
{
m_converted_string = core::stringw(original);
#if TRANSLATE_VERBOSE
std::wcout << L" translation : " << m_converted_string.c_str() << std::endl;
#endif
return m_converted_string.c_str();
}
// print
//for (int n=0;; n+=4)
wchar_t* out_ptr = (wchar_t*)original_t;
//std::wcout << L" translation : " << out_ptr << std::endl;
if (remove_bom) out_ptr++;
#if TRANSLATE_VERBOSE
std::wcout << L" translation : " << out_ptr << std::endl;
#endif
return out_ptr;
}