<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 28, 2016 at 12:27 PM, Scott Dickerson <span dir="ltr">&lt;<a href="mailto:sdickers@redhat.com" target="_blank">sdickers@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Thu, Jul 28, 2016 at 11:19 AM, Vojtech Szocs <span dir="ltr">&lt;<a href="mailto:vszocs@redhat.com" target="_blank">vszocs@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Ramesh,<br>
<br>
this issue seems to be related with removal of @DefaultMessage annotations,<br>
moving the default (English) strings into corresponding .properties files.<br></blockquote><div><br></div></span><div>Apparently if both properties file definitions and annotations are connected to the same message method, the properties version takes precidence.  I wasn&#39;t sure if this applied to alternate messages, but your problem clearly shows that it does.<br></div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
As we generally want default strings to reside in .properties files, I see<br>
following options to explore, based on our earlier conversation:<br>
<br>
1, try annotating UIMessages interface with:<br>
   @Generate(format = &quot;com.google.gwt.i18n.server.PropertyCatalogFactory&quot;)<br>
<br>
   - ref: <a href="https://github.com/gwtproject/gwt/issues/7032#issuecomment-110858030" rel="noreferrer" target="_blank">https://github.com/gwtproject/gwt/issues/7032#issuecomment-110858030</a><br>
   - this is likely non-feasible, however, since @Generate requests generation<br>
     of translation sources (.properties) from Java code<br>
<br>
2, try removing @AlternateMessage annotation and modify .properties file:<br>
   recurrenceType=Incorrect enum<br>
   recurrenceType[UNKNOWN]=None<br>
   recurrenceType[INTERVAL]=Minute<br>
   recurrenceType[HOURLY]=Hourly<br>
   recurrenceType[DAILY]=Daily<br>
   recurrenceType[WEEKLY]=Weekly<br>
   recurrenceType[MONTHLY]=Monthly<br>
<br>
   - ref: <a href="http://www.gwtproject.org/doc/latest/DevGuideI18nPluralForms.html" rel="noreferrer" target="_blank">http://www.gwtproject.org/doc/latest/DevGuideI18nPluralForms.html</a><br>
   - this might not work as it might be @PluralCount-only (not for @Select)<br>
<br></blockquote><div><br></div></span><div>I just tried this alternate messages in properties file technique and it will work.  <br><br></div><div>UIMessages.java:<br><div style="margin-left:40px">String recurrenceType(@Messages.Select GlusterVolumeSnapshotScheduleRecurrence recurrence);<br></div><br></div><div>UIMessage.properties:<span class=""><br><div style="margin-left:40px">recurrenceType=Incorrect enum<br>recurrenceType[UNKNOWN]=None<br>recurrenceType[INTERVAL]=Minute<br>recurrenceType[HOURLY]=Hourly<br>recurrenceType[DAILY]=Daily<br>recurrenceType[WEEKLY]=Weekly<br>recurrenceType[MONTHLY]=Monthly<br></div></span></div><div><br>The generated code looks like this:<br><div style="margin-left:40px">  public java.lang.String recurrenceType(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotScheduleRecurrence arg0) {<span class=""><br>    java.lang.String returnVal = null;<br>    int arg0_ordinal = -1;<br>    if (arg0 != null) {<br>      arg0_ordinal = arg0.ordinal();<br>    }<br></span>    switch (arg0_ordinal) {<br>      case 2:  // DAILY<br>        returnVal = &quot;Daily&quot;;<br>        break;<br>      case 1:  // HOURLY<br>        returnVal = &quot;Hourly&quot;;<br>        break;<br>      case 0:  // INTERVAL<br>        returnVal = &quot;Minute&quot;;<br>        break;<br>      case 4:  // MONTHLY<br>        returnVal = &quot;Monthly&quot;;<br>        break;<br>      case 5:  // UNKNOWN<br>        returnVal = &quot;None&quot;;<br>        break;<br>      case 3:  // WEEKLY<br>        returnVal = &quot;Weekly&quot;;<br>        break;<span class=""><br>    }<br>    if (returnVal != null) {<br>      return returnVal;<br>    }<br>    return &quot;Incorrect enum&quot;;<br>  }<br></span></div>  <br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
3, remove @AlternateMessage &amp; handle enum-to-string formatting on our own<span class=""><br>
<span><br>
   String sizeUnitString(String size, @Messages.Select SizeConverter.SizeUnit sizeUnit);<br>
</span>   becomes<br>
   String sizeUnitString(String size, String sizeUnitValue);<br>
<br>
   String recurrenceType(@Select GlusterVolumeSnapshotScheduleRecurrence recurrence);<br>
   gets removed, because there is no point in having &quot;{0}&quot; message<br>
<br>
   getMessages().sizeUnitString(size, sizeUnit);<br>
   becomes<br>
   getMessages().sizeUnitString(size, &lt;someUtility&gt;(sizeUnit));<br>
<br>
   getMessages().recurrenceType(recurrence);<br>
   becomes<br>
   &lt;someUtility&gt;(recurrence);<br>
<br>
Personally, I think 3, is the most correct solution. As Alex wrote below,<br>
we&#39;re planning to switch away from GWT i18n mechanism in the long-term;<br>
relying on @AlternateMessage etc. is therefore an obstacle to that effort.<br>
</span></blockquote><div><br></div><div>Option 2 is the most expedient and least intrusive.  As a bonus, those alternate strings will be pushed out to the translators without having to do additional work/changes.<br></div></div></div></div></blockquote><div><br></div><div>+1</div><div><br></div><div>Greg</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Also, we already have infra for localizing enum members: LocalizedEnums<br>
<br>
So as part of solution 3, we should add into LocalizedEnums:<br>
<br>
  String GlusterVolumeSnapshotScheduleRecurrence___INTERVAL();<br>
  String GlusterVolumeSnapshotScheduleRecurrence___HOURLY();<br>
  String GlusterVolumeSnapshotScheduleRecurrence___DAILY();<br>
  String GlusterVolumeSnapshotScheduleRecurrence___WEEKLY();<br>
  String GlusterVolumeSnapshotScheduleRecurrence___MONTHLY();<br>
  String GlusterVolumeSnapshotScheduleRecurrence___UNKNOWN();<br>
<br>
plus add corresponding strings in LocalizedEnums.properties file.<br>
<br>
This way, we can leverage existing EnumTranslator#translate method.<br>
<br>
By doing so, &lt;someUtility&gt; mentioned above === EnumTranslator#translate<br>
<br>
Regards,<br>
Vojtech<br>
<div><div><br>
<br>
----- Original Message -----<br>
&gt; From: &quot;Alexander Wels&quot; &lt;<a href="mailto:awels@redhat.com" target="_blank">awels@redhat.com</a>&gt;<br>
&gt; To: &quot;Ramesh Nachimuthu&quot; &lt;<a href="mailto:rnachimu@redhat.com" target="_blank">rnachimu@redhat.com</a>&gt;<br>
&gt; Cc: &quot;devel&quot; &lt;<a href="mailto:devel@ovirt.org" target="_blank">devel@ovirt.org</a>&gt;, &quot;Vojtech Szocs&quot; &lt;<a href="mailto:vszocs@redhat.com" target="_blank">vszocs@redhat.com</a>&gt;, &quot;Scott Dickerson&quot; &lt;<a href="mailto:sdickers@redhat.com" target="_blank">sdickers@redhat.com</a>&gt;<br>
&gt; Sent: Thursday, July 28, 2016 2:21:23 PM<br>
&gt; Subject: Re: Strange issues with com.google.gwt.i18n.client.Messages.AlternateMessage [bz#1358837]<br>
&gt;<br>
&gt; On Thursday, July 28, 2016 05:49:57 AM Ramesh Nachimuthu wrote:<br>
&gt; &gt; Hi,<br>
&gt; &gt;<br>
&gt; &gt;  We have a strange issue with the<br>
&gt; &gt; com.google.gwt.i18n.client.Messages.AlternateMessage in UIMessages.java. We<br>
&gt; &gt; have defined some alternate messages using @Messages.Select with Enums. But<br>
&gt; &gt; its doesn&#39;t work any more.<br>
&gt; &gt;<br>
&gt; &gt; We have following messages in the UIMessages.java.<br>
&gt; &gt;<br>
&gt; &gt;     @Messages.AlternateMessage(value = { &quot;UNKNOWN&quot; , &quot;None&quot; , &quot;INTERVAL&quot; ,<br>
&gt; &gt; &quot;Minute&quot; , &quot;HOURLY&quot; , &quot;Hourly&quot; , &quot;DAILY&quot; , &quot;Daily&quot; , &quot;WEEKLY&quot; , &quot;Weekly&quot; ,<br>
&gt; &gt; &quot;MONTHLY&quot; , &quot;Monthly&quot; }) String recurrenceType(@Messages.Select<br>
&gt; &gt;     GlusterVolumeSnapshotScheduleRecurrence recurrence);<br>
&gt; &gt;<br>
&gt; &gt;     @Messages.AlternateMessage(value = { &quot;BYTES&quot; , &quot;{0} B&quot; , &quot;KiB&quot; , &quot;{0}<br>
&gt; &gt; KiB&quot; , &quot;MiB&quot; , &quot;{0} MiB&quot; , &quot;GiB&quot; , &quot;{0} GiB&quot; , &quot;TiB&quot; , &quot;{0} TiB&quot; }) String<br>
&gt; &gt; sizeUnitString(String size, @Messages.Select<br>
&gt; &gt;     SizeConverter.SizeUnit sizeUnit);<br>
&gt; &gt;<br>
&gt; &gt; But the generated UIMessages_.java doesn&#39;t use any of the enum conditions.<br>
&gt; &gt;<br>
&gt; &gt;   public java.lang.String<br>
&gt; &gt; recurrenceType(org.ovirt.engine.core.common.businessentities.gluster.Gluste<br>
&gt; &gt; rVolumeSnapshotScheduleRecurrence arg0) { java.lang.String returnVal =<br>
&gt; &gt; null;<br>
&gt; &gt;     int arg0_ordinal = -1;<br>
&gt; &gt;     if (arg0 != null) {<br>
&gt; &gt;       arg0_ordinal = arg0.ordinal();<br>
&gt; &gt;     }<br>
&gt; &gt;     if (returnVal != null) {<br>
&gt; &gt;       return returnVal;<br>
&gt; &gt;     }<br>
&gt; &gt;     return &quot;Incorrect enum&quot;;<br>
&gt; &gt;   }<br>
&gt; &gt;<br>
&gt; &gt;   public java.lang.String sizeUnitString(java.lang.String<br>
&gt; &gt; arg0,org.ovirt.engine.core.common.utils.SizeConverter.SizeUnit arg1) {<br>
&gt; &gt; java.lang.String returnVal = null;<br>
&gt; &gt;     int arg1_ordinal = -1;<br>
&gt; &gt;     if (arg1 != null) {<br>
&gt; &gt;       arg1_ordinal = arg1.ordinal();<br>
&gt; &gt;     }<br>
&gt; &gt;     if (returnVal != null) {<br>
&gt; &gt;       return returnVal;<br>
&gt; &gt;     }<br>
&gt; &gt;     return arg0 + &quot; TiB&quot;;<br>
&gt; &gt;   }<br>
&gt; &gt;<br>
&gt; &gt; It used to work earlier. Is there any known issue in the current GWT<br>
&gt; &gt; Version? or Am I missing something?.<br>
&gt; &gt;<br>
&gt; &gt; Regards,<br>
&gt; &gt; Ramesh<br>
&gt;<br>
&gt; We have an active project to remove all the annotations from the Messages<br>
&gt; interfaces in the project. I am guessing that is probably the cause of your<br>
&gt; problems. I am fairly certain there is an alternative to the annotations now,<br>
&gt; but I don&#39;t know of the top of my head. Scott can you give them the details?<br>
&gt;<br>
&gt; Alexander<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div></div></div><br></div><div class="gmail_extra">Regards,<br></div><div class="gmail_extra">Scott<span class="HOEnZb"><font color="#888888"><br clear="all"></font></span></div><span class="HOEnZb"><font color="#888888"><div class="gmail_extra"><br>-- <br><div data-smartmail="gmail_signature"><div dir="ltr"><div><div>Scott Dickerson<br></div>Senior Software Engineer<br></div>RHEV-M Engineering - UX Team<br>Red Hat, Inc<br></div></div>
</div></font></span></div>
<br>_______________________________________________<br>
Devel mailing list<br>
<a href="mailto:Devel@ovirt.org">Devel@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.ovirt.org/mailman/listinfo/devel</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Greg Sheremeta, MBA<br>Red Hat, Inc.<br>Sr. Software Engineer<br><a href="mailto:gshereme@redhat.com" target="_blank">gshereme@redhat.com</a><br></div></div></div>
</div></div>