This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: gettext markup of library sources
Once you put this in, I can go through and standardize all the strings.
>Let's start with this patch, which lays groundwork but changes no behavior
>outside of bitset error conditions. Also, there's a helper rule added to
>po/Makefile.am to regenerate the .pot file, but I didn't actually run it
>because it's incomplete.
Looks ok. Some minor nits.
>The location of the "_" macro is debatable. With this patch we'd only be
>using it in funcexcept.cc, so that's where I have it. Which means in turn
>that we could just use "gettext" directly, and #define that as a no-op
>macro when libintl.h is missing. I don't much care either way.
I like the way you have it. No sense splatting these defines all over
the place in c++config.h if you just need them in one file...
>
>Index: configure.in
>===================================================================
>RCS file: /cvs/gcc/gcc/libstdc++-v3/configure.in,v
>retrieving revision 1.122
>diff -u -3 -p -r1.122 configure.in
>--- configure.in 23 Apr 2003 22:31:44 -0000 1.122
>+++ configure.in 24 Apr 2003 21:11:07 -0000
>@@ -401,7 +401,7 @@ else
> # Check for available headers.
> AC_CHECK_HEADERS([nan.h ieeefp.h endian.h sys/isa_defs.h machine/endian.h \
> machine/param.h sys/machine.h fp.h locale.h float.h inttypes.h gconv.h \
>- sys/types.h])
>+ sys/types.h libintl.h])
>
> GLIBCPP_CHECK_COMPILER_FEATURES
> GLIBCPP_CHECK_LINKER_FEATURES
>Index: include/bits/c++config
>===================================================================
>RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/c++config,v
>retrieving revision 1.708
>diff -u -3 -p -r1.708 c++config
>--- include/bits/c++config 24 Apr 2003 00:17:06 -0000 1.708
>+++ include/bits/c++config 24 Apr 2003 21:11:07 -0000
>@@ -97,4 +97,11 @@
> # define _GLIBCPP_FAST_MATH 0
> #endif
>
>+// XXX These are only placeholders. They let people mark up the library
>+// sources without breaking things, and will be probably be somewhere else
>+// once localization of the library itself is functioning.
>+//#define _(msgid) gettext (msgid)
>+//#define _(msgid) (msgid)
>+#define __N(msgid) (msgid)
>+
> // End of prewritten config; the discovered settings follow.
>Index: include/std/std_bitset.h
>===================================================================
>RCS file: /cvs/gcc/gcc/libstdc++-v3/include/std/std_bitset.h,v
>retrieving revision 1.13
>diff -u -3 -p -r1.13 std_bitset.h
>--- include/std/std_bitset.h 15 Apr 2003 06:11:10 -0000 1.13
>+++ include/std/std_bitset.h 24 Apr 2003 21:11:07 -0000
>@@ -264,7 +264,7 @@ namespace std
> {
> for (size_t __i = 1; __i < _Nw; ++__i)
> if (_M_w[__i])
>- __throw_overflow_error("bitset -- too large to fit in unsigned long");
>+ __throw_overflow_error(__N("bitset value is too large to fit in unsigned long"));
> return _M_w[0];
> }
>
>@@ -466,7 +466,7 @@ namespace std
> // localized to this single should-never-get-this-far function.
> _WordT&
> _M_getword(size_t) const
>- { __throw_out_of_range("bitset -- zero-length"); return *new _WordT; }
>+ { __throw_out_of_range(__N("bitset is zero-length")); return *new _WordT; }
>
> _WordT
> _M_hiword() const { return 0; }
>@@ -862,7 +862,7 @@ namespace std
> set(size_t __pos, bool __val = true)
> {
> if (__pos >= _Nb)
>- __throw_out_of_range("bitset -- set() argument too large");
>+ __throw_out_of_range(__N("bitset::set() argument too large"));
> return _Unchecked_set(__pos, __val);
> }
>
>@@ -887,7 +887,7 @@ namespace std
> reset(size_t __pos)
> {
> if (__pos >= _Nb)
>- __throw_out_of_range("bitset -- reset() argument too large");
>+ __throw_out_of_range(__N("bitset::reset() argument too large"));
> return _Unchecked_reset(__pos);
> }
>
>@@ -911,7 +911,7 @@ namespace std
> flip(size_t __pos)
> {
> if (__pos >= _Nb)
>- __throw_out_of_range("bitset -- flip() argument too large");
>+ __throw_out_of_range(__N("bitset::flip() argument too large"));
> return _Unchecked_flip(__pos);
> }
>
>@@ -1014,7 +1014,7 @@ namespace std
> test(size_t __pos) const
> {
> if (__pos >= _Nb)
>- __throw_out_of_range("bitset -- test() argument too large");
>+ __throw_out_of_range(__N("bitset::test() argument too large"));
> return _Unchecked_test(__pos);
> }
>
>Index: po/Makefile.am
>===================================================================
>RCS file: /cvs/gcc/gcc/libstdc++-v3/po/Makefile.am,v
>retrieving revision 1.6
>diff -u -3 -p -r1.6 Makefile.am
>--- po/Makefile.am 7 Jan 2002 18:57:06 -0000 1.6
>+++ po/Makefile.am 24 Apr 2003 21:11:07 -0000
>@@ -22,6 +22,7 @@
> ## USA.
>
> PACKAGE = @PACKAGE@
>+glibcpp_srcdir = @glibcpp_srcdir@
>
> # Location of installation directories.
> mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
>@@ -76,6 +77,14 @@ install-data-local-yes: all-local-yes
> $(mkinstalldirs) $$install_dir; \
> $(INSTALL_DATA) $$cat $$install_dir/$(PACKAGE).mo; \
> done
>+
>+# Maintainence of the .po template file. This rule is never run automatically,
>+# and updates the source directory.
>+pot:
>+ cd $(glibcpp_srcdir); \
>+ xgettext --default-domain=$(PACKAGE) --add-comments --c++ --debug \
>+ --join-existing -o po/$(PACKAGE).pot --keyword=__N \
>+ `grep -r -l '__N(".*")' .`
>
> # Specify what gets cleaned up on a 'make clean'
> CLEANFILES = $(LOCALE_OUT)
>Index: src/functexcept.cc
>===================================================================
>RCS file: /cvs/gcc/gcc/libstdc++-v3/src/functexcept.cc,v
>retrieving revision 1.3
>diff -u -3 -p -r1.3 functexcept.cc
>--- src/functexcept.cc 13 Feb 2002 18:29:11 -0000 1.3
>+++ src/functexcept.cc 24 Apr 2003 21:11:07 -0000
>@@ -1,4 +1,4 @@
>-// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
>+// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
> //
> // This file is part of the GNU ISO C++ Library. This library is free
> // software; you can redistribute it and/or modify it under the
>@@ -32,6 +32,12 @@
> #include <new>
> #include <typeinfo>
> #include <ios>
>+#ifdef _GLIBCPP_HAVE_LIBINTL_H
>+# include <libintl.h>
>+# define _(msgid) gettext (msgid)
>+#else
>+# define _(msgid) (msgid)
>+#endif
>
> namespace std
> {
>@@ -54,43 +60,43 @@ namespace std
>
> void
> __throw_logic_error(const char* __s)
>- { throw logic_error(__s); }
>+ { throw logic_error(_(__s)); }
>
> void
> __throw_domain_error(const char* __s)
>- { throw domain_error(__s); }
>+ { throw domain_error(_(__s)); }
>
> void
> __throw_invalid_argument(const char* __s)
>- { throw invalid_argument(__s); }
>+ { throw invalid_argument(_(__s)); }
>
> void
> __throw_length_error(const char* __s)
>- { throw length_error(__s); }
>+ { throw length_error(_(__s)); }
>
> void
> __throw_out_of_range(const char* __s)
>- { throw out_of_range(__s); }
>+ { throw out_of_range(_(__s)); }
>
> void
> __throw_runtime_error(const char* __s)
>- { throw runtime_error(__s); }
>+ { throw runtime_error(_(__s)); }
>
> void
> __throw_range_error(const char* __s)
>- { throw range_error(__s); }
>+ { throw range_error(_(__s)); }
>
> void
> __throw_overflow_error(const char* __s)
>- { throw overflow_error(__s); }
>+ { throw overflow_error(_(__s)); }
>
> void
> __throw_underflow_error(const char* __s)
>- { throw underflow_error(__s); }
>+ { throw underflow_error(_(__s)); }
>
> void
> __throw_ios_failure(const char* __s)
>- { throw ios_base::failure(__s); }
>+ { throw ios_base::failure(_(__s)); }
> #else
> void
> __throw_bad_exception(void)
>Index: config.h.in
>===================================================================
>RCS file: /cvs/gcc/gcc/libstdc++-v3/config.h.in,v
>retrieving revision 1.63
>diff -u -3 -p -r1.63 config.h.in
>--- config.h.in 17 Apr 2003 03:26:54 -0000 1.63
>+++ config.h.in 24 Apr 2003 21:11:05 -0000
>@@ -731,6 +731,9 @@
> /* Define if you have the <inttypes.h> header file. */
> #undef HAVE_INTTYPES_H
>
>+/* Define if you have the <libintl.h> header file. */
>+#undef HAVE_LIBINTL_H
>+
> /* Define if you have the <locale.h> header file. */
> #undef HAVE_LOCALE_H
>