Session expiry translation to another language

Hello dear Forummers !

Is it possible to translate to another language Session expiry alert little pop-up window?

Yes! you would have to create a custom error handler:

Then you could translate as needed!

EDIT:

You would have to create your own ā€œReset Sessionā€ Form that pops up.

Thank you very much Antonys

But how to create own ā€œReset Sessionā€ Form that pops up?
Where to find trigger that Session is ended?

For the first part of your question, you can find basic info about creating a popup here:

Anvil Docs | Alerts and Notifications.

To build the form, you need to learn a little about creating layouts with code, as opposed to using the drag-and-drop designer:

https://pythonanvil.com/#section-18
https://pythonanvil.com/#section-26.4

Here’s a little example of how to use a dropdown, in an alert layout:

from ._anvil_designer import Form1Template
from anvil import *

class Form1(Form1Template):

  def __init__(self, **properties):
    self.init_components(**properties)
    languages=DropDown(items=['English', 'French', 'German'])
    alert(
      content=languages,
      title="Pick a language"
    )
    alert(f"language: {languages.selected_value}")

https://anvil.works/build#clone:MDASRAZBCIP2PFFQ=2SKMQZZSUWGTJY5ONTA3FL25

To see the reference for that DropDown widget, check out the documentation in the Anvil docs:

1 Like

For the second part of your question, the link you posted shows the following error handling code:

try:
  anvil.server.call("foo")
except anvil.server.SessionExpiredError:
  anvil.server.reset_session()
  # This will work now, but with a blank session
  anvil.server.call("foo")

You could, for example, do something like this:

try:
  anvil.server.call("foo", None)
except anvil.server.SessionExpiredError:
  anvil.server.reset_session()
  languages=DropDown(items=['English', 'French', 'German'])
  alert(
      content=languages,
      title="Pick a language"
    )
  alert(f"language: {languages.selected_value}")
  print(anvil.server.call('foo', languages.selected_value))
1 Like

Couldn’t have layed it out better!

Thanks Nick!