[Jsxe-cvs] SF.net SVN: jsxe: [1022] trunk/jsxe
Status: Inactive
Brought to you by:
ian_lewis
From: <ian...@us...> - 2006-07-12 20:07:52
|
Revision: 1022 Author: ian_lewis Date: 2006-07-12 13:07:44 -0700 (Wed, 12 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1022&view=rev Log Message: ----------- Messages loads messages files in UTF-8 Modified Paths: -------------- trunk/jsxe/Changelog trunk/jsxe/messages/messages trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java Modified: trunk/jsxe/Changelog =================================================================== --- trunk/jsxe/Changelog 2006-07-12 17:53:33 UTC (rev 1021) +++ trunk/jsxe/Changelog 2006-07-12 20:07:44 UTC (rev 1022) @@ -5,6 +5,7 @@ action is updated. This is a bug that is fixed in the beta for Java 6 but obviously it can't wait that long. * Renamed EnhancedMenu to WrappingMenu. I think it's more descriptive. + * Updated messages to load the messages files in UTF-8 07/10/2006 Ian Lewis <Ian...@me...> Modified: trunk/jsxe/messages/messages =================================================================== --- trunk/jsxe/messages/messages 2006-07-12 17:53:33 UTC (rev 1021) +++ trunk/jsxe/messages/messages 2006-07-12 20:07:44 UTC (rev 1022) @@ -25,6 +25,11 @@ common.find=Find... common.findnext=Find Next +common.ctrl=Ctrl +common.alt=Alt +common.shift=Shift +common.meta=Meta + #}}} #{{{ XML Terminology Modified: trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java =================================================================== --- trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java 2006-07-12 17:53:33 UTC (rev 1021) +++ trunk/jsxe/src/net/sourceforge/jsxe/gui/Messages.java 2006-07-12 20:07:44 UTC (rev 1022) @@ -75,10 +75,6 @@ public class Messages { //{{{ Private static members - /* - TODO: Properties files save and load in ISO 8859-1. This is unacceptable. - Need a UTF-8 way to load properties. - */ /** * properties containing the messages for jsXe */ @@ -88,8 +84,13 @@ */ private static Properties m_pluginMessages; + static { + // Locale.setDefault(new Locale("sv")); + Locale.setDefault(Locale.GERMANY); + } private static Locale m_locale = Locale.getDefault(); + private static boolean initialized = false; private static boolean plugins_initialized = false; @@ -124,6 +125,7 @@ String messagesFile = getMessagesFileName(locale); try { + Properties props = new Properties(); //create input stream from messages file FileInputStream in = new FileInputStream(jsXe.getInstallDirectory()+ @@ -132,12 +134,23 @@ System.getProperty("file.separator")+ messagesFile); - Properties props = new Properties(); - Log.log(Log.NOTICE, Messages.class, "Loading message file: "+messagesFile); props.load(in); + //reset the messages in UTF-8 + //TODO: fix this so we don't have to do a encoding conversion + Enumeration keys = props.keys(); + while (keys.hasMoreElements()) { + String key = keys.nextElement().toString(); + String value = props.getProperty(key); + if (value != null) { + props.setProperty(key, new String(value.getBytes("ISO-8859-1"),"UTF-8")); + } else { + Log.log(Log.DEBUG, Messages.class, "null value: "+key); + } + } + m_messages = MiscUtilities.mergeProperties(m_messages, props); } catch (FileNotFoundException e) { @@ -166,6 +179,19 @@ props.load(resource.openStream()); + //reset the messages in UTF-8 + //TODO: fix this so we don't have to do a encoding conversion + Enumeration keys = props.keys(); + while (keys.hasMoreElements()) { + String key = keys.nextElement().toString(); + String value = props.getProperty(key); + if (value != null) { + props.setProperty(key, new String(value.getBytes("ISO-8859-1"),"UTF-8")); + } else { + Log.log(Log.DEBUG, Messages.class, "null value: "+key); + } + } + m_pluginMessages = MiscUtilities.mergeProperties(m_pluginMessages, props); } catch (FileNotFoundException e) { //fall through This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |