It seems to me that this function is not supported by the GWT I18NCreator (this is what causes the maven i18n target). To do this, you will have to write your own generator. I wrote a couple of generators, and it's not as complicated as you think. In your case, you would like to write a generator that creates an instance of the interface similar to GWT messages (but you can use your own), but which has additional functions that you want to use when decoding messages. The following guide, which will help you, may help you, since it seems to be pretty much what I did and it works:
http://groups.google.com/group/Google-Web-Toolkit/msg/ae249ea67c2c3435?pli=1
I found that the easiest way to write a GWT generator is to actually write a test class with the code that you want to generate in your IDE (and using autocompletion, validation syntax, etc.), and then in the past / adapt it to to a writer like this:
writer.println("public void doSomething() { }");
And do not forget to tell your module (module.gwt.xml file) which interface you need to create and with which class, for example:
<generate-with class="mycompany.utils.generators.MyGenerator"> <when-type-assignable class="mycompany.messages.MyCoolPropertiesReader" /> </generate-with>
In Generator code, you can use Java with all its great features (not limited to GWT-translatable code), so itβs easy for you to implement what you want. In client code, you can simply do:
public interface MyCoolPropertiesReader { public String getMessage(String propKey, Object... parameters); } public class MyClientSideClass { MyCoolPropertiesReader reader = GWT.create(MyCoolPropertiesReader.class); String msg = reader.getMessage("my.message", 10);
The test generator that I wrote (GWT "reflective" getter and setter, as it were) looks like this:
public class TestGenerator extends Generator { @Override public String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException { try { TypeOracle oracle = context.getTypeOracle(); JClassType requestedClass = oracle.getType(typeName); String packageName = requestedClass.getPackage().getName(); String simpleClassName = requestedClass.getSimpleSourceName(); String proxyClassName = simpleClassName + "GetterAndSetter"; String qualifiedProxyClassName = packageName + "." + proxyClassName; System.out.println("Created a class called: " + qualifiedProxyClassName); PrintWriter printWriter = context.tryCreate(logger, packageName, className); if (printWriter == null) return null; ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(packageName, className); composerFactory.addImport("test.project.shared.GetterAndSetter"); composerFactory.addImplementedInterface("GetterAndSetter<" + underlyingTypeName + ">"); SourceWriter writer = composerFactory.createSourceWriter(context, printWriter); if (writer != null) { JField[] fields = requestedClass.getFields(); for (JField field : fields) { createSetterMethodForField(typeName, writer, field); } writer.indent(); writer.println("public void set(" + typeName + " target, String path, Object value) {"); writer.indent(); createIfBlockForFields(writer, fields, true); writer.outdent(); writer.println("}"); writer.println(); writer.println("public <K> K get(" + typeName + " target, String path) {"); writer.indent(); createIfBlockForFields(writer, fields, false); writer.outdent(); writer.println("}"); writer.println(); writer.outdent(); writer.commit(logger); } return packageName + "." + proxyClassName; } catch(NotFoundException nfe) { throw new UnableToCompleteException(); } } }
Hope this helps you.