fundacion-sadosky / genis

GENis
https://www.fundacionsadosky.org.ar/genis/
GNU Affero General Public License v3.0
7 stars 3 forks source link

Dynamically Change Language #117

Open javieriserte opened 2 months ago

javieriserte commented 2 months ago

A prototype...

imagen

imagen

javieriserte commented 2 months ago

For backend error messages:

  1. define an API endpoint to change language:
    def changeLanguage(lang: String): Action[AnyContent] = Action {
      implicit request => {
        // val pLang = request.cookies.get("PLAY_LANG").map(_.value)
        // val l = implicitly[Lang]
        val s0 = Messages("error.E0304")
        Redirect("/home")
          .withLang(Lang(lang))
      }
    }
  2. Create a messages.en file with all the messages translated.
  3. Add a application.langs key in the configuration file.
  4. All messages should be generated in the API end point functions (not in functions used by them), where the request object is passed as argument. The value of the language is set in the cookie PLAY_LANG, this value is used implicitly by the Messages object.