For programming enthusiasts, the most embarrassing thing is that when executing the Chinese software they wrote, a prompt message pops up in English. This article introduces a quick and easy method to Chineseize the system prompt information in Delphi.
In Delphi, the source files (.pas) that define system resource string constants are placed in the /Source directory of the Delphi installation directory and are distributed in several subdirectories by their category, and their compiled unit files (. dcu) is placed in the /Lib directory of the Delphi installation directory. When the system compiles and links the application, it will automatically find the required string constants from these unit files to replace them. Therefore, we just need to Chineseize the prompt information string in the source file in the /Source directory, compile it into a unit file, and then copy the unit file to the /Lib directory, and overwrite the original unit file to achieve the purpose of Chineseization. When we need to Chineseize a prompt message, find the source file containing the prompt message and Chineseize the prompt message string.
First, create a new project in Delphi, which will automatically contain a form file named Unit1 and remove it from the project. Then select Project → Options from the menu. In the pop-up Project Options dialog box, select the Directories/Conditionals tag. The Unit output directory text box can specify the storage path of the unit file after the project is compiled. Fill in the /Lib directory here The complete path, in my system, this path is C:/Program Files/Borland/Delphi5/lib. Finally, save the project file and name it HanHua.dpr. At this point, this project file for Chineseization has been established. So, how can I start working with this project file? Next, I will use an example to illustrate the method of using it.
When using Delphi to compile an application software, after the software is compiled, a prompt message "Delete record?" appears at runtime. The steps for Chineseization are as follows:
1. Open the project file HanHua.dpr in Delphi.
2. Select menu Search → Find in Files, in the pop-up dialog box, enter the text to find: text box, here we enter "Delete record?", and then select Search in in the Where component box Directories, and enter the full path of the /Source directory in Search Directory Options, in my system the path is C:/Program Files/Borland/Delphi5/Source, and finally don't forget to select Include subdirectories and click "OK" The button starts searching.
3. A new window will be added at the bottom of the code editor to display all files containing the text you are looking for. In this example, only one file is found, and the "C:/Program Files/Borland/Delphi5/Source/Vcl /dbconsts.pas(100):SDeleteRecordQuestion=''Delete record?'';", double-click to open the file, the system will automatically move the cursor to "Delete record?" and change it to "Delete record?".
4. Select the menu Project → Add to Project. In the pop-up dialog box, the system will automatically use the currently opened file (dbconsts.pas here) as the default open file. You can directly click the "Open" button to add it to the project. middle.
5. Compile the project HanHua.dpr.
Finally, we just need to recompile the previous application software once, and the prompt message "Delete record?" becomes "Delete record?". How about it, is it fast and accurate to use this method to Chinese? However, because we directly modify the source file in the system directory, there are two problems. First, if there is an error during the modification process, the source file that can be referenced cannot be found; second, After reinstalling Delphi, all the results of Chineseization are gone. So we also need to make some improvements to the above Chineseization process. In fact, we only need to add the following steps between Steps 3 and Step 4 above:
Select the menu File→Save As, and in the pop-up dialog box, replace the file and save it to another directory.
After adding the above step, the two problems mentioned above were solved: the system source files were not modified, and the modified files were placed in our own directory; after reinstalling Delphi, just recompile the project HanHua .dpr can re-Chinese system prompt information from previous Chinese.