EWL C++ predefines only two names: "
C"
and
"". However, other names sent to the locale constructor are interpreted as file names containing data to create a named locale. So localizing your program is as easy as creating a data file specifying the desired behavior. The format for this data file is outlined below for each different facet.
A
locale is a collection of
facets. And a
facet is a class that provides a certain behavior. The "
C"
locale contains the following
facets:
- ctype<char> & ctype<wchar_t>
- codecvt<char, char, mbstate_t> & codecvt<wchar_t, char, mbstate_t>
- num_get<char> & num_get<wchar_t>
- num_put<char> & num_put<wchar_t>
- numpunct<char> & numpunct<wchar_t>
- collate<char> & collate<wchar_t>
- time_get<char> & time_get<wchar_t>
- time_put<char> & time_put<wchar_t>
- money_get<char> & money_get<wchar_t>
- money_put<char> & money_put<wchar_t>
- moneypunct<char, bool> & moneypunct<wchar_t, bool>
- messages<char> & messages<wchar_t>
A
named locale replaces many of these facets with "
_byname"
versions, whose behavior can vary based on the name passed.
- ctype_byname<char> & ctype_byname<wchar_t>
- codecvt_byname<char, char, mbstate_t> & codecvt_byname<wchar_t, char, mbstate_t>
- numpunct_byname<char> & numpunct_byname<wchar_t>
- collate_byname<char> & collate_byname<wchar_t>
- time_get_byname<char> & time_get_byname<wchar_t>
- time_put_byname<char> & time_put_byname<wchar_t>
- moneypunct_byname<char, bool> & moneypunct_byname<wchar_t, bool>
- messages_byname<char> & messages_byname<wchar_t>
The behavior of each of these "
_byname" facets can be specified with a data file. A single data file can contain data for all of the byname facets. That way, when you code:
locale myloc("MyLocale");
then the file "
MyLocale" will be used for each "
_byname"
facet in
myloc.
Note: Unnamed namespaces are displayed using a compiler generated unique name that has the form: __unnamed_<filename> where <filename> is the source file name of the main translation unit that contains the unnamed namespace.