Thursday, December 10, 2015

Re: Is it possible to reuse one i18n message in another


Don't the "callers" all have to change anyway, in order to express whether they want "this" or "that" or neither?

see http://www.gwtproject.org/doc/latest/DevGuideI18nMessages.html#SelectForms

public enum ThisThatVariation { THIS, THAT, PLAIN }


public interface MyMessages extends Messages {

  @DefaultMessage("{0}")
  @AlternateMessage({
    "THIS", "{0} this",
    "THAT", "{0} that",
  })
  String thisThat(String text, @Select ThisThatVariation variation);

  @DefaultMessage("search")
  String search();
}

...
  // (GWT.create / init msgs)
  String a = msgs.thisThat(msgs.search(), ThisThatVariation.THIS); // "search this"
  String b = msgs.thisThat(msgs.search(), ThisThatVariation.THAT); // "search that"
  String c = msgs.thisThat(msgs.search(), ThisThatVariation.PLAIN); // "search"
  String d = msgs.search(); // "search"


On Thursday, December 10, 2015 at 4:22:30 AM UTC-5, Константин Милютин wrote:
I have an i18n message like the following:
search = search
search = suchen

I would like to re-use it in other messages (invented syntax):
searchThis = {search} this
searchThat = {search} that

The only way I see is to add a parameter to searchThis and the caller should pass search() inside. But then I have to change all existing calls...

Is it possible to do it transparently for the caller?


--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment