Localized Zhejiang University Computer System 344 Mail (310027) Zheng Jie Visual C (hereinafter referred to as the NC) is one of Microsoft's Visual Series Software Development Tools. For programmers in non-English areas, inevitably solve the localization problem of software. The VC itself supports multilingual programming, which brings great convenience to localization. Here we mainly discuss the localization of MFC-based components.
To achieve the localization of components that use MFC, you need to solve the following two problems. The first question is to realize localization of some special resources of the component itself, such as strings, dialogs, and more. Since most of the components of the architecture on the MFC also include and use a part of the resource defined by the MFC, these MFC resources must be localized. Fortunately, MFC itself has provided a localized version of a variety of languages, including: Chinese, German, Spanish, French, Italian, Japanese, and Korean. In the corresponding / devStudi / VC / MFC / [SRC | Include] /L.xxx/ directory in the VC CD, "L" represents "Localization", "L.chs" represents Simplified Chinese. Turn the * .rc file in these directories to the appropriate directory in the hard drive. This method should be used when the application is static linkage between the application and the MFC, but it is only supported in the professional version of VC 5.0. Most applications and MFCs use dynamic links, at this time, there must be a local version of the corresponding MFC resource DLL file in Win95 - MFC4XLoc.dll (PWIN95 OEMSR2 version is MFC0 Loc.dll) ). Copy the files in the directory / devStudio / VC / Redist: mfc42xxx.dll into the System directory of the PWI95 and renamed: mfc42loc.dll (where Mfc42chs.dll represents the resource DLL file of the Simplified Chinese version) . In addition to solving the version issues overwritten by the same name DLL, you should pay attention to the following two aspects: First, MFC4XLoc.dll should not be installed on the English version of the system (such as English Win95). Because the English version of the resource file code has been built in MFC4x.dll, the application loaded from the MFC4x.dll is much faster than the speed of searching the code prior to the MFC4XLOCD LL. Second, since there are multiple versions of MFC4XLoc.dll, you can find in the directory / devStudio / VC / Redist of the VC CD, such as: mfc4xchs.dll - Simplified Chinese version, mfc4xdeu.dll - Germany version, mfc4xesp.ll- - Italy version, etc. So before installing, you should first determine whether the local version code of the installed MFC4XLoc.dll is consistent with the WINDOW system used, for example: only MFC42chs.dll can be installed on the PWIN95 system. It should be noted that the above method will bring a certain complexity to the installation of the application, as the user's system may have a variety of localized version of the application. For example: support Simplified Chinese; later installed a Japanese version of the software and link library files MFC4XLoc.dll only one, if the latter covers the former, the application is running out of the resource link error. So we recommend using another way to build your own local version of the MFC resource DLL file instead of calling the MFC4XLoc.dll file directly. This method will continue to analyze.
The second problem for processing code is that the code should be handled in the localized resources of each component, so that it can work well in the target environment. In most cases, this depends on the application ability of the application to the height of the byte and the processing capabilities of the double-byte character. By default, MFC supports them. Therefore, localized applications and DLLs are essentially required to change the corresponding resources with local languages. If you do not have a localized string or body in the C source code, you only need to modify the resource file. In fact, users can achieve their own components, so you don't need to rebuild the original code to get local version. This may be complicated, but it is worth it, and the MFC itself uses this technology. Open the resource file editor to edit directly with local languages, but so that each version of the upgrade needs to be rebuilt. Note: VC 4.0 or later version directly supports .rc files in multiple languages. One way to avoid this is to establish an isolated DLL and localize it, and the DLL is sometimes called "satellite DLL". It will be dynamically linked during operation, at which time the resource will be loaded from this "satellite DLL" instead of loading from the master module. The MFC directly supports this method, and the MFC4XLoc.dll itself is a localized "satellite DLL", which is only provided by the MFC under the default condition. We can build a "satellite DLL", such as a MyApp.exe application, all of its resources come from a file called myres.dll. These are done in the initInstance events of their applications, as shown below: CMYApp :: InitInstance () {// Initial Code start section Hinstance Hinst = LoadLibrary ("MyRes.dll"); if (hinst! = Null) AFXSetResourceHandle (HINST); // The following is the other initialization code ...} After this code is executed, the MFC will load resources from MyRes.dll, not directly from MyApp.exe. It is not difficult to build a single resource DLL file. First create a DLL project file, join .rc files and other necessary resources, then add a "/ noentry" parameter in the Linker parameter. This parameter tells the linker that the DLL does not have an access point because the resource DLL file has no code. In addition, if the application is established in Win32 Release (ie, the debug code is not embedded in the EXE file), the following steps are required. In the project file, open the menu Projects / Settings ..., select the C / C page and the R Esources page, remove the parameters [/ d "_afxdll"] (it is typically generated automatically by AppWizard). This parameter specifies that the resources are only loaded only from the MFC's shared DLL file, and other resources are not defined so that the user's own resource DLL file will not work. Finally, because AppWizard is a major feature of VC , VC allows you to select a different language when you create an MFC-based application framework, directly generate localized program frameworks. Among them, Korean and Simplified Chinese, because of the need to support the two-byte version of the operating system, the MFC AppWizard DLLS corresponding to these three Far East language is not loaded with the VC 5.0 installer in the default. Therefore, in the first page of the application generation wizard, these language entries are not found, but they can be found in the VC CD / DevStudio / Sharedide / Bi / IDE directory: Language AppWizard DLL ----- ------------------------------- Japanese ---- Appwzjpn.dll Korean ---- Appwzkor.dll Simplified Chinese - - AppWZCHS.DLL Under Simplified Chinese PWIN95, simply copy the corresponding AppWZCHS.DLL file from the VC CD into the / devsudio / shareIDE / BIN / IDE directory.