[xwiki-users] Object properties' translations

Sergiu Dumitriu sergiu.dumitriu at gmail.com
Tue Jan 9 02:06:01 CET 2007


Here are the two files.

You should create a new Panel object (introduced in XWiki 1.0 beta-s) and
copy the contents of the Panels.TranslateSpecial file into the panel code.
Note that you must change the names of the classes which you would like
translated. Then, you should modify the XWiki global preferences to include
the new panel.

Second, You should create a document named XWiki.TranslateSpecial and copy
the content from the other file.

The Translate panel must be adapted to support more than two languages, as I
didn't have the time to make it extensible enough. Now it just works with
two languages.


Regarding the code, no, there's nothing written yet, just a bunch of ideas
waiting to be implemented.


On 1/9/07, Marc Lijour <marc at lijour.net> wrote:
>
> Indeed, very interesting.
>
> Could we record this discussion somewhere on a page at xwiki.org?
> And I would take the code as well if you'd like to share it.
>
> Thanks!
>
> On Monday 08 January 2007 19:17, Karttunen Petteri wrote:
> > Thank you Sergiu! That information clarified the issue for me and helps
> me
> > a lot in planning. I can see from the schema and id generation
> algorithms
> > that object linking on document translation level is not too simple
> thing
> > to change. Maybe that's a little too heavy an issue for me to
> contribute,
> > but of curiosity: do you have plans already how to solve this? Code in
> SVN?
> >
> >
> >
> > In any case  I'm interested of the panel and page code you mentioned so
> > please send it to me. Thanks!
>
>
>
>
> --
> You receive this message as a subscriber of the xwiki-users at objectweb.orgmailing list.
> To unsubscribe: mailto:xwiki-users-unsubscribe at objectweb.org
> For general help: mailto:sympa at objectweb.org?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xwiki.org/pipermail/users/attachments/20070109/4affe289/attachment-0001.htm 
-------------- next part --------------
#if(($context.action == "inline") && $hasedit)
#if($context.language == "en")
#set($otherlang = "ro")
#else
#set($otherlang = "en")
#end
#macro(translationpanel $classname)
#set($crtobj = "")
#set($crtobj = $doc.getObject($classname, "lang", $context.language, true))
#if($crtobj == "")
## do nothing
#elseif((!$crtobj.getProperty("lang")) || ($crtobj.getProperty("lang").value.trim().equals("")))
#panelheader($msg.get("translate"))
* $msg.get("objlangnotset")!
* $msg.get("setobjlangto"): <a href="$doc.getURL("save", "${classname}_${crtobj.number}_lang=en&amp;xredirect=${doc.getURL('inline', 'language=en')}")">en</a> <a href="$doc.getURL("save", "${classname}_${crtobj.number}_lang=ro&amp;xredirect=${doc.getURL('inline', 'language=ro')}")">ro</a>
#panelfooter()
#else
#panelheader($msg.get("translate"))
#if($crtobj.getProperty("lang").value == $context.language)
* $msg.get("editedlanguage"): $context.language
#set($crtobjtr = $doc.getObject($classname, "lang", ${otherlang}, false))
#if(!$crtobjtr)
* $msg.get("translateinlanguage") <a href="$xwiki.getURL("XWiki.TranslateSpecial", "view", "page=${doc.fullName}&amp;from=${context.language}&amp;to=${otherlang}&amp;class=${classname}")">$otherlang</a>
#else
* $msg.get("editinlanguage") <a href="$doc.getURL("inline", "language=${otherlang}")">${otherlang}</a>
#end
#end
#panelfooter()
#end ## crtobj
#end ## macro
#translationpanel("XWiki.SomeClass")
#translationpanel("XWiki.AnotherClass")
#end
-------------- next part --------------
#set($page = $request.getParameter("page"))
#set($class = $request.getParameter("class"))
#set($from = $request.from)
#set($to = $request.to)
#if(!$page || $page.trim().equals("") || !$from || !$to || !$class)
1 Translate pages
Nothing to see here, move along
#else
#set($pagedoc = $xwiki.getDocument($page))
Translating $page from $from to $to, with class $class

#set($pageobj = $pagedoc.getObject($class, "lang", $to, false))
#if($pageobj)
Target already exists!
$response.sendRedirect($pagedoc.getURL("inline", "language=$to"))
#else
#set($pageobj = $pagedoc.getObject($class, "lang", $from, false))
#if($pageobj)
Good, creating clone
#set($pageobj = $pageobj.getXWikiObject())
#set($cloneobj = $pageobj.clone())
#set($discard = $cloneobj.set("lang", $to, $context.context))
$pagedoc.document.addObject($class, $cloneobj)
$pagedoc.save()
$response.sendRedirect($pagedoc.getURL("inline", "language=$to"))
#else
Source does not exist!
$response.sendRedirect($pagedoc.getURL("inline", "language=$from"))
#end
#end
#end


More information about the users mailing list