Play启动时是否读取所有支持的语言消息文件

时间:2014-03-24 06:53:07

标签: playframework-2.0

请确认Play 2.0框架是否在运行或编译时读取所有支持的消息文件。由于我目前的项目支持大约20种语言和启动需要花费很多时间。这是因为消息文件而发生。我只想知道播放框架在编译时读取所有消息文件。如果是,我们是否有任何替代方法使其只读取设置语言消息文件。

由于

1 个答案:

答案 0 :(得分:0)

消息文件内容在运行时中读取,特别是在应用程序启动时。在编译时不会以任何方式解析或处理消息文件。

我建议您查看this source code file底部的MessagesPlugin课程,以便更好地了解Play处理邮件文件的方式。基本算法如下:

On application startup:
  load the contents of the default messages file into a map
  for each locale l specified in the application.langs configuration value
    load the contents of the messages.l file into a map
  consolidate these maps into a single (locale -> file contents) super map 

如果您认为支持大量语言环境会影响应用程序的性能,则可以通过减少application.langs配置设置中支持的语言数量来测试此假设。