chelder
chelder

Reputation: 3997

Does grails internationalization work in index.gsp?

If we type the following, the language of the web application changes properly:

http://localhost:8080/yourCoolWebApp/behappy/list?lang=en
http://localhost:8080/yourCoolWebApp/smile/list?lang=es

But if we type an uri that doesn't have a controller, the language shown is the default one. This is the case of index.gsp. If we type the following code, the shown language is the default one always:

http://localhost:8080/?lang=en
http://localhost:8080/?lang=es

In this old bug report, marked as won't fix, there is a solution. I tried to implement it. I changed the following line of my UrlMappings.groovy:

"/"(view:"/index")

by:

"/"(view:"/index", controller:"foo")

But, after a grails clean, index.gsp keep being in the default language always.

I also have another view without a controller, so I also had the following line of code in UrlMappings.groovy:

name contact: "/contact"(view:"contact")

I changed it by:

name contact: "/contact"(view:"contact", controller:"foo")

I got a: The requested resource is not available (/webAlojamientoUCA/WEB-INF/grails-app/views/foo/contacto.jsp)

I'm using Grails 2.2.4.

Upvotes: 0

Views: 310

Answers (1)

Aram Arabyan
Aram Arabyan

Reputation: 2359

Grails' i18n infrastructure relies on the logic passing through the controller layer

Yes you need to create/have controller !

Something like

UrlMappings

"/"(controller: 'index')

and controller

class IndexController {

    def index() {
    }
}

and view ${appName}/grails-app/views/index/index.gsp

Upvotes: 2

Related Questions