Index: core/xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java =================================================================== --- core/xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java (revision 23911) +++ core/xwiki-core/src/main/java/com/xpn/xwiki/doc/XWikiDocument.java (working copy) @@ -533,6 +533,17 @@ // document's context. For example this is true for the Admin page, see // http://jira.xwiki.org/jira/browse/XWIKI-4274 for more details. + // If the user is speaking a language other than the default, we must switch documents. + // This is already handled in the old renderer. + XWikiDocument tdoc = getTranslatedDocument(context); + + // Get the revision from the context, mimicing behavior of getTranslatedContent + // to maintain consistancy because getTranslatedContent was used previously. + String rev = (String) context.get("rev"); + if (rev != null && rev.length() != 0 && !tdoc.getVersion().equals(rev)) { + tdoc = context.getWiki().getDocument(tdoc, rev, context); + } + String renderedContent; Object isInRenderingEngine = context.get("isInRenderingEngine"); @@ -544,11 +555,10 @@ context.put("isInRenderingEngine", true); // If the Syntax id is "xwiki/1.0" then use the old rendering subsystem. Otherwise use the new one. - if (is10Syntax()) { - renderedContent = context.getWiki().getRenderingEngine().renderDocument(this, context); + if (tdoc.is10Syntax()) { + return context.getWiki().getRenderingEngine().renderText(tdoc.getContent(), this, context); } else { - renderedContent = - performSyntaxConversion(getTranslatedContent(context), getSyntaxId(), targetSyntax, true); + return performSyntaxConversion(tdoc.getXDOM(), tdoc.getSyntaxId(), targetSyntax, true); } } finally { if (isInRenderingEngine != null) { @@ -557,7 +567,6 @@ context.remove("isInRenderingEngine"); } } - return renderedContent; } public String getRenderedContent(XWikiContext context) throws XWikiException Index: core/xwiki-core/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java =================================================================== --- core/xwiki-core/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java (revision 23911) +++ core/xwiki-core/src/test/java/com/xpn/xwiki/doc/XWikiDocumentTest.java (working copy) @@ -673,20 +673,19 @@ this.document.setContent("*bold*"); this.document.setSyntaxId("xwiki/1.0"); - this.mockXWikiRenderingEngine.expects(once()).method("renderDocument").will(returnValue("bold")); + this.mockXWikiRenderingEngine.expects(once()).method("renderText").will(returnValue("bold")); assertEquals("bold", this.document.getRenderedContent(getContext())); this.translatedDocument = new XWikiDocument(); - this.translatedDocument.setContent("~italic~"); + this.translatedDocument.setContent("//italic//"); this.translatedDocument.setSyntaxId("xwiki/2.0"); this.translatedDocument.setNew(false); this.mockXWiki.stubs().method("getLanguagePreference").will(returnValue("fr")); this.mockXWikiStoreInterface.stubs().method("loadXWikiDoc").will(returnValue(this.translatedDocument)); - this.mockXWikiRenderingEngine.expects(once()).method("renderDocument").will(returnValue("italic")); - assertEquals("italic", this.document.getRenderedContent(getContext())); + assertEquals("

italic

", this.document.getRenderedContent(getContext())); } public void testGetRenderedContent() throws XWikiException @@ -697,14 +696,15 @@ assertEquals("

bold

", this.document.getRenderedContent(getContext())); this.translatedDocument = new XWikiDocument(); - this.translatedDocument.setContent("//italic//"); + this.translatedDocument.setContent("~italic~"); this.translatedDocument.setSyntaxId("xwiki/1.0"); this.translatedDocument.setNew(false); this.mockXWiki.stubs().method("getLanguagePreference").will(returnValue("fr")); this.mockXWikiStoreInterface.stubs().method("loadXWikiDoc").will(returnValue(this.translatedDocument)); + this.mockXWikiRenderingEngine.expects(once()).method("renderText").will(returnValue("italic")); - assertEquals("

italic

", this.document.getRenderedContent(getContext())); + assertEquals("italic", this.document.getRenderedContent(getContext())); } public void testGetRenderedContentWithSourceSyntax() throws XWikiException