gettext markup of library sources
Phil Edwards
phil@jaj.com
Sun Apr 20 23:19:00 GMT 2003
This is going to happen at some point, why not start now? :-) See, for
example, docs/html/22_locale/messages.html, number 4, paragraph "Making
the message catalogs", and number 6, "At some point in the near future".
The point of this email: There are a number of places in the library where
we have error messages which ought to be localized. The sooner we get
those strings into the libstdc++.pot file, the sooner they can be translated.
I'd like to start noting the string literals so that xgettext can find them
easily. Elsewhere this has been done with (essentially)
#define _(x) gettext(x)
#define N(x) (x)
An example patch follows for discussion. Mainly I'm hoping to talk about
good names for the wrapper macros. They need to be short. "_" and "N"
are traditional. We can't actually use _N like I've noted below; it's in
the BADNAMES list for Solaris.
Note that, as shown below, I'm /not/ proposing we actually use gettext()
yet. That will require some configury magic, and is probably best left
for post-3.3.
Index: include/bits/c++config
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/libstdc++-v3/include/bits/c++config,v
retrieving revision 1.704
diff -u -r1.704 c++config
--- include/bits/c++config 20 Apr 2003 00:17:05 -0000 1.704
+++ include/bits/c++config 20 Apr 2003 23:11:45 -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) (__msgid)
+#define _N(__msgid) (__msgid)
+#define gettext_noop(__msgid) (__msgid)
+
// End of prewritten config; the discovered settings follow.
Index: include/std/std_bitset.h
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/libstdc++-v3/include/std/std_bitset.h,v
retrieving revision 1.13
diff -u -3 -r1.13 std_bitset.h
--- include/std/std_bitset.h 15 Apr 2003 06:11:10 -0000 1.13
+++ include/std/std_bitset.h 18 Apr 2003 03:05:30 -0000
@@ -264,7 +264,7 @@
{
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(_("bitset -- too large to fit in unsigned long"));
return _M_w[0];
}
@@ -466,7 +466,7 @@
// 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(_("bitset -- zero-length")); return *new _WordT; }
_WordT
_M_hiword() const { return 0; }
@@ -862,7 +862,7 @@
set(size_t __pos, bool __val = true)
{
if (__pos >= _Nb)
- __throw_out_of_range("bitset -- set() argument too large");
+ __throw_out_of_range(_("bitset -- set() argument too large"));
return _Unchecked_set(__pos, __val);
}
@@ -887,7 +887,7 @@
reset(size_t __pos)
{
if (__pos >= _Nb)
- __throw_out_of_range("bitset -- reset() argument too large");
+ __throw_out_of_range(_("bitset -- reset() argument too large"));
return _Unchecked_reset(__pos);
}
@@ -911,7 +911,7 @@
flip(size_t __pos)
{
if (__pos >= _Nb)
- __throw_out_of_range("bitset -- flip() argument too large");
+ __throw_out_of_range(_("bitset -- flip() argument too large"));
return _Unchecked_flip(__pos);
}
@@ -1014,7 +1014,7 @@
test(size_t __pos) const
{
if (__pos >= _Nb)
- __throw_out_of_range("bitset -- test() argument too large");
+ __throw_out_of_range(_("bitset -- test() argument too large"));
return _Unchecked_test(__pos);
}
More information about the Libstdc++
mailing list