Localizing UI Text
From Multiverse
| User Interface Development |
|
Overview • Managing Widgets • Event Handling • Using Widget Templates • Customizing Key Bindings • Localizing UI Text • Character Creation Framework • Minimap Component • Scripting Avatar Appearance |
| Reference |
| Tutorials |
|
Hello World • Creating a Button • Creating a Menu • Creating a Help Dialog • Using Radio Buttons |
Contents |
Overview
The Multiverse Client can display international characters as well as standard ASCII characters.
To make enable international character display, do the following:
- Modify
Interface\FrameXML\MvFonts.xmlfile in your asset repository as described below. - Add a command to make the server to send the localized characters to the client
- Test
Modifying font XML file
In Interface\FrameXML\MvFonts.xml file, there is an entry that defines the ChatFont as follows:
<FontString name="ChatFont" font="Fonts\MUFN____.TTF" virtual="true">
<FontHeight>
<AbsValue val="16"/>
</FontHeight>
<Color r="1.0" g="1.0" b="1.0"/>
</FontString>
To make the client use a different font with more characters, do the following:
- Place the font that contains the characters you wish to display in the
Fontsfolder of your asset repository. - Change the XML that defines the font template to reference this font (for example,
SIMHEI.TTF), and generate characters for 65536 unicode characters (with thebytesattribute).
Here is an example:
<FontString name="ChatFont" font="Fonts\SIMHEI.TTF" bytes="65536" virtual="true">
<FontHeight>
<AbsValue val="16"/>
</FontHeight>
<Color r="1.0" g="1.0" b="1.0"/>
</FontString>
Now the client will display international characters.
Modifying old chat frame XML file
Older versions of MvChat.xml explicitly limited the character set to 256 bytes. The older version had the following line:
<FontString inherits="ChatFont" bytes="256">
The bytes argument should be removed so that the line is:
<FontString inherits="ChatFont">
Sending international characters to the client
The make the server to send the localized characters to the client, add the following to extensions_proxy.py in your world directory on the server:
class TestFontCommand(ProxyPlugin.CommandParser):
def parse(self, cmdEvent):
playerOid = cmdEvent.getObjectOid()
WorldManagerClient.sendObjChatMsg(playerOid, 1, u"你好!")
Log.debug("/testfont: oid=" + str(playerOid))
return None
proxyPlugin.registerCommand("/testfont", TestFontCommand())
Be sure to precde the Python string with the u character to indicate that the string is Unicode.
Also be sure that extensions_proxy.py is saved using UTF-8. Unfortunately, Jython does not support the UTF-8 signature that is usually placed at the beginning of the file, so this may need to be removed.
Testing
Launch the client, connect to the server, and send a /testfont command. You should see the appropriate response.
