如何更改默认的message.properties [英] How to change the default message.properties
问题描述
假设我们有以下代码行:
Let's say we have the following line of code:
<p> <g:message code="nav.usuario.show" /> </p>
如果我们使用的是意大利计算机,Grails将首先查看messages_it.properties
.如果grails找不到nav.usuario.show=textLabel
,将尝试在messages.properties
中找到它.我想更改此行为以查看 message_es.properties
而不是默认 messages.properties
(但仅当标签不是当前语言环境语言时)
If we are using an italian computer, Grails will look at messages_it.properties
first. If grails desn't find nav.usuario.show=textLabel
there, will try to find it in messages.properties
. I want to change this behavior to look at message_es.properties
instead the default messages.properties
(but only if the label is not in the current locale language)
我尝试了以下代码,但没有看到任何变化. resources.groovy
:
I tried the following code, but I didn't see any change. resources.groovy
:
beans = {
localeResolver(org.springframework.web.servlet.i18n.SessionLocaleResolver) {
defaultLocale = new Locale("it","")
java.util.Locale.setDefault(defaultLocale)
}
}
推荐答案
只需将默认情况下所需的语言代码(例如messages_es.properties
)复制到默认的messages.properties
文件中.
Simply copy the code of the language you want by default (for example messages_es.properties
) to the default messages.properties
file.
如果要保留英语,则必须创建一个名称如messages_en.properties
的新文件.将messages.properties
的代码移到那里.
If you want to keep the English language, you have to create a new file with a name like messages_en.properties
. Move the code of messages.properties
there.
这篇关于如何更改默认的message.properties的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!