diff --git a/src/as/com/threerings/crowd/chat/client/ChatDirector.as b/src/as/com/threerings/crowd/chat/client/ChatDirector.as index b3cdf0ac3..97593b21b 100644 --- a/src/as/com/threerings/crowd/chat/client/ChatDirector.as +++ b/src/as/com/threerings/crowd/chat/client/ChatDirector.as @@ -186,8 +186,8 @@ public class ChatDirector extends BasicDirector var key :String = "c." + command; if (msg.exists(key)) { var tokens :Array = msg.get(key).split(/\s+/); - for (var ii :int = 0; ii < tokens.length; ii++) { - _handlers.put(tokens[ii], handler); + for each (var cmd :Object in tokens) { + _handlers.put(cmd, handler); } } else { // fall back to just using the English command @@ -276,8 +276,8 @@ public class ChatDirector extends BasicDirector */ public function dispatchMessage (message :ChatMessage) :void { - for (var ii :int = 0; ii < _displays.length; ii++) { - (_displays.getItemAt(ii) as ChatDisplay).displayMessage(message); + for each (var display :ChatDisplay in _displays) { + display.displayMessage(message); } } diff --git a/src/as/com/threerings/crowd/chat/client/HelpHandler.as b/src/as/com/threerings/crowd/chat/client/HelpHandler.as index 8c27603d9..30d781ca8 100644 --- a/src/as/com/threerings/crowd/chat/client/HelpHandler.as +++ b/src/as/com/threerings/crowd/chat/client/HelpHandler.as @@ -49,7 +49,7 @@ public class HelpHandler extends CommandHandler var cmds :Array = possibleCmds.keys(); cmds.sort(); var cmdList :String = ""; - for (var skey :String in cmds) { + for each (var skey :String in cmds) { cmdList += " /" + skey; } return MessageBundle.tcompose("m.usage_help", cmdList); diff --git a/src/as/com/threerings/util/Equalable.as b/src/as/com/threerings/util/Equalable.as index d798c3b23..4c809964c 100644 --- a/src/as/com/threerings/util/Equalable.as +++ b/src/as/com/threerings/util/Equalable.as @@ -4,9 +4,11 @@ package com.threerings.util { * An interface we can use to implement equals(), which is standard and * very useful in Java. */ -public interface Equalable { +public interface Equalable +{ /** - * Return true to see if this instance is equal to the specified object. + * Returns true to indicate that the specified object is equal to + * this instance. */ function equals (other :Object) :Boolean; } diff --git a/src/as/com/threerings/util/MessageBundle.as b/src/as/com/threerings/util/MessageBundle.as index 36a8a4f1a..fa77545bf 100644 --- a/src/as/com/threerings/util/MessageBundle.as +++ b/src/as/com/threerings/util/MessageBundle.as @@ -21,6 +21,8 @@ package com.threerings.util { +import mx.resources.ResourceBundle; + /** * A message bundle provides an easy mechanism by which to obtain * translated message strings from a resource bundle. It uses the {@link diff --git a/src/as/com/threerings/util/MessageManager.as b/src/as/com/threerings/util/MessageManager.as index bd2f08dc6..239aa850f 100644 --- a/src/as/com/threerings/util/MessageManager.as +++ b/src/as/com/threerings/util/MessageManager.as @@ -21,6 +21,11 @@ package com.threerings.util { +import mx.managers.ISystemManager; + +import mx.resources.Locale; +import mx.resources.ResourceBundle; + /** * The message manager provides a thin wrapper around Java's built-in * localization support, supporting a policy of dividing up localization @@ -56,11 +61,15 @@ public class MessageManager * ResourceBundle#getBundle(String,Locale,ClassLoader)} for a more * detailed explanation of how resource bundle paths are resolved. */ - public function MessageManager (resourcePrefix :String) + public function MessageManager ( + resourcePrefix :String, sysMgr :ISystemManager) { // keep the prefix _prefix = resourcePrefix; + // use the default locale + _locale = Locale.getCurrent(sysMgr); + // make sure the prefix ends with a dot if (_prefix.charAt(_prefix.length - 1) != ".") { _prefix += "."; @@ -76,21 +85,21 @@ public class MessageManager * new SimpleDateFormat("EEEE", getLocale()) to get the name of a weekday * that matches the language being used for all other client translations. */ -// public Locale getLocale () -// { -// return _locale; -// } + public function getLocale () :Locale + { + return _locale; + } /** * Sets the locale to the specified locale. Subsequent message bundles * fetched via the message manager will use the new locale. The * message bundle cache will also be cleared. */ -// public void setLocale (Locale locale) -// { -// _locale = locale; -// _cache.clear(); -// } + public function setLocale (locale :Locale) :void + { + _locale = locale; + _cache.clear(); + } /** * Allows a custom classloader to be configured for locating @@ -125,7 +134,7 @@ public class MessageManager // if (_loader != null) { // rbundle = ResourceBundle.getBundle(fqpath, _locale, _loader); // } else { - rbundle = ResourceBundle.getBundle(fqpath); + rbundle = ResourceBundle.getResourceBundle(fqpath); // } } catch (mre :Error) { Log.warning("Unable to resolve resource bundle " + @@ -171,7 +180,7 @@ public class MessageManager protected var _prefix :String; /** The locale for which we're obtaining message bundles. */ -// protected var _locale :Locale; + protected var _locale :Locale; /** A custom class loader that we use to load resource bundles. */ // protected var _loader :ClassLoader; diff --git a/src/as/com/threerings/util/ResourceBundle.as b/src/as/com/threerings/util/ResourceBundle.as deleted file mode 100644 index 64bf4b598..000000000 --- a/src/as/com/threerings/util/ResourceBundle.as +++ /dev/null @@ -1,15 +0,0 @@ -package com.threerings.util { - -public class ResourceBundle -{ - public static function getBundle (path :String) :ResourceBundle - { - return new ResourceBundle(); - } - - public function getString (key :String) :String - { - return "TODO: resource:" + key; - } -} -}