Go back to using mx.resources.ResourceBundle, as it's the standard thing
and turned out to not be the class that was sucking in vast quantities of flex code. Alas. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4596 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
package com.threerings.util {
|
package com.threerings.util {
|
||||||
|
|
||||||
|
import mx.resources.ResourceBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A message bundle provides an easy mechanism by which to obtain
|
* A message bundle provides an easy mechanism by which to obtain
|
||||||
* translated message strings from a resource bundle. It uses the {@link
|
* translated message strings from a resource bundle. It uses the {@link
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ package com.threerings.util {
|
|||||||
//
|
//
|
||||||
//import mx.resources.Locale;
|
//import mx.resources.Locale;
|
||||||
|
|
||||||
|
import mx.resources.ResourceBundle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The message manager provides a thin wrapper around Java's built-in
|
* The message manager provides a thin wrapper around Java's built-in
|
||||||
* localization support, supporting a policy of dividing up localization
|
* localization support, supporting a policy of dividing up localization
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
package com.threerings.util {
|
|
||||||
|
|
||||||
import flash.system.ApplicationDomain;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A non-flex version of ResourceBundle.
|
|
||||||
*/
|
|
||||||
public /*abstract*/ class ResourceBundle
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get a resource bundle by name.
|
|
||||||
*/
|
|
||||||
public static function getResourceBundle (
|
|
||||||
baseName :String, appDom :ApplicationDomain = null) :ResourceBundle
|
|
||||||
{
|
|
||||||
if (appDom == null) {
|
|
||||||
appDom = ApplicationDomain.currentDomain;
|
|
||||||
}
|
|
||||||
|
|
||||||
var className :String = baseName + "_properties";
|
|
||||||
if (appDom.hasDefinition(className)) {
|
|
||||||
var obj :Object = new (Class(appDom.getDefinition(className)))();
|
|
||||||
if (obj is ResourceBundle) {
|
|
||||||
var rb :ResourceBundle = ResourceBundle(obj);
|
|
||||||
rb.initialize(baseName);
|
|
||||||
return rb;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new Error("Could not find resource bundle " + baseName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a resource value as a String.
|
|
||||||
*/
|
|
||||||
public function getString (key :String) :String
|
|
||||||
{
|
|
||||||
return String(getObject(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a resouce value as the raw type contained within the content
|
|
||||||
* object.
|
|
||||||
*/
|
|
||||||
public function getObject (key :String) :Object
|
|
||||||
{
|
|
||||||
var val :Object = _content[key];
|
|
||||||
if (val != null) {
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
throw new Error("Key '" + key + "' was not found in resource bundle '" +
|
|
||||||
_name + "'.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal initialization method.
|
|
||||||
*/
|
|
||||||
private function initialize (name :String) :void
|
|
||||||
{
|
|
||||||
_content = getContent();
|
|
||||||
if (_content == null) {
|
|
||||||
throw new Error("No content found in resource bundle '" + name + "'.");
|
|
||||||
}
|
|
||||||
_name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the content of this resource bundle.
|
|
||||||
* You may override this to do custom stuff.
|
|
||||||
*/
|
|
||||||
protected function getContent () :Object
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The name of this bundle. */
|
|
||||||
protected var _name :String;
|
|
||||||
|
|
||||||
/** Contains resource bundle values. */
|
|
||||||
protected var _content :Object;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user