Caching an action in a multi-language website using Play Framework's Cached API

后端 未结 2 1367
闹比i
闹比i 2021-01-01 15:32

In order to cache actions per label and language for a given number of seconds, I wrote the following helper method (where label, is the name I give to my action):



        
2条回答
  •  天命终不由人
    2021-01-01 16:10

    Maybe the problem is in the getLanguage method. Try this, as recommended by the docs:

    def getLanguage(request: RequestHeader): String = {
        request.acceptLanguages
               .map(_.code)
               .headOption
               .getOrElse(helpers.LanguageHelpers.FRENCH)
    }
    

    Also, take a look at Controller.request2lang() method and see if it could be helpful to you.

提交回复
热议问题