Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale passed in as parameter in args is now taken into account when rendering. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions grails-app/i18n/messages_fr.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
label = french
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class XhtmlDocumentService {
protected generateXhtml(Map args) {
def xhtmlWriter = new StringWriter()

RenderEnvironment.with(grailsApplication.mainContext, xhtmlWriter) {
RenderEnvironment.with(grailsApplication.mainContext, xhtmlWriter, args.locale) {
createTemplate(args).make(args.model).writeTo(xhtmlWriter)
}

Expand Down
1 change: 1 addition & 0 deletions grails-app/views/_simple.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
<body>
<p>This is a PDF!</p>
<p>${var}</p>
<p>Locale specific content: ${message(code: 'label')}</p>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class RenderingServiceSpec extends IntegrationSpec {
then:
notThrown(Exception)
}

def renderTemplateInPlugin() {
when:
renderer.render(pluginTemplate)
Expand All @@ -63,7 +63,7 @@ abstract class RenderingServiceSpec extends IntegrationSpec {
then:
thrown(UnknownTemplateException)
}


def renderToResponse() {
given:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ class PdfRenderingServiceSpec extends RenderingServiceSpec {
def getRenderer() {
pdfRenderingService
}

def renderWithLocaleArgument(){
given:
def response = createMockResponse()
when:
renderer.render(getSimpleTemplate([locale: Locale.FRENCH]), response)
def matcher = new PDFTextStripper().getText(PDDocument.load(new ByteArrayInputStream(response.contentAsByteArray))) =~ /french/
then:
matcher.size() == 1
}

protected extractTextLines(Map renderArgs) {
extractTextLines(createPdf(renderArgs))
Expand Down