wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth ./Makefile.am ./changelog ./configure.a...


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth ./Makefile.am ./changelog ./configure.a...
Date: Sat, 23 Apr 2005 13:09:48 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    05/04/23 17:09:48

Modified files:
        .              : Makefile.am changelog configure.ac 
        src            : language.cpp 

Log message:
        Make the installer generate locale files, and use them in language.cpp. 
The code is rather experimental, but it is disabled by default: it requires a 
configure option. So it isn't a release-stopper. The autostuff would benefit 
from some tidying by an expert.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/Makefile.am.diff?tr1=1.31&tr2=1.32&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/changelog.diff?tr1=1.612&tr2=1.613&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/configure.ac.diff?tr1=1.141&tr2=1.142&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/language.cpp.diff?tr1=1.85&tr2=1.86&r1=text&r2=text

Patches:
Index: wesnoth/Makefile.am
diff -u wesnoth/Makefile.am:1.31 wesnoth/Makefile.am:1.32
--- wesnoth/Makefile.am:1.31    Thu Apr 21 18:18:16 2005
+++ wesnoth/Makefile.am Sat Apr 23 17:09:48 2005
@@ -32,6 +32,13 @@
          echo " $(install_sh_DATA) '$$d$$p' '$(DESTDIR)$(pkgdatadir)/$$f'"; \
          $(install_sh_DATA) "$$d$$p" "$(DESTDIR)$(pkgdatadir)/$$f"; \
        done
+if DUMMYLOCALES
+       $(mkdir_p) "$(DESTDIR)$(pkgdatadir)/locales"; \
+       echo | localedef --force "$(DESTDIR)$(pkgdatadir)/locales/C" 2> 
/dev/null; \
+       for loc in `sed -n 's/^.*language_def..\(.._..\).*$$/\1/p' 
"$(srcdir)/src/language.cpp"`; do \
+         ln -s C "$(DESTDIR)$(pkgdatadir)/locales/$$loc"; done; \
+       true
+endif
 if TINYGUI
        (cd $(top_srcdir) && find images images/terrain \( $(findfilterflags) 
-o -name '*.png' -print \) ) | while read p; do \
          $(w_preparefileinstall) \
Index: wesnoth/changelog
diff -u wesnoth/changelog:1.612 wesnoth/changelog:1.613
--- wesnoth/changelog:1.612     Fri Apr 22 19:19:20 2005
+++ wesnoth/changelog   Sat Apr 23 17:09:48 2005
@@ -44,6 +44,9 @@
      * Japanese
      * Slovenian
      * Swedish
+   * added a ./configure --with-dummy-locales option for Wesnoth to generate
+     its own set of i18n locale files and use them instead of the potentially
+     missing system files (highly experimental)
  * fixed the missing 'elder-mage-halo7.png' in the Elder Mage
  * fixed some OoS errors when chatting while a fight is taking place
  * fixed the spurious "statistics verification failed" messages
Index: wesnoth/configure.ac
diff -u wesnoth/configure.ac:1.141 wesnoth/configure.ac:1.142
--- wesnoth/configure.ac:1.141  Sun Apr 10 22:13:20 2005
+++ wesnoth/configure.ac        Sat Apr 23 17:09:48 2005
@@ -37,7 +37,7 @@
 EOF
 ])
 
-AC_REVISION([$Revision: 1.141 $])
+AC_REVISION([$Revision: 1.142 $])
 
 AC_CONFIG_AUX_DIR([config])
 AC_CONFIG_SRCDIR([src/actions.cpp])
@@ -217,6 +217,11 @@
              [wzip=$enableval],
              [wzip=no])
 
+AC_ARG_ENABLE([dummy-locales],
+              AS_HELP_STRING([--enable-dummy-locales], [enable installation of 
Wesnoth own provate locales]),
+              [dummylocales=$enableval],
+              [dummylocales=no])
+
 AM_CONDITIONAL([STATIC], [test x$static = xyes])
 AM_CONDITIONAL([GAME], [test x$game = xyes])
 AM_CONDITIONAL([SERVER], [test x$server = xyes])
@@ -227,6 +232,11 @@
 AM_CONDITIONAL([WZIP], [test x$wzip = xyes])
 AM_CONDITIONAL([INCLUDEDINTL], [test x$nls_cv_use_gnu_gettext = xyes])
 AM_CONDITIONAL([INSTALLDATA], [test x$game = xyes || x$editor = xyes])
+AM_CONDITIONAL([DUMMYLOCALES], [test x$dummylocales = xyes])
+
+if test x$dummylocales = xyes; then
+  AC_DEFINE([USE_DUMMYLOCALES],,[Define if the game should not use system 
locales])
+fi
 
 #######################################################################
 # Checks for programs.                                                #
Index: wesnoth/src/language.cpp
diff -u wesnoth/src/language.cpp:1.85 wesnoth/src/language.cpp:1.86
--- wesnoth/src/language.cpp:1.85       Sun Apr 17 18:53:10 2005
+++ wesnoth/src/language.cpp    Sat Apr 23 17:09:48 2005
@@ -1,4 +1,4 @@
-/* $Id: language.cpp,v 1.85 2005/04/17 18:53:10 gruikya Exp $ */
+/* $Id: language.cpp,v 1.86 2005/04/23 17:09:48 silene Exp $ */
 /* vim:set encoding=utf-8: */
 /*
    Copyright (C) 2003 by David White <address@hidden>
@@ -16,12 +16,14 @@
 
 #include "config.hpp"
 #include "filesystem.hpp"
+#include "game_config.hpp"
 #include "gettext.hpp"
 #include "language.hpp"
 #include "preferences.hpp"
 #include "util.hpp"
 #include "serialization/parser.hpp"
 #include "serialization/preprocessor.hpp"
+#include "wesconfig.h"
 
 #include <algorithm>
 #include <cctype>
@@ -118,8 +120,9 @@
        return res;
 }
 
-char* wesnoth_setlocale(int category, const char *locale)
+static void wesnoth_setlocale(int category, std::string const &slocale)
 {
+       char const *locale = slocale.c_str();
 #ifdef __BEOS__
        if(setenv ("LANG", locale, 1) == -1)
                std::cerr << "setenv LANG failed: " << strerror(errno);
@@ -134,15 +137,29 @@
 #endif 
 
 #ifdef _WIN32
-       const std::string env = std::string("LANG=") + locale;
+       const std::string env = "LANG=" + slocale;
        putenv(env.c_str());
 #endif
 
+#ifdef USE_DUMMYLOCALES
+       static enum { UNINIT, NONE, PRESENT } status = UNINIT;
+       static std::string locpath;
+       if (status == UNINIT)
+               if (char const *p = getenv("LOCPATH")) {
+                       locpath = p;
+                       status = PRESENT;
+               } else status = NONE;
+       if (slocale.empty())
+               if (status == NONE)
+                       unsetenv("LOCPATH");
+               else
+                       setenv("LOCPATH", locpath.c_str(), 1);
+       else setenv("LOCPATH", (game_config::path + "/locales").c_str(), 1);
+#endif
        char* res = setlocale (category, locale);
        if (res == NULL)
                std::cerr << "WARNING: setlocale() failed for "
                          << locale << ".\n";
-       return res;
 }
 
 bool set_language(const language_def& locale)
@@ -156,7 +173,7 @@
        config cfg;
 
        current_language = locale;
-       wesnoth_setlocale (LC_MESSAGES, locale.localename.c_str());
+       wesnoth_setlocale(LC_MESSAGES, locale.localename);
        known_languages[0].language = gettext("System default language");
 
        // fill string_table (should be moved somwhere else some day)
@@ -190,15 +207,12 @@
 
        const std::string& prefs_locale = preferences::language();
        if(prefs_locale.empty() == false) {
-               char* setlocaleres = wesnoth_setlocale (LC_MESSAGES, 
prefs_locale.c_str());
-               if(setlocaleres == NULL)
-                       std::cerr << "call to setlocale() failed for " << 
prefs_locale.c_str() << "\n";
+               wesnoth_setlocale(LC_MESSAGES, prefs_locale);
                for(int i = 0; known_languages[i].language[0] != '\0'; i++) {
                        if (prefs_locale == known_languages[i].localename)
                                return known_languages[i];
                }
-               
-               std::cerr << "setlocale succeeded but locale not found in known 
array; defaulting to system locale\n";
+               std::cerr << "locale not found in known array; defaulting to 
system locale\n";
                return known_languages[0];
        }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]