我正在使用多语言 grails 应用程序(英语和阿拉伯语),我希望当用户选择阿拉伯语时,视图的标签将位于页面的右侧,而英语位于左侧,如何实现?
谢谢
我正在使用多语言 grails 应用程序(英语和阿拉伯语),我希望当用户选择阿拉伯语时,视图的标签将位于页面的右侧,而英语位于左侧,如何实现?
谢谢
If the views have differences beyond simple string substitution, I would recommend using a different set of views based on locale:
Example controller code:
import org.springframework.web.servlet.support.RequestContextUtils as RCU
class ExampleController {
final static String englishLanguageCode = new Locale('en').getLanguage()
final static String arabicLanguageCode = new Locale('ar').getLanguage()
def differentViews() {
def currentLocale = RCU.getLocale(request)
switch(currentLocale.language) {
case englishLanguageCode:
render view: 'englishView'
break
case arabicLanguageCode:
render view: 'arabicView'
break
default:
// pick a default view or error page, etc.
}
}
}
您可以通过messages.properties 文件在grails 中使用国际化,您可以在文件中定义消息签名,并且可以通过URL 上的?lang=es 访问它们,您可能需要有两个文件,一个用于英语,另一个用于阿拉伯语。
例如在 messages.properties 中定义:
vendor.link.dashboardLink = Vendor Dashboard
在 GSP 页面上,您可以像这样访问它:
<g:message code="vendor.link.dashboardLink" />
您可以在 grails doc 中找到有关内部化的更多信息,请查看http://grails.org/doc/2.2.1/guide/i18n.html