0

Thanks for reading this.

I am looking to provide i18n in my Spring-Shell application. Specifically, I am looking for the ability to print the help messages within the @CliOption in different languages depending on the locale. I have not found any concrete examples of how this can be done out of the box. I have looked the code and I do see a locale converter. Not sure if this will suffice though.

Does Spring-Shell support i18n out of the box ? Any help/tips/pointers to resources related to this matter will be highly appreciated.

Thanks.

ajj
  • 101
  • 1
  • 10

1 Answers1

0

this is not currently supported and would require a significant change in Spring Shell. I'll take note of it as a requirement for the next major evolution of Spring Shell.

The LocaleConverter you refer to is for converting parameters from text (String) form to Locale, i.e. if a command like this existed:

@CliCommand(value="translate", help="translate text from one language to another")
  public String translate(
    @CliOption(key={"", "text"}, help="the text to translate") String text,
    @CliOption(key="from", help="the source Locale") Locale source,
    @CliOption(key="to", help="the target Locale") Locale target) {

    Word from = service.lookup(text, source);
    Word to = from.tranlatedTo(target);
    return to.toString();
  }
}

That way, you'd directly get a Locale object when typing e.g.

translate bonjour --from fr_FR --to en

Hope that makes sense.

ebottard
  • 1,997
  • 2
  • 12
  • 14
  • Thanks for the reply @ebottard. Yes. My educated guess conforms to your reply that it is not supported out of the box. Though one can argue that a power user must have some level of proficiency in english if he is to use a command-line tool imho, it can be a very handy feature. I was about to go the route of using a messagesource to see if that would pick up the help message in a configured language...... What is your opinion about that approach ? Maybe it would seem more of a pragmatic hack than anything else. – ajj Sep 03 '15 at 08:34