2
* Copyright (c) 2005 Massachusetts Institute of Technology
3
* Copyright (c) 2007 Secure Endpoints Inc.
5
* Permission is hereby granted, free of charge, to any person
6
* obtaining a copy of this software and associated documentation
7
* files (the "Software"), to deal in the Software without
8
* restriction, including without limitation the rights to use, copy,
9
* modify, merge, publish, distribute, sublicense, and/or sell copies
10
* of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
13
* The above copyright notice and this permission notice shall be
14
* included in all copies or substantial portions of the Software.
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
\page pi_localization Localization
31
If a module requires localized resources, it can register the
32
localized resource libraries with the module manager when it receives
33
the init_module() callback. Note that you can only register localized
34
resource libraries during init_module().
36
The localized resource library is global to a module. Each plug-in is
37
not allowed to define its own localization library, although it is
38
free to load and use any library as it sees fit. The module manager
39
does not manage these libraries for the plug-in.
41
\section pi_loc_spec Specification of localized resources
43
In order to register localized resource libraries, a module calls
44
kmm_set_locale_info(). The \a locales parameter to the function holds
45
a pointer to an array of ::kmm_module_locale records. Each record
46
specifies one language code and a filename of a library that holds the
47
language resources for that language.
49
It is recommended that you use the LOCALE_DEF convenience macro when
50
defining locale records for use with kmm_set_locale_info(). This will
51
ensure that future changes in the API will only minimally affect your
55
kmm_module_locale my_locales[] = {
56
LOCALE_DEF(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US), L"english.dll", KMM_MLOC_FLAG_DEFAULT),
57
LOCALE_DEF(MAKELANGID(LANG_DUTCH,SUBLANG_DUTCH), L"dutch.dll", 0),
58
LOCALE_DEF(MAKELANGID(LANG_SPANISH,SUBLANG_SPANISH_MODERN), L"spanish.dll", 0)
61
int n_locales = sizeof(my_locales)/sizeof(my_locales[0]);
65
kmm_set_locale_info(h_module, my_locales, n_locales);
70
See kmm_set_locale_info() and ::kmm_module_locale for more info.
72
\section pi_loc_how Selection of localized resource library
74
The module manager searches the array of ::kmm_module_locale objects
75
passed into the kmm_set_locale_info() function for one that matches
76
the current user locale (as opposed to the current system locale). A
77
record matches the locale if it has the same language ID.
79
If a match is found, that library is selected. Otherwise, the list is
80
searched for one that is compatible with the current user locale. A
81
locale record is compatible with the user locale if the primary
84
If a match is still not found, the first record in the locale array
85
that has the ::KMM_MLOC_FLAG_DEFAULT flag set will be selected.
87
If a match is still not found, then the kmm_set_locale_info() will
88
return ::KHM_ERROR_NOT_FOUND.
90
\section pi_loc_usage Using localization
92
The following convenience macros are available for using a module
93
handle to load resources from the corresponding resource library.
94
However, for performance reasons, it is advisable to obtain a handle
95
to the resource library loaded by the module manager using
96
kmm_get_resource_module() and then use it to access resources using
97
the regular WIN32 API.
99
- ::kmm_LoadAccelerators