The locale for the current session. Determined by either `get_user_locale`, which you can override to set the locale based on, e.g., a user preference stored in a database, or `get_browser_locale`, which uses the ``Accept-Language`` header. .. versionchanged
(self)
| 1249 | |
| 1250 | @property |
| 1251 | def locale(self) -> tornado.locale.Locale: |
| 1252 | """The locale for the current session. |
| 1253 | |
| 1254 | Determined by either `get_user_locale`, which you can override to |
| 1255 | set the locale based on, e.g., a user preference stored in a |
| 1256 | database, or `get_browser_locale`, which uses the ``Accept-Language`` |
| 1257 | header. |
| 1258 | |
| 1259 | .. versionchanged: 4.1 |
| 1260 | Added a property setter. |
| 1261 | """ |
| 1262 | if not hasattr(self, "_locale"): |
| 1263 | loc = self.get_user_locale() |
| 1264 | if loc is not None: |
| 1265 | self._locale = loc |
| 1266 | else: |
| 1267 | self._locale = self.get_browser_locale() |
| 1268 | assert self._locale |
| 1269 | return self._locale |
| 1270 | |
| 1271 | @locale.setter |
| 1272 | def locale(self, value: tornado.locale.Locale) -> None: |
nothing calls this directly
no test coverage detected