Closed
Description
Description
Assigning a localized name for enum values is rather challenging with the current Qute API.
It would be helpful to be able to set part of the key as the first parameter of the message method:
Implementation ideas
public enum
MyEnum {
ON, OFF, UNDEFINED
}
@MessageBundle
public interface AppMessages {
@Message
String displayName(MyEnum name);
}
Then the localized file could look like:
# This comment is ignored
displayName.ON=On
displayName.OFF=Off
displayName.UNDEFINED=Undefined
We could add a new annotation for the parameter to make it explicit that it is part of the key:
public interface AppMessages {
@Message
String displayName(@MessageKey MyEnum name);
}
if we want to be able to provide the message in the @message annotation, we could make it repeatable:
public interface AppMessages {
@Message(key="ON", value="On")
@Message(key="OFF", value="Off")
@Message(key="UNDEFINED", value="Undefined")
String displayName(@MessageKey MyEnum name);
}
or we could just prevent to set the message if MessageKey is present ?