Task: there is a simple SWT window, such:
Perform localization.
The development tool used is eclipse 3.7.
1. Select the one corresponding to the preceding window. java file (mainframe in this example. java), right-click, and select Source-externalize strings in sequence. In the displayed dialog box, keep the default state, select next, and then click Finish. Two files are generated: messages. java and messages. properties.
The content in messages. properties is as follows:
View Source
Print?
1 |
MainFrame_0=/javax/swing/plaf/basic/icons/JavaCup16.png |
2 |
MainFrame_1=Student Information |
2. Copy the messages. properties file to the bin folder in JDK on your computer. For example, I put it in the D: \ Program Files \ Java \ jdk1.6.0 _ 25 \ bin directory.
3. Open the messages. properties file in the bin directory in notepad and replace the English words after "=" with the desired Chinese characters. After replacement, the content is as follows:
View Source
Print?
1 |
MainFrame_0=/javax/swing/plaf/basic/icons/JavaCup16.png |
2 |
Mainframe_1 = Student Information |
5 |
Mainframe_4 = student ID |
(Note:/javax/swing/plaf/basic/icons/javacup16.png indicates a path, regardless of which)
4. Next is a key step. Select Start-run, Enter cmd, and open the command window. The command to be entered is as follows:
Press enter to generate a newmessages. properties file with the following content:
View Source
Print?
1 |
MainFrame_0=/javax/swing/plaf/basic/icons/JavaCup16.png |
2 |
MainFrame_1=\u5b66\u751f\u4fe1\u606f |
3 |
MainFrame_2=\u59d3\u540d |
4 |
MainFrame_3=\u6027\u522b |
5 |
MainFrame_4=\u5b66\u53f7 |
6 |
MainFrame_5=\u73ed\u7ea7 |
5. Replace the messages. properties file in the Eclipse project with the above content and save it. Run the program. The effect is as follows: