Is it possible to overload method messages in GWT i18n

I have an implementation com.google.gwt.i18n.client.Messagesfor a localized GWT project.

But it seems impossible to overload the methods. Is this a mistake or is there a reason?

public interface CommonMessages extends Messages {

    public static final CommonMessages INSTANCE = GWT.create( CommonMessages.class );

    @DefaultMessage( "The entered text \"{0}\" contains the illegal character(s) \"{1}\" ." )
    String textValidatorError( String o, String e );

    @DefaultMessage( "The entered text \"{0}\" contains illegal character(s)." )
    String textValidatorError( String o );
}

causes:

        Rebinding common.client.i18n.CommonMessages
 [java] Invoking generator com.google.gwt.i18n.rebind.LocalizableGenerator
 [java]    Processing interface common.client.i18n.CommonMessages
 [java]       Generating method body for textValidatorError()
 [java]          [ERROR] Argument 1 beyond range of arguments: The entered text "{0}" contains the illegal character(s) "{1}" .
+5
source share
1 answer

Your message interface depends on the properties file. Since your interface has methods using the same name, gwt tries to find the textValidatorError property twice in the same file. For the first time, he searches for a property with two arguments and finds it. The second time, he searches for a property with 1 argument and finds one with two ... Therefore, an error.

@Key, .

public interface CommonMessages extends Messages {

  public static final CommonMessages INSTANCE = GWT.create( CommonMessages.class );

  @DefaultMessage( "The entered text \"{0}\" contains the illegal character(s) \"{1}\" ." )
  String textValidatorError( String o, String e );

  @DefaultMessage( "The entered text \"{0}\" contains illegal character(s)." )
  @Key("textValidatorErrorAlternate")
  String textValidatorError( String o );
}
+4

All Articles