0

I develop a translation helper page in my pyramid based application. A new translation is saved in .po and .mo files via this:

po = polib.pofile(join(root, 'locale', lang, 'LC_MESSAGES', 'myapp.po'))
.....

po.save(join(root, 'locale', lang, 'LC_MESSAGES', 'myapp.po'))
po.save_as_mofile(join(root, 'locale', lang, 'LC_MESSAGES', 'myapp.mo'))

But the new translation does not take effect until I restart the application.

I need to reload the translation file right after the new translation file is saved without restarting the wsgi application.

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
sahama
  • 669
  • 8
  • 16

1 Answers1

1

Translations are cached for performance in Pyramid but you can setup pserve to automatically restart the wsgi server when the files change. Just add watch_files directive to your ini file. The watcher uses python glob module and so what is supported depends on if you're on python2 or python3 but you can experiment to find a regex that works. (For example, ** is not supported on python 2).

[pserve]
watch_files = myapp/locales/**/*
Michael Merickel
  • 23,153
  • 3
  • 54
  • 70