Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Annotation to signal resource bundle key replacement
Annotation to signal resource bundle key replacement [message #419749] Thu, 05 June 2008 00:21 Go to next message
Cameron Bateman is currently offline Cameron BatemanFriend
Messages: 481
Registered: July 2009
Senior Member
I'm using the element eAnnotation in my ecore models to signal that a
specific element should map to a particular feature during load from an
XML file using the XMLResource implementation. This works well.

I have some data in these XML files, that I would like to put through a
resource bundle translation before the data is set. For example, I have
feature called "displayName" on some object that I load string data into
like:

<displayName>%some.external.key</displayName>

Is there any eAnnotation I can add to the displayName feature definition
that would cause some.external.key to be looked up in a properties file
and if present, use the corresponding value to eSet the displayName
feature's value (assuming type and cardinality etc. match)?

If not, is it feasible for me to construct such an annotation and
sub-class XMLResourceImpl or one of it's load helpers to do this?


--Cam
Re: Annotation to signal resource bundle key replacement [message #419750 is a reply to message #419749] Thu, 05 June 2008 00:46 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Cam,

I could imagine defining a derived unchangeable feature that would use
the value of another feature to do a lookup in some table or properties
file, but no such mechanism exists today. I.e., I can imagine doing
this at the level of the model, but not so much as something done during
loading, since the inverse would clearly need to be done during saving.
That being said, in general, it seems best to have the data be the same
for all languages and to have translations be something left to the
viewing mechanisms. Consider, for example, if databases support what
you've just described. A better approach might be to define an
enumeration and to provide translated strings that correspond to those
literals; the item providers generate a key for each enumeration literal
that can be translated and is used in the properties view...


Cameron Bateman wrote:
> I'm using the element eAnnotation in my ecore models to signal that a
> specific element should map to a particular feature during load from
> an XML file using the XMLResource implementation. This works well.
>
> I have some data in these XML files, that I would like to put through
> a resource bundle translation before the data is set. For example, I
> have feature called "displayName" on some object that I load string
> data into like:
>
> <displayName>%some.external.key</displayName>
>
> Is there any eAnnotation I can add to the displayName feature
> definition that would cause some.external.key to be looked up in a
> properties file and if present, use the corresponding value to eSet
> the displayName feature's value (assuming type and cardinality etc.
> match)?
>
> If not, is it feasible for me to construct such an annotation and
> sub-class XMLResourceImpl or one of it's load helpers to do this?
>
>
> --Cam
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Tracking resource changes using AdapterFactoryContentProvider
Next Topic:Re: Change tracking
Goto Forum:
  


Current Time: Fri Apr 26 08:27:43 GMT 2024

Powered by FUDForum. Page generated in 0.03617 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top