Skip to main content



      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 12:34 Go to next message
Eclipse UserFriend
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 12:35] by Moderator

Re: Why Enumerators save the Literal into the file [message #1863928 is a reply to message #1863926] Wed, 06 March 2024 15:03 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Why Enumerators save the Literal into the file [message #1863932 is a reply to message #1863928] Thu, 07 March 2024 01:45 Go to previous messageGo to next message
Eclipse UserFriend
That being said, of course you can specialize the XyzFactoryImpl's createFromString/convertToString however you like.
Re: Why Enumerators save the Literal into the file [message #1863950 is a reply to message #1863932] Thu, 07 March 2024 15:37 Go to previous messageGo to next message
Eclipse UserFriend
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 01:48 Go to previous message
Eclipse UserFriend
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...
Previous Topic:Instance level permissions
Next Topic:Track change notifications
Goto Forum:
  


Current Time: Sat Jul 12 14:39:26 EDT 2025

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

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

Back to the top