fix(babel): Fallback on empty locale.
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
import gettext
|
from typing import Optional
|
||||||
import logging
|
import logging
|
||||||
from contextvars import ContextVar
|
from contextvars import ContextVar
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
|
import gettext
|
||||||
|
|
||||||
from discord.app_commands import Translator, locale_str
|
from discord.app_commands import Translator, locale_str
|
||||||
from discord.enums import Locale
|
from discord.enums import Locale
|
||||||
|
|
||||||
@@ -70,7 +72,8 @@ class LeoBabel(Translator):
|
|||||||
async def unload(self):
|
async def unload(self):
|
||||||
self.translators.clear()
|
self.translators.clear()
|
||||||
|
|
||||||
def get_translator(self, locale, domain):
|
def get_translator(self, locale: Optional[str], domain):
|
||||||
|
locale = locale or SOURCE_LOCALE
|
||||||
locale = locale.replace('-', '_') if locale else None
|
locale = locale.replace('-', '_') if locale else None
|
||||||
if locale == SOURCE_LOCALE:
|
if locale == SOURCE_LOCALE:
|
||||||
translator = null
|
translator = null
|
||||||
|
|||||||
@@ -780,7 +780,7 @@ class Timer:
|
|||||||
logger.info(f"Timer {self!r} has stopped. Auto restart is {'on' if auto_restart else 'off'}")
|
logger.info(f"Timer {self!r} has stopped. Auto restart is {'on' if auto_restart else 'off'}")
|
||||||
|
|
||||||
@log_wrap(action="Destroy Timer")
|
@log_wrap(action="Destroy Timer")
|
||||||
async def destroy(self, reason: str = None):
|
async def destroy(self, reason: Optional[str] = None):
|
||||||
"""
|
"""
|
||||||
Deconstructs the timer, stopping all tasks.
|
Deconstructs the timer, stopping all tasks.
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user