mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-06 18:11: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
|
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]:
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
base = {
|
base = {
|
||||||
'name': self.name,
|
'name': self.name,
|
||||||
|
@ -880,8 +880,9 @@ class InteractionResponse:
|
|||||||
|
|
||||||
translator = self._parent._state._translator
|
translator = self._parent._state._translator
|
||||||
if translator is not None:
|
if translator is not None:
|
||||||
|
user_locale = self._parent.locale
|
||||||
payload: Dict[str, Any] = {
|
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:
|
else:
|
||||||
payload: Dict[str, Any] = {
|
payload: Dict[str, Any] = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user