mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-22 16:51:59 +00:00
Fix autocomplete translations calling unnecessary locales
This commit is contained in:
parent
32c5a0cec1
commit
49e6fe9a0c
@ -484,6 +484,16 @@ class Choice(Generic[ChoiceT]):
|
||||
|
||||
return base
|
||||
|
||||
async def get_translated_payload_for_locale(self, translator: Translator, locale: Locale) -> Dict[str, Any]:
|
||||
base = self.to_dict()
|
||||
if self._locale_name:
|
||||
context = TranslationContext(location=TranslationContextLocation.choice_name, data=self)
|
||||
translation = await translator._checked_translate(self._locale_name, locale, context)
|
||||
if translation is not None:
|
||||
base['name'] = translation
|
||||
|
||||
return base
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
base = {
|
||||
'name': self.name,
|
||||
|
@ -880,8 +880,9 @@ class InteractionResponse:
|
||||
|
||||
translator = self._parent._state._translator
|
||||
if translator is not None:
|
||||
user_locale = self._parent.locale
|
||||
payload: Dict[str, Any] = {
|
||||
'choices': [await option.get_translated_payload(translator) for option in choices],
|
||||
'choices': [await option.get_translated_payload_for_locale(translator, user_locale) for option in choices],
|
||||
}
|
||||
else:
|
||||
payload: Dict[str, Any] = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user