[cai18n-dev] Type safe message definition

Takeshi Kondo takeshi.kondo at gmail.com
Fri Aug 28 16:27:59 CEST 2009


Hello Ceki

I don't like to write property file(because I must execute  
native2ascii to property file in Japanese) , but main point is IDE  
support.

Because Enum and Annotation is in Java syntax, IDE inform quickly  
error to me in saving code.
Verification approach can't check consistency on no execution. It  
don't utilize typed language advantage.

IMO, the advantage of typed language like as Java and C# than dynamic  
language like as Ruby and Python is to inform error in compiling time.
Japanese famous engineer Yasuo Higa have been creating excellent  
features from this concept.
(see Tyep safe query:  http://sites.google.com/site/slim3appengine/ 
Home ).
I like this concept.

What do you think about IDE support?


On 2009/08/28, at 21:11, Ceki Gulcu wrote:

> Hello Takeshi,
>
> LocalizedColors and ColorDef_* show that it is possible to do
> localization without resource bundles. Is that the main point, or is
> there something else?
>
> The syntax of LocalizedColors is more verbose than what you would have
> with a simple enum + resource bundles. Actually, the syntax is
> overwhelmingly noisy to be useful, or I may be just missing the
> point. :-)
>
> The syntax of MessageDeclaration based enums is much better but still
> more verbose than the enum + resource bundles
> combination. MessageDefinitionConveyor demonstrates that an enum-only
> (or Java code only) implementation of IMessageConveyor is
> possible. But from a practical point of view, resource bundles are
> more convenient. Wouldn't you agree?
>
> In any case, thank you for sharing your ideas. They are well
> appreciated.
>
>
>
> Takeshi Kondo wrote:
>> Hi Ceki
>> I have two type safe message definition idea.
>> I've committed draft code to my cai18n project clone.
>> (http://github.com/takeshi/cai18n/tree/master)
>> Please take it in cai18n project, if you like it,.
>> My ideas is as follows.
>> 1. Message definition by annotation
>> for instance,
>> public enum LocalizedColors {
>>    @Message("green")
>>    GREEN {
>>        @Message("vert")
>>        Locale fr = Locale.FRANCE;
>>        @Message("midori")
>>        Locale ja = Locale.JAPAN;
>>    }
>> }
>> Using enum field declaration with annotation, we can define  
>> localized message. It is simple , but we can't add other locale.
>> 2. Message definition by switch case
>> for instance,
>> public class ColorDef_fr extends MessageDefinition<Colors> {
>>    public Locale getLocale() {
>>        return Locale.FRANCE;
>>    }
>>    public String getMessage(Colors e) {
>>        switch (e) {
>>        case BLUE:
>>            return "blue";
>>        case GREEN:
>>            return "vert";
>>        case RED:
>>            return "rouge";
>>        }
>>        return null;
>>    }
>> }
>> Using method return, we can define localized message.
>> It is not simple, but this we can define it per  
>> locale._______________________________________________
>> cai18n-dev mailing list
>> cai18n-dev at qos.ch
>> http://qos.ch/mailman/listinfo/cai18n-dev
>
> -- 
> Ceki Gülcü
> Logback: The reliable, generic, fast and flexible logging framework  
> for Java.
> http://logback.qos.ch
> _______________________________________________
> cai18n-dev mailing list
> cai18n-dev at qos.ch
> http://qos.ch/mailman/listinfo/cai18n-dev




More information about the cal10n-dev mailing list