Hello all, What is $msg variable, and where can I read more about it? (is not in xwikivars.vm...) And how does $msg.get() works? Please, I really need some help. I want to include support for languages in my datepicker and Sergiu told me to put the strings in ApplicationRessources.properties and now I'm trying to get them in a js file with $msg.get("core.datepicker.somethingdefinedbymehere"), but it seems that the server does not know how $msg is, but it knows who $xwiki, $context and all other are.... So please, please, I would like to know more about this variable or how to get the strings from ApplicatonRessources. I'd really appreciate some help because I'm stuck on this.... Thank you very much, Evelina
Hi Evelina, On Jun 28, 2007, at 3:18 PM, [email protected] wrote:
Hello all,
What is $msg variable, and where can I read more about it? (is not in xwikivars.vm...) And how does $msg.get() works?
Please, I really need some help. I want to include support for languages in my datepicker and Sergiu told me to put the strings in ApplicationRessources.properties and now I'm trying to get them in a js file with $msg.get ("core.datepicker.somethingdefinedbymehere"), but it seems that the server does not know how $msg is, but it knows who $xwiki, $context and all other are....
The ApplicationResources files are used for templates and skin properties. However if you're developing an XWiki application (XAR) then you should use a page in your application to contain the translations as described on http://www.xwiki.org/xwiki/bin/view/ DevGuide/InternationalizingApplications Note that I don't know what you're developing... BTW this means that we need to create a translation page for the default wiki and put all translations in there and NOT in the ApplicationResources files.
So please, please, I would like to know more about this variable or how to get the strings from ApplicatonRessources.
See http://www.xwiki.org/xwiki/bin/view/DevGuide/ InternationalizingApplications -Vincent
I'd really appreciate some help because I'm stuck on this....
Thank you very much,
Evelina
Hi, It seems that I introduced a bug a while ago, but this is because the MessageTool is created in the wrong places. Now, to explain a bit how to find more information about $msg. If you don't know what variable is, you can write $msg.class to find out what kind of object is that. In this case, you find out it is a com.xpn.xwiki.web.XWikiMessageTool instance. Next, you open your favorite IDE (let's say Eclipse) and navigate to that class. You want to know where is that object placed in the context, so you can right click the class name, or the java file in the tree browser, and select References->Project. The first result is exactly XWiki.getMessage, which I told you to try. Since it is not in the API, you can look if there is an equivalent method in the api.XWiki class, which you can call from velocity. Another search result is XWiki.prepareResources. Looking at this method, you see that this is the place where the $msg variable is placed in the context: XWikiMessageTool msg = new XWikiMessageTool(bundle, context); context.put("msg", msg); If your script does not have $msg, then it means that this method is not called, or an error occurred before putting the MessageTool in the context. So let's see where is this method called. You right click the prepareResources method and search for References->Project, and so you see that it is called either in XWiki.prepareDocuments, or in XWikiightServiceImpl#checkAccess. in XWiki.prepareDocuments it is only created for a registration request, so this leaves the checkAccess as the only place where prepareResources is called. After looking inside checkAccess, I see that all the code branches have a prepareResources call, so the problem is that checkAccess is not called in some places. Searching for the references to XWikiRightService#checkAccess (the interface method, not the implementation one), we see that the only relevant place where it is called is XWiki#checkAccess, and opening this method we see: if (action.equals("skin") && doc.getSpace().equals("skins")) return true; return getRightService().checkAccess(action, doc, context); So the problem is that for the /skin/ action, we skip the checkAccess method, thus we don't create the MessageTool. I'll fix this problem right away, so you should svn update in a few minutes. On 6/28/07, [email protected] <[email protected]> wrote:
Hello all,
What is $msg variable, and where can I read more about it? (is not in xwikivars.vm...) And how does $msg.get() works?
Please, I really need some help. I want to include support for languages in my datepicker and Sergiu told me to put the strings in ApplicationRessources.properties and now I'm trying to get them in a js file with $msg.get("core.datepicker.somethingdefinedbymehere"), but it seems that the server does not know how $msg is, but it knows who $xwiki, $context and all other are....
So please, please, I would like to know more about this variable or how to get the strings from ApplicatonRessources.
I'd really appreciate some help because I'm stuck on this....
Thank you very much,
Evelina
Sergiu -- http://purl.org/net/sergiu
As always, Sergiu saved my day :D. Indeed, now $msg.get() from javascript works fine in xwiki, although usually it shouldn't work, as Catalin said (javascript is client-side and velocity server-side) but in xwiki somehow really works. Thanks again Sergiu. And of course, thank you all who answered my question. It's a very nice community here at xwiki :D and I'm happy to be part of it.
Hi, Evelina. [email protected] wrote:
What is $msg variable, and where can I read more about it? (is not in xwikivars.vm...) And how does $msg.get() works?
As I know, $msg == java context.get("msg") == XWikiMessageTool class You can read about it in javadocs in xwiki-platform-core/src/main/java/com/xpn/xwiki/web/XWikiMessageTool.java
Please, I really need some help. I want to include support for languages in my datepicker and Sergiu told me to put the strings in ApplicationRessources.properties and now I'm trying to get them in a js file with $msg.get("core.datepicker.somethingdefinedbymehere"), but it seems that the server does not know how $msg is, but it knows who $xwiki, $context and all other are....
As I know, external javascript files(<script src=..>) do not parsed by xwiki velocity/groovy parsers (as .vm files), so xwiki variables won't work here. Perhaps you need to create vm file with your javascripts and include it to somewhere by #template(yourfile.vm) Sorry I don't know else more about it :) -- Artem Melentyev
Artem, in the current sources, javascript files that get through SkinAction are interpreted by velocity and groovy. Those that are taken from the filesystem directly indeed cannot be parsed. On 6/29/07, Artem Melentyev <[email protected]> wrote:
As I know, external javascript files(<script src=..>) do not parsed by xwiki velocity/groovy parsers (as .vm files), so xwiki variables won't work here. Perhaps you need to create vm file with your javascripts and include it to somewhere by #template(yourfile.vm) Sorry I don't know else more about it :)
Sergiu -- http://purl.org/net/sergiu
participants (4)
-
Artem Melentyev -
evelyne24@gmail.com -
Sergiu Dumitriu -
Vincent Massol