Could not find any match !

I18N -

Basic support for internationalized messages. The realization is quite simple as you only need to write basic class which provides the desired messages. Here’s is an example how to do that:

package my.example;

import com.kasisoft.libs.common.i18n.*;

public class Messages {

  @I18N("copyrighted by Daniel Kasmeroglu")
  public static String           msg_copyrights;

  @I18N("we're sorry, you're only %d years old which isn't sufficient")
  public static I18NFormatter    msg_not_old_enough;

  static {
    I18NSupport.initialize(Locale.GERMAN, Messages.class);

} /* ENDCLASS */

This class provides two messages and the default values provided in their annotations. My own convention is to use english as the default but that’s up to you.

The fields will be filled within the static initialization portion. The defaults will only be used if there’s no translations available.

Translations will be provided as property files. The resource folder must match the package, so in our example we need to place the translations in a resource location /my/example.

The basename must match the classname (lower case) which is messages in our case.

If that doesn’t fit your needs you can choose a different resource location using the corresponding annotation @I18NBasename(resource = “/wobby/fruppel”) which used the resource location wobby and the basename fruppel.

The basenames must be appended by the specified Locale and the suffix .properties . Here are some examples:

You might have noted that I’ve used two types for the translations: String and I18NFormatter. The String is obvious whereas the I18NFormatter includes String.format functionality. The basic advantage of using this formatter is that it improves readability since you don’t clutter your code with explicit String.format calls. I suggest to make use of it since you don’t end up to using different formatting functions (f.e. when using Slf4j).

Here’s an example:

package bibo;

import static my.example.Messages.*;

public class Example {

    public static void main( String[] args ) {

        System.out.println( msg_copyrights );
        System.out.println( msg_not_old_enough.format( 20 ) );


} /* ENDCLASS */