Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Why Enumerators save the Literal into the file(Literal change with language but the name does not, therefore the name should be saved)
Why Enumerators save the Literal into the file [message #1863926] Wed, 06 March 2024 17:34 Go to next message
Yigal Spinner is currently offline Yigal SpinnerFriend
Messages: 127
Registered: July 2009
Senior Member
I've an application that is using EMF at the core.
As long as I have English speaking customers, I have no issues.

But now I have Japanese customer and I need to translate all the "Literals" of the Enumerator classes to Japanese.
That when I notice that the XMIResource actually saves the "Literal" value and not the "Name" value. Therefore my Japanese version fails loading since it can't load the data that the values are in English and the eCore has Japanese for Literal..
I assumed that the Name will not change since it is the Enumeration definition and build ny application around that idea. like:
N41(0, "N41", "Two State"),
The Resource saves the "Two State" into the file, but that can't be loaded since the Japanese version has other literal value.

Is there a way to make the XMIResource save and load the "Name" and not the "Literal"?

Thanks
Yigal

[Updated on: Wed, 06 March 2024 17:35]

Report message to a moderator

Re: Why Enumerators save the Literal into the file [message #1863928 is a reply to message #1863926] Wed, 06 March 2024 20:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
All these values, name, literal, and value, are fixed in the *.ecore model and do not depend on the locale. Only the presentation to the users is localized via the item providers and changes depending on the locale, e.g.,

https://github.com/eclipse-emf/org.eclipse.emf/blob/2b463bfafcac5019e55f16b3f4f36d407913b3bf/plugins/org.eclipse.emf.codegen.ecore.ui/plugin.properties#L269-L271

So no, there is no way to create a serialization that is dependent on the locale where it is produced or consumed.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Why Enumerators save the Literal into the file [message #1863932 is a reply to message #1863928] Thu, 07 March 2024 06:45 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
That being said, of course you can specialize the XyzFactoryImpl's createFromString/convertToString however you like.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Why Enumerators save the Literal into the file [message #1863950 is a reply to message #1863932] Thu, 07 March 2024 20:37 Go to previous messageGo to next message
Yigal Spinner is currently offline Yigal SpinnerFriend
Messages: 127
Registered: July 2009
Senior Member
Hi Ed
I tried the idea of modifying the generated Factory Impl. However, that also impacts the databinding code.
I only want to force a change during the save operation of the data into the file.

I can't figure out how to acomplish that.
Yigal
Re: Why Enumerators save the Literal into the file [message #1863958 is a reply to message #1863950] Fri, 08 March 2024 06:48 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
The debugger would help you figure that out. For XML serialization, the work is done by these methods:

org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.convertToString(EFactory, EDataType, Object)
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.createFromString(EFactory, EDataType, String)

It seems strange to create a serialization that is not portable across locales...


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Instance level permissions
Next Topic:Track change notifications
Goto Forum:
  


Current Time: Wed May 01 23:55:30 GMT 2024

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

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

Back to the top