tags:

views:

263

answers:

0

I want to be able to highlight missing resource text. What I would like to see is [key]-locale if the given key is missing for the given locale. E.g. [panel.label]-fr_FR.

The resourceManager currently returns nothing if a label is missing. This makes missing resources harder to find.

I can wrap calls to ResourceManager.resourceManager.getString() and test the result and format it properly.

However, in my main.mxml and probably the others as well(haven't got that far yet), when I change language my function isn't called. But when I use resourceManager, a change in language is reflected in the GUI.

so this returns a value if panel.label is defined for the current locale or blank if not. And is called when the language is changed.

whereas this will return the correct value or my [panel.label]-fr_FR if it is missing, but it is only called on start up and not when the language is changed.

Here is the full code for HGResourceManager: package fred {

import mx.managers.ISystemManager;
import mx.resources.ResourceManager;


[Mixin]
public class HGResourceManager {

 public static function init(systemManager:ISystemManager):void
 {
   new HGResourceManager();
 }
 private static var me:HGResourceManager;
 public function HGResourceManager() 
 {
  me = this;
 }

 public static function getResMan():HGResourceManager 
 {
  return me;
 }


 public function getString(bundleName:String, resourceName:String, parameters:Array = null, locale:String = null):String
 {
  trace("calling hgresman for:" + resourceName);
  var temp:String = ResourceManager.getInstance().getString(bundleName, resourceName, parameters, locale);
  if (temp == null)
   return "[" + resourceName + "]-" + ResourceManager.getInstance().localeChain[0];
  else
   return temp;
 }

}

}

And the language is changed like this - where lang comes from a combobox:

public function setLanguage(lang:String):void { trace (lang); ResourceManager.getInstance().localeChain = [lang]; ResourceManager.getInstance().update(); }

So I'm looking either for a way to get resourceManager to let me know when something is missing - doesn't have to be my format but I'd like the key name at least, or to understand how to make sure that my wrapper is called whenever the language changes.

Thanks for any clues.