<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"><<a href="mailto:sdickers@redhat.com" target="_blank">sdickers@redhat.com</a>></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"><<a href="mailto:vszocs@redhat.com" target="_blank">vszocs@redhat.com</a>></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'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 = "com.google.gwt.i18n.server.PropertyCatalogFactory")<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 = "Daily";<br> break;<br> case 1: // HOURLY<br> returnVal = "Hourly";<br> break;<br> case 0: // INTERVAL<br> returnVal = "Minute";<br> break;<br> case 4: // MONTHLY<br> returnVal = "Monthly";<br> break;<br> case 5: // UNKNOWN<br> returnVal = "None";<br> break;<br> case 3: // WEEKLY<br> returnVal = "Weekly";<br> break;<span class=""><br> }<br> if (returnVal != null) {<br> return returnVal;<br> }<br> return "Incorrect enum";<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 & 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 "{0}" message<br>
<br>
getMessages().sizeUnitString(size, sizeUnit);<br>
becomes<br>
getMessages().sizeUnitString(size, <someUtility>(sizeUnit));<br>
<br>
getMessages().recurrenceType(recurrence);<br>
becomes<br>
<someUtility>(recurrence);<br>
<br>
Personally, I think 3, is the most correct solution. As Alex wrote below,<br>
we'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, <someUtility> mentioned above === EnumTranslator#translate<br>
<br>
Regards,<br>
Vojtech<br>
<div><div><br>
<br>
----- Original Message -----<br>
> From: "Alexander Wels" <<a href="mailto:awels@redhat.com" target="_blank">awels@redhat.com</a>><br>
> To: "Ramesh Nachimuthu" <<a href="mailto:rnachimu@redhat.com" target="_blank">rnachimu@redhat.com</a>><br>
> Cc: "devel" <<a href="mailto:devel@ovirt.org" target="_blank">devel@ovirt.org</a>>, "Vojtech Szocs" <<a href="mailto:vszocs@redhat.com" target="_blank">vszocs@redhat.com</a>>, "Scott Dickerson" <<a href="mailto:sdickers@redhat.com" target="_blank">sdickers@redhat.com</a>><br>
> Sent: Thursday, July 28, 2016 2:21:23 PM<br>
> Subject: Re: Strange issues with com.google.gwt.i18n.client.Messages.AlternateMessage [bz#1358837]<br>
><br>
> On Thursday, July 28, 2016 05:49:57 AM Ramesh Nachimuthu wrote:<br>
> > Hi,<br>
> ><br>
> > We have a strange issue with the<br>
> > com.google.gwt.i18n.client.Messages.AlternateMessage in UIMessages.java. We<br>
> > have defined some alternate messages using @Messages.Select with Enums. But<br>
> > its doesn't work any more.<br>
> ><br>
> > We have following messages in the UIMessages.java.<br>
> ><br>
> > @Messages.AlternateMessage(value = { "UNKNOWN" , "None" , "INTERVAL" ,<br>
> > "Minute" , "HOURLY" , "Hourly" , "DAILY" , "Daily" , "WEEKLY" , "Weekly" ,<br>
> > "MONTHLY" , "Monthly" }) String recurrenceType(@Messages.Select<br>
> > GlusterVolumeSnapshotScheduleRecurrence recurrence);<br>
> ><br>
> > @Messages.AlternateMessage(value = { "BYTES" , "{0} B" , "KiB" , "{0}<br>
> > KiB" , "MiB" , "{0} MiB" , "GiB" , "{0} GiB" , "TiB" , "{0} TiB" }) String<br>
> > sizeUnitString(String size, @Messages.Select<br>
> > SizeConverter.SizeUnit sizeUnit);<br>
> ><br>
> > But the generated UIMessages_.java doesn't use any of the enum conditions.<br>
> ><br>
> > public java.lang.String<br>
> > recurrenceType(org.ovirt.engine.core.common.businessentities.gluster.Gluste<br>
> > rVolumeSnapshotScheduleRecurrence arg0) { java.lang.String returnVal =<br>
> > null;<br>
> > int arg0_ordinal = -1;<br>
> > if (arg0 != null) {<br>
> > arg0_ordinal = arg0.ordinal();<br>
> > }<br>
> > if (returnVal != null) {<br>
> > return returnVal;<br>
> > }<br>
> > return "Incorrect enum";<br>
> > }<br>
> ><br>
> > public java.lang.String sizeUnitString(java.lang.String<br>
> > arg0,org.ovirt.engine.core.common.utils.SizeConverter.SizeUnit arg1) {<br>
> > java.lang.String returnVal = null;<br>
> > int arg1_ordinal = -1;<br>
> > if (arg1 != null) {<br>
> > arg1_ordinal = arg1.ordinal();<br>
> > }<br>
> > if (returnVal != null) {<br>
> > return returnVal;<br>
> > }<br>
> > return arg0 + " TiB";<br>
> > }<br>
> ><br>
> > It used to work earlier. Is there any known issue in the current GWT<br>
> > Version? or Am I missing something?.<br>
> ><br>
> > Regards,<br>
> > Ramesh<br>
><br>
> We have an active project to remove all the annotations from the Messages<br>
> interfaces in the project. I am guessing that is probably the cause of your<br>
> problems. I am fairly certain there is an alternative to the annotations now,<br>
> but I don't know of the top of my head. Scott can you give them the details?<br>
><br>
> Alexander<br>
><br>
><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>