Skip to content

Commit

Permalink
[ConversationGames] add language to inter
Browse files Browse the repository at this point in the history
  • Loading branch information
japandotorg committed Oct 12, 2023
1 parent 424c83c commit 4a477b7
Showing 1 changed file with 38 additions and 27 deletions.
65 changes: 38 additions & 27 deletions conversationgames/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,47 @@
from redbot.core.bot import Red


select_options = {
"en": {
"label": "English",
"description": "Get English translation of this question.",
},
"bn": {
"label": "Bengali",
"description": "Get Bengali translation of this question.",
},
"de": {
"label": "German",
"description": "Get German translation of this question.",
},
"es": {
"label": "Spanish",
"description": "Get Spanish translation of this question.",
},
"fr": {
"label": "French",
"description": "Get French translation of this question.",
},
"hi": {
"label": "Hindi",
"description": "Get Hindi translation of this question.",
},
"tl": {
"label": "Filipino",
"description": "Get French translation of this question.",
},
}


class BaseLanguageOptions:
def __init__(self) -> None:
self._options: List[discord.SelectOption] = [
discord.SelectOption(
label="English", description="Get English translation of this question."
),
discord.SelectOption(
label="Bengali",
description="Get Bengali translation of this question.",
value="bn",
),
discord.SelectOption(
label="German", description="Get German translation of this question.", value="de"
),
discord.SelectOption(
label="Spanish",
description="Get Spanish translation of this question.",
value="es",
),
discord.SelectOption(
label="French", description="Get French translation of this question.", value="fr"
),
discord.SelectOption(
label="Hindi", description="Get Hindi translation of this question.", value="hi"
),
discord.SelectOption(
label="Filipino",
description="Get Filipino translation of this question.",
value="tl",
),
value=key,
label=select_options[key]["label"],
description=select_options[key]["description"],
)
for key in select_options
]

def _get_options(self) -> List[discord.SelectOption]:
Expand Down Expand Up @@ -107,7 +118,7 @@ async def _callback(self: Select, interaction: discord.Interaction[Red]) -> None
description=(
self.view._result["question"] # type: ignore
if self.values[0] == "English"
else f"({self.values[0].__str__()}) "
else f"({select_options[self.values[0]]['label']}) "
+ self.view._result["translations"][self.values[0]] # type: ignore
),
color=await self.view._ctx.embed_color(), # type: ignore
Expand Down

0 comments on commit 4a477b7

Please sign in to comment.