Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically Change Language #117

Open
javieriserte opened this issue Aug 9, 2024 · 2 comments
Open

Dynamically Change Language #117

javieriserte opened this issue Aug 9, 2024 · 2 comments

Comments

@javieriserte
Copy link
Collaborator

No description provided.

javieriserte added a commit that referenced this issue Aug 9, 2024
@javieriserte
Copy link
Collaborator Author

A prototype...

imagen

imagen

javieriserte added a commit that referenced this issue Aug 12, 2024
@javieriserte
Copy link
Collaborator Author

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))
      }
  }
  1. Create a messages.en file with all the messages translated.
  2. Add a application.langs key in the configuration file.
  3. 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.

javieriserte added a commit that referenced this issue Aug 27, 2024
javieriserte added a commit that referenced this issue Aug 27, 2024
javieriserte added a commit that referenced this issue Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant