----- Original Message ----- > From: "Einav Cohen" <eco...@redhat.com> > To: "Daniel Erez" <de...@redhat.com> > Cc: "Martin Sivak" <msi...@redhat.com>, "engine-devel" > <engine-devel@ovirt.org> > Sent: Thursday, October 17, 2013 4:37:42 PM > Subject: Re: [Engine-devel] Localization of canDoAction error messages > > Hi Derez, > > > addCanDoActionMessage(VdcBllMessages.VAR__TYPE__HOST); > > addCanDoActionMessage(String.format("$%1$s %2$s", "hostName", > > "host-A")); > > > > addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CONSTRAINT_MEMORY); > > > > addCanDoActionMessage(VdcBllMessages.VAR__TYPE__HOST); > > addCanDoActionMessage(String.format("$%1$s %2$s", "hostName", > > "host-B")); > > addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CONSTRAINT_CPU); > > // I changed that from your original message on purpose. > > > > [VdcBllMessages.ACTION_TYPE_FAILED_CONSTRAINT_MEMORY = > > "${type} ${hostName} failed constraint memory"] > > Is there a guarantee that each of the ACTION_TYPE_FAILED_CONSTRAINT_MEMORY > will > be replaced with its "matching" VAR__TYPE__HOST value? isn't there a chance > that > the above will result in: > > ... > Host host-A failed constraint memory > Host host-A failed constraint cpu load // second message was replaced with > an already-used variable value. > ... > > > or in: > ... > Host host-B failed constraint memory > Host host-A failed constraint cpu load // variable values were not used for > their "matching" base-messages. > ... > > ?
It shouldn't happen as long as the messages are sent in the correct order (iirc, the inner implementation is based on a linked list). Worth a bit of trial and error though... :) > > > ----- Original Message ----- > > From: "Daniel Erez" <de...@redhat.com> > > To: "Martin Sivak" <msi...@redhat.com> > > Cc: "engine-devel" <engine-devel@ovirt.org> > > Sent: Wednesday, October 16, 2013 4:30:07 PM > > Subject: Re: [Engine-devel] Localization of canDoAction error messages > > > > > > > > ----- Original Message ----- > > > From: "Martin Sivak" <msi...@redhat.com> > > > To: "Einav Cohen" <eco...@redhat.com> > > > Cc: "engine-devel" <engine-devel@ovirt.org> > > > Sent: Wednesday, October 16, 2013 6:46:42 PM > > > Subject: Re: [Engine-devel] Localization of canDoAction error messages > > > > > > Hi Einav, > > > > > > I know about this procedure, but if you check closely what I am doing, I > > > need > > > to print a list of messages at once where each has a different content. > > > > > > Something like this (again the strings are just an illustration): > > > > > > ------------- Error ---------------------- > > > The VM net-A could not be started because > > > there was no fitting host available. > > > > > > Host host-A failed constraint memory > > > Host host-B failed constraint cpu load > > > Host host-C failed constraint memory > > > ------------------------------------------ > > > > > > I am pretty sure the replacing we have in VdcBllMessages does not support > > > this as it cannot assign two or more different values to the same > > > variable. > > > > IIUC the exact request, I think you can use a mechanism I've introduced > > a while back into the error translator. It requires adding each variable > > separately (and multiple times when needed) to the CanDoActionMessages > > list - e.g. [1]. > > The messages will be then localized and displayed in a bullet list layout. > > However, there's one imitation, adding a title message is trickier > > (i.e. every message must preceded by a bullet); as an alternative, > > you can probably utilize 'CommandBase -> setDescription' which is used > > on RunMultipleAction failure (e.g. for displaying VM name on top > > of the relevant errors bullet list). > > > > [1] > > code -> > > > > addCanDoActionMessage(VdcBllMessages.VAR__TYPE__HOST); > > addCanDoActionMessage(String.format("$%1$s %2$s", "hostName", > > "host-A")); > > > > addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CONSTRAINT_MEMORY); > > > > addCanDoActionMessage(VdcBllMessages.VAR__TYPE__HOST); > > addCanDoActionMessage(String.format("$%1$s %2$s", "hostName", > > "host-B")); > > > > addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_CONSTRAINT_MEMORY); > > > > [VdcBllMessages.ACTION_TYPE_FAILED_CONSTRAINT_MEMORY = > > "${type} ${hostName} failed constraint memory"] > > > > output -> > > > > Error while executing action: > > > > VM1: > > * Host host-A failed constraint memory > > * Host host-B failed constraint memory > > > > > > note: > > instead of adding VAR__TYPE__HOST multiple times, it should be possible to > > just add a new variable that won't conflict with ${type} (which is already > > used > > by VAR__TYPE__VM in case of RunVmCommand). > > > > > > > > -- > > > Martin Sivák > > > msi...@redhat.com > > > Red Hat Czech > > > RHEV-M SLA / Brno, CZ > > > > > > ----- Original Message ----- > > > > Hi Martin, please follow instructions in [1] for adding new messages to > > > > the > > > > system. > > > > [you should not add the English message to the canDoActionMessages > > > > collection > > > > - you > > > > should add a key from the AppErrors resource - look for other examples > > > > in > > > > the > > > > code > > > > that add items to a command's canDoActionMessages field] > > > > > > > > ---- > > > > Thanks, > > > > Einav > > > > > > > > [1] http://www.ovirt.org/Engine_Adding_Messages > > > > > > > > ----- Original Message ----- > > > > > From: "Martin Sivak" <msi...@redhat.com> > > > > > To: "engine-devel" <engine-devel@ovirt.org> > > > > > Sent: Wednesday, October 16, 2013 11:22:02 AM > > > > > Subject: [Engine-devel] Localization of canDoAction error messages > > > > > > > > > > Hi, > > > > > > > > > > I am trying to improve the messages the user gets when scheduling > > > > > fails. > > > > > But > > > > > I have found an interesting issue regarding localization. The texts > > > > > here > > > > > are > > > > > simplified, but should demonstrate what I am trying to do. > > > > > > > > > > So here is the flow: > > > > > > > > > > - RunVmCommand's canDoAction fails because there is no host that fits > > > > > the > > > > > constraints > > > > > - For each host I add a message to > > > > > getReturnValue().getCanDoActionMessages() > > > > > in the format of "Host XYZ failed constraint ABCD". > > > > > - I log the same message to the log > > > > > > > > > > I expect the log to contain the strings in english and a localized > > > > > version > > > > > to > > > > > be shown in the error popup that will be displayed by the webadmin. > > > > > > > > > > And the question is.. how do I localize this? I looked at AppErrors > > > > > and > > > > > AppMessages, but there is not way of using them from the backend > > > > > side. > > > > > > > > > > Any ideas? > > > > > > > > > > -- > > > > > Martin Sivák > > > > > msi...@redhat.com > > > > > Red Hat Czech > > > > > RHEV-M SLA / Brno, CZ > > > > > > > > > > _______________________________________________ > > > > > Engine-devel mailing list > > > > > Engine-devel@ovirt.org > > > > > http://lists.ovirt.org/mailman/listinfo/engine-devel > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > Engine-devel mailing list > > > Engine-devel@ovirt.org > > > http://lists.ovirt.org/mailman/listinfo/engine-devel > > > > > _______________________________________________ > > Engine-devel mailing list > > Engine-devel@ovirt.org > > http://lists.ovirt.org/mailman/listinfo/engine-devel > > > > > > > _______________________________________________ Engine-devel mailing list Engine-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-devel