Software: Apache/2.0.54 (Fedora). PHP/5.0.4 uname -a: Linux mina-info.me 2.6.17-1.2142_FC4smp #1 SMP Tue Jul 11 22:57:02 EDT 2006 i686 uid=48(apache) gid=48(apache) groups=48(apache) Safe-mode: OFF (not secure) /usr/share/doc/libstdc++-devel-4.0.2/html/22_locale/ drwxr-xr-x |
Viewing file: Select action/file-type: Notes on the messages implementation.prepared by Benjamin Kosnik (bkoz@redhat.com) on August 8, 20011. AbstractThe std::messages facet implements message retrieval functionality equivalent to Java's java.text.MessageFormat .using either GNU gettext or IEEE 1003.1-200 functions. 2. What the standard saysThe std::messages facet is probably the most vaguely defined facet in the standard library. It's assumed that this facility was built into the standard library in order to convert string literals from one locale to the other. For instance, converting the "C" locale'sconst char* c = "please" to a German-localized "bitte"
during program execution.
22.2.7.1 - Template class messages [lib.locale.messages]This class has three public member functions, which directly correspond to three protected virtual member functions. The public member functions are:
While the virtual functions are:
-1- Returns: A value that may be passed to get() to retrieve a message, from the message catalog identified by the string name according to an implementation-defined mapping. The result can be used until it is passed to close(). Returns a value less than 0 if no such catalog can be opened.
-3- Requires: A catalog cat obtained from open() and not yet closed. -4- Returns: A message identified by arguments set, msgid, and dfault, according to an implementation-defined mapping. If no such message can be found, returns dfault.
-5- Requires: A catalog cat obtained from open() and not yet closed. -6- Effects: Releases unspecified resources associated with cat. -7- Notes: The limit on such resources, if any, is implementation-defined. 3. Problems with "C" messages: thread safety, over-specification, and assumptions.A couple of notes on the standard.
First, why is
Second, by making the member functions
The 'open' member function in particular seems to be oddly
designed. The signature seems quite peculiar. Why specify a Lastly, it seems odd that messages, which explicitly require code conversion, don't use the codecvt facet. Because the messages facet has only one template parameter, it is assumed that ctype, and not codecvt, is to be used to convert between character sets. It is implicitly assumed that the locale for the default message string in 'get' is in the "C" locale. Thus, all source code is assumed to be written in English, so translations are always from "en_US" to other, explicitly named locales. 4. Design and Implementation DetailsThis is a relatively simple class, on the face of it. The standard specifies very little in concrete terms, so generic implementations that are conforming yet do very little are the norm. Adding functionality that would be useful to programmers and comparable to Java's java.text.MessageFormat takes a bit of work, and is highly dependent on the capabilities of the underlying operating system.Three different mechanisms have been provided, selectable via configure flags:
A new, standards-conformant non-virtual member function signature was added for 'open' so that a directory could be specified with a given message catalog. This simplifies calling conventions for the gnu model. The rest of this document discusses details of the GNU model.
The messages facet, because it is retrieving and converting between
characters sets, depends on the ctype and perhaps the codecvt facet in
a given locale. In addition, underlying "C" library locale support is
necessary for more than just the Making the message catalogs can be initially tricky, but become quite simple with practice. For complete info, see the gettext documentation. Here's an idea of what is required:
5. Examples
6. Unresolved Issues
7. AcknowledgmentsUlrich Drepper for the character set explanations, gettext details, and patient answering of late-night questions, Tom Tromey for the java details.8. Bibliography / Referenced DocumentsDrepper, Ulrich, GNU libc (glibc) 2.2 manual. In particular, Chapters "7 Locales and Internationalization"Drepper, Ulrich, Thread-Aware Locale Model, A proposal. This is a draft document describing the design of glibc 2.3 MT locale functionality. Drepper, Ulrich, Numerous, late-night email correspondence ISO/IEC 9899:1999 Programming languages - C ISO/IEC 14882:1998 Programming languages - C++ Java 2 Platform, Standard Edition, v 1.3.1 API Specification. In particular, java.util.Properties, java.text.MessageFormat, java.util.Locale, java.util.ResourceBundle. http://java.sun.com/j2se/1.3/docs/api System Interface Definitions, Issue 7 (IEEE Std. 1003.1-200x) The Open Group/The Institute of Electrical and Electronics Engineers, Inc. In particular see lines 5268-5427. http://www.opennc.org/austin/docreg.html GNU gettext tools, version 0.10.38, Native Language Support Library and Tools. http://sources.redhat.com/gettext Langer, Angelika and Klaus Kreft, Standard C++ IOStreams and Locales, Advanced Programmer's Guide and Reference, Addison Wesley Longman, Inc. 2000. See page 725, Internationalized Messages. Stroustrup, Bjarne, Appendix D, The C++ Programming Language, Special Edition, Addison Wesley, Inc. 2000 |
:: Command execute :: | |
--[ c99shell v. 1.0 pre-release build #16 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0028 ]-- |