当我在开发模式下运行我的 Play 2.6 应用程序时,它已正确本地化为请求的语言。但是在生产模式下,消息的占位符不会被它们的实际值替换。换句话说:
在messages.en
我有:
home.location = Germany
在我的 Twirl 模板中,我有:
@()(implicit messages: MessagesProvider)
...
<span>@messages.messages("home.location")</span>
在控制器中:
class HomeController @Inject()(components: ControllerComponents, langs: Langs)
extends AbstractController(components)
with I18nSupport {
def home: Action[AnyContent] = Action { implicit request =>
Ok(views.html.home())
}
}
当我在开发模式下运行时,它呈现为
<span>Germany</span>
但在 prod 模式下:
<span>home.location</span>
当我在 SBT 中以 prod 模式运行以及将其打包sbt-native-packager
并独立运行时,就会发生这种情况。我拿错了吗?