Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to customize XText code generation to NL-enable plugin?
How to customize XText code generation to NL-enable plugin? [message #540576] Wed, 16 June 2010 14:43 Go to next message
Samantha Chan is currently offline Samantha ChanFriend
Messages: 60
Registered: July 2009
Member
Hi all,

I need to make sure that I can NL-enable my editor. XText code generation leave hard-code strings in the the plugin.xml or in java source. I would like to either put in "NON-NLS" tag in the generated code if the string is not supposed to be externalized. I would also like to externalize NL strings into properties files.

Is there a way to customize the code generation to achieve this?

Thanks...
Samantha
Re: How to customize XText code generation to NL-enable plugin? [message #540631 is a reply to message #540576] Wed, 16 June 2010 18:41 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
You can modify the plugin.xml manually it won't be overwritten if it
exists. Changing the code generator is generally only possible by
excluding generator fragments.

Of course you could check out the code and modify it yourself.

What generated Java code contains these hard coded strings?

Sven



Samantha Chan schrieb:
> Hi all,
>
> I need to make sure that I can NL-enable my editor. XText code
> generation leave hard-code strings in the the plugin.xml or in java
> source. I would like to either put in "NON-NLS" tag in the generated
> code if the string is not supposed to be externalized. I would also
> like to externalize NL strings into properties files.
> Is there a way to customize the code generation to achieve this?
>
> Thanks...
> Samantha


--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: How to customize XText code generation to NL-enable plugin? [message #540964 is a reply to message #540576] Thu, 17 June 2010 18:55 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Samantha,

I'm not aware of hardcoded strings, that cannot be substituted by
specialized services. I just wrote a blogpost on how to customize the
error messages in the editor:
http://zarnekow.blogspot.com/2010/06/customizing-error-messa ges-in-xtext-10.html

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 16.06.10 16:43, schrieb Samantha Chan:
> Hi all,
>
> I need to make sure that I can NL-enable my editor. XText code
> generation leave hard-code strings in the the plugin.xml or in java
> source. I would like to either put in "NON-NLS" tag in the generated
> code if the string is not supposed to be externalized. I would also like
> to externalize NL strings into properties files.
> Is there a way to customize the code generation to achieve this?
>
> Thanks...
> Samantha
Re: How to customize XText code generation to NL-enable plugin? [message #541551 is a reply to message #540964] Mon, 21 June 2010 14:18 Go to previous messageGo to next message
Samantha Chan is currently offline Samantha ChanFriend
Messages: 60
Registered: July 2009
Member
Thanks for the response.

For me to fully NL-enabled my editor, I need all human-readable strings in the generated plugins must be externalized. These include the strings in plugin.xml and in the java source.

I ran the externalize string tool from Eclipse, and this is where I found the hard-code strings:

From the core plugin:
... parser/antlr/MyLangParser
... parser/antlr/MyLangAntlrTokenFileProfier
... parser/antlr/internal/InternalMyLangParser
... parser/antlr/internal/InternalMyLangLexer
... services/MyLangGrammerAccess

I think these strings are just rule names, and should not be exposed to the user. I don't think there are any error messages produced by these files. Although it would be nice if I can add the NON_NLS tag to these strings, I don't think they pose a problem.

In the UI plugin,
plugin.xml - strings for preference pages, actions contributed via extensions, etc
...ui/contentassit/antlr/MyLangParser
...ui/contentassit/antlr/internal/InternalMyLangLexer
...ui/contentassit/antlr/internal/InternalMyLangParser
...ui/internal/MyLangActivator

Again, I think these strings are just rule names, and should be ok.

In the UI plugin, if I understand correctly, I can manually externalize the strings from the pluginx.xml, and they would not be overwritten if my plugins are regenerated? If that's the case, then I think I am ok.

The more problematic strings are found in XText itself.

I looked at org.eclipse.xtext.ui:
* I found that all human-readable strings like command labels, menus, etc, are not externalized.
* Secondly, I also found that strings are just hard-coded in the Java source. e.g. ToggleSLCommentAction, the error messages are hard-coded in the code where the error dialog is opened.

To fully NL-enabled a plugin, I need more than just being able to customize error messages. All human-readable strings, including UI labels, error messages, preference pages, dialogs, etc, just be externalized to properties files.

What is the current status of NL-enablement of XText? Is it correct to assume that XText is not NL-ready? What are your plans to externalize the strings in the core XText plugins / or perhaps provide translated version of XText support?

Thanks for your help.
Samantha
Re: How to customize XText code generation to NL-enable plugin? [message #541694 is a reply to message #541551] Tue, 22 June 2010 08:21 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Samantha,

it is correct that Xtext will override your plugin.xml.
Regarding the hardcoded strings in xtext.ui: Would you please file a
ticket and attach your findings. It's very likely that we'll fix those
ones in the upcoming service release.

Thanks,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 21.06.10 16:18, schrieb Samantha Chan:
> Thanks for the response.
>
> For me to fully NL-enabled my editor, I need all human-readable strings
> in the generated plugins must be externalized. These include the strings
> in plugin.xml and in the java source.
>
> I ran the externalize string tool from Eclipse, and this is where I
> found the hard-code strings:
>
> From the core plugin:
> .. parser/antlr/MyLangParser
> .. parser/antlr/MyLangAntlrTokenFileProfier
> .. parser/antlr/internal/InternalMyLangParser
> .. parser/antlr/internal/InternalMyLangLexer
> .. services/MyLangGrammerAccess
>
> I think these strings are just rule names, and should not be exposed to
> the user. I don't think there are any error messages produced by these
> files. Although it would be nice if I can add the NON_NLS tag to these
> strings, I don't think they pose a problem.
>
> In the UI plugin,
> plugin.xml - strings for preference pages, actions contributed via
> extensions, etc
> ..ui/contentassit/antlr/MyLangParser
> ..ui/contentassit/antlr/internal/InternalMyLangLexer
> ..ui/contentassit/antlr/internal/InternalMyLangParser
> ..ui/internal/MyLangActivator
>
> Again, I think these strings are just rule names, and should be ok.
>
> In the UI plugin, if I understand correctly, I can manually externalize
> the strings from the pluginx.xml, and they would not be overwritten if
> my plugins are regenerated? If that's the case, then I think I am ok.
>
> The more problematic strings are found in XText itself.
>
> I looked at org.eclipse.xtext.ui:
> * I found that all human-readable strings like command labels, menus,
> etc, are not externalized. * Secondly, I also found that strings are
> just hard-coded in the Java source. e.g. ToggleSLCommentAction, the
> error messages are hard-coded in the code where the error dialog is opened.
>
> To fully NL-enabled a plugin, I need more than just being able to
> customize error messages. All human-readable strings, including UI
> labels, error messages, preference pages, dialogs, etc, just be
> externalized to properties files.
>
> What is the current status of NL-enablement of XText? Is it correct to
> assume that XText is not NL-ready? What are your plans to externalize
> the strings in the core XText plugins / or perhaps provide translated
> version of XText support?
>
> Thanks for your help.
> Samantha
Re: How to customize XText code generation to NL-enable plugin? [message #541767 is a reply to message #541694] Tue, 22 June 2010 13:31 Go to previous messageGo to next message
Samantha Chan is currently offline Samantha ChanFriend
Messages: 60
Registered: July 2009
Member
Thanks for all the help. I will really help me if this can be fixed in the 1.0 service release.

I opened this defect:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=317578

Lastly, if this is going to be addressed in the next service release, when is your next service release? Do you follow base Eclipse service schedule?

Thanks...
Samantha
Re: How to customize XText code generation to NL-enable plugin? [message #541811 is a reply to message #541767] Tue, 22 June 2010 14:29 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Samantha,

we have not yet settled a schedule for this one. Last years first
service release of Xtext (0.7.1) was available approx 4 weeks after
Xtext 0.7.0. I'ld guess that we aim at a release date around Aug 15 but
- as I already mentioned - nothing's carved in stone.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 22.06.10 15:31, schrieb Samantha Chan:
> Thanks for all the help. I will really help me if this can be fixed in
> the 1.0 service release.
>
> I opened this defect:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=317578
>
> Lastly, if this is going to be addressed in the next service release,
> when is your next service release? Do you follow base Eclipse service
> schedule?
>
> Thanks...
> Samantha
Previous Topic:Automatically insert spaces
Next Topic:b3 status update
Goto Forum:
  


Current Time: Thu Apr 18 05:12:14 GMT 2024

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

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

Back to the top