![]() ![]() Support’s self-hosting from our Github Repo.Automatically translate any & all flag reactions to a message.Translate custom messages with !tr this to :.Instead of just sending translations to channels you can have them sent to peoples’ DM’s.Translate channels automatically using the !tr channel command. #DISCORD TRANSLATE BOT FREE#Totally free Discord Translation, no limits of any kind.Rita is an open-source free Discord Translator built using discord.js & google-translate-api Features negotiate (, supported_locales, sep = "-" )) except ( ValueError, TypeError, babel. UnknownLocaleError ): # ValueError is Raised by `parse_locale` when an invalid Locale is given to it # Lets handle it silently and default to "en_US" try : # Try to find a babel locale that's close to the one used by red babel_locale = Locale ( Locale. parse_locale ( red_locale, sep = "-" )) except ( ValueError, babel. UnknownLocaleError ): try : babel_locale = Locale ( * babel. parse_locale ( red_locale )) except ( ValueError, babel. locale_identifiers () try : # Handles cases where red_locale is already Babel supported babel_locale = Locale ( * babel. lru_cache () def _get_babel_locale ( red_locale : str ) -> babel. #DISCORD TRANSLATE BOT UPDATE#update ( _parse ( translation_file )) def _add_translation ( self, untranslated, translated ): untranslated = _unescape ( untranslated ) translated = _unescape ( translated ) if translated : self. _parse ( file ) def _parse ( self, translation_file ): self. open ( encoding = "utf-8" ) as file : self. suppress ( IOError, FileNotFoundError ): with locale_path. translations : # Locales cannot be loaded twice as they have an entry in # anslations return locale_path = get_locale_path ( self. lower () = "en-us" : # Red is written in en-US, no point in loading it return if locale in self. def load_translations ( self ): """ Loads the current translations. """ step = None untranslated = "" translated = "" translations = ". Returns - Dict A dict mapping the original strings to their translations. Parameters - translation_file : io.TextIOWrapper An open text file containing translations. TextIOWrapper ) -> Dict : """ Custom gettext parsing of translation files. """ locale = await get_locale_from_guild ( bot, guild ) regional_format = await get_regional_format_from_guild ( bot, guild ) set_contextual_locale ( locale ) set_contextual_regional_format ( regional_format ) def _parse ( translation_file : io. Use `None` if the context doesn't involve guild. guild: Optional The guild contextual locale is set for. Parameters - bot: Red The bot's instance. async def set_contextual_locales_from_guild ( bot : Red, guild : Optional ) -> None : """ Set contextual locales (locale and regional format) for given guild context. ![]() set ( regional_format ) def reload_locales () -> None : for translator in _translators : translator. get ()) def set_regional_format ( regional_format : Optional ) -> None : global _current_regional_format _current_regional_format = ContextVar ( "_current_regional_format", default = regional_format ) def set_contextual_regional_format ( regional_format : Optional ) -> None : _current_regional_format. get ()) return str ( _current_regional_format. get () is None : return str ( _current_locale. set ( locale ) reload_locales () def get_regional_format () -> str : if _current_regional_format. get ()) def set_locale ( locale : str ) -> None : global _current_locale _current_locale = ContextVar ( "_current_locale", default = locale ) reload_locales () def set_contextual_locale ( locale : str ) -> None : _current_locale. getLogger ( "red.i18n" ) _current_locale = ContextVar ( "_current_locale", default = "en-US" ) _current_regional_format = ContextVar ( "_current_regional_format", default = None ) WAITING_FOR_MSGID = 1 IN_MSGID = 2 WAITING_FOR_MSGSTR = 3 IN_MSGSTR = 4 MSGID = 'msgid "' MSGSTR = 'msgstr "' _translators = def get_locale () -> str : return str ( _current_locale.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |