mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
fix: i18n User.language_code is optional (#871)
user.language_code is Optional and may raise an exception #870
This commit is contained in:
parent
79588b7c5d
commit
b50500e28d
1 changed files with 1 additions and 1 deletions
|
|
@ -118,7 +118,7 @@ class SimpleI18nMiddleware(I18nMiddleware):
|
|||
)
|
||||
|
||||
event_from_user: Optional[User] = data.get("event_from_user", None)
|
||||
if event_from_user is None:
|
||||
if event_from_user is None or event_from_user.language_code is None:
|
||||
return self.i18n.default_locale
|
||||
try:
|
||||
locale = Locale.parse(event_from_user.language_code, sep="-")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue