thanks for clarifying.
indeed today, the canDoActionMessages is simply a collection of strings, each
of which is either a message, a message with variable placeholder(s) or a
variable value; if a few messages contain an identically-named variable
placeholder (e.g. '${HostName}'), and you want to replace each one of these
placeholders with a different value (e.g. 'host-A', 'host-B', etc.), it is
impossible to do AFAIK.
a possible improvement to the current mechanism in order to support what you
need is to define the canDoActionMessage field to be a collection of string
collections (rather than a collection of strings); and each string collection
will actually represent a single 'line' in the can-do-action failure message,
by containing the 'base' message (e.g. "Host '${HostName}' failed
constraint
memory") and its matching variable value(s) (e.g. '$HostName host-A').
----
Regards,
Einav
----- Original Message -----
From: "Martin Sivak" <msivak(a)redhat.com>
To: "Einav Cohen" <ecohen(a)redhat.com>
Cc: "engine-devel" <engine-devel(a)ovirt.org>
Sent: Wednesday, October 16, 2013 11:46:42 AM
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.
--
Martin Sivák
msivak(a)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" <msivak(a)redhat.com>
> > To: "engine-devel" <engine-devel(a)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
> > msivak(a)redhat.com
> > Red Hat Czech
> > RHEV-M SLA / Brno, CZ
> >
> > _______________________________________________
> > Engine-devel mailing list
> > Engine-devel(a)ovirt.org
> >
http://lists.ovirt.org/mailman/listinfo/engine-devel
> >
> >
> >
>