mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-05 01:16:21 +00:00
Refactor TranslationContext to be more useful
The previous enum was good at accomplishing dynamic key generation for a few cases, but it fell short in others: 1. It could not discern group names and command names 2. It could not give you more contextual data such as the full object currently being translated. On top of that, the context being a required parameter for Translator.translate meant that it wouldn't be possible to re-use the translator for other use cases outside of the rigid ones defined in the library. To alleviate these concerns, new enum attributes were added along with a richer type for obtaining even more context.
This commit is contained in:
@ -626,10 +626,18 @@ locale_str
|
||||
TranslationContext
|
||||
+++++++++++++++++++
|
||||
|
||||
.. class:: TranslationContext
|
||||
.. attributetable:: discord.app_commands.TranslationContext
|
||||
|
||||
.. autoclass:: discord.app_commands.TranslationContext
|
||||
:members:
|
||||
|
||||
TranslationContextLocation
|
||||
+++++++++++++++++++++++++++
|
||||
|
||||
.. class:: TranslationContextLocation
|
||||
:module: discord.app_commands
|
||||
|
||||
An enum representing the context that the translation occurs in when requested for translation.
|
||||
An enum representing the location context that the translation occurs in when requested for translation.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
@ -639,6 +647,13 @@ TranslationContext
|
||||
.. attribute:: command_description
|
||||
|
||||
The translation involved a command description.
|
||||
|
||||
.. attribute:: group_name
|
||||
|
||||
The translation involved a group name.
|
||||
.. attribute:: group_description
|
||||
|
||||
The translation involved a group description.
|
||||
.. attribute:: parameter_name
|
||||
|
||||
The translation involved a parameter name.
|
||||
@ -648,7 +663,10 @@ TranslationContext
|
||||
.. attribute:: choice_name
|
||||
|
||||
The translation involved a choice name.
|
||||
.. attribute:: other
|
||||
|
||||
The translation involved something else entirely. This is useful for running
|
||||
:meth:`Translator.translate` for custom usage.
|
||||
|
||||
Exceptions
|
||||
~~~~~~~~~~~
|
||||
|
Reference in New Issue
Block a user