mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
96 lines
3 KiB
Text
96 lines
3 KiB
Text
# SOME DESCRIPTIVE TITLE.
|
|
# Copyright (C) 2023, aiogram Team
|
|
# This file is distributed under the same license as the aiogram package.
|
|
# FIRST AUTHOR <EMAIL@ADDRESS>, 2023.
|
|
#
|
|
#, fuzzy
|
|
msgid ""
|
|
msgstr ""
|
|
"Project-Id-Version: aiogram \n"
|
|
"Report-Msgid-Bugs-To: \n"
|
|
"POT-Creation-Date: 2023-08-26 23:17+0300\n"
|
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
|
"MIME-Version: 1.0\n"
|
|
"Content-Type: text/plain; charset=utf-8\n"
|
|
"Content-Transfer-Encoding: 8bit\n"
|
|
"Generated-By: Babel 2.12.1\n"
|
|
|
|
#: ../../dispatcher/dependency_injection.rst:3
|
|
msgid "Dependency injection"
|
|
msgstr ""
|
|
|
|
#: ../../dispatcher/dependency_injection.rst:5
|
|
msgid ""
|
|
"Dependency injection is a programming technique that makes a class "
|
|
"independent of its dependencies. It achieves that by decoupling the usage"
|
|
" of an object from its creation. This helps you to follow `SOLID's "
|
|
"<https://en.wikipedia.org/wiki/SOLID>`_ dependency inversion and single "
|
|
"responsibility principles."
|
|
msgstr ""
|
|
|
|
#: ../../dispatcher/dependency_injection.rst:12
|
|
msgid "How it works in aiogram"
|
|
msgstr ""
|
|
|
|
#: ../../dispatcher/dependency_injection.rst:14
|
|
msgid ""
|
|
"For each update :class:`aiogram.dispatcher.dispatcher.Dispatcher` passes "
|
|
"handling context data. Filters and middleware can also make changes to "
|
|
"the context."
|
|
msgstr ""
|
|
|
|
#: ../../dispatcher/dependency_injection.rst:17
|
|
msgid ""
|
|
"To access contextual data you should specify corresponding keyword "
|
|
"parameter in handler or filter. For example, to get "
|
|
":class:`aiogram.fsm.context.FSMContext` we do it like that:"
|
|
msgstr ""
|
|
|
|
#: ../../dispatcher/dependency_injection.rst:30
|
|
msgid "Injecting own dependencies"
|
|
msgstr ""
|
|
|
|
#: ../../dispatcher/dependency_injection.rst:32
|
|
msgid "Aiogram provides several ways to complement / modify contextual data."
|
|
msgstr ""
|
|
|
|
#: ../../dispatcher/dependency_injection.rst:34
|
|
msgid ""
|
|
"The first and easiest way is to simply specify the named arguments in "
|
|
":class:`aiogram.dispatcher.dispatcher.Dispatcher` initialization, polling"
|
|
" start methods or "
|
|
":class:`aiogram.webhook.aiohttp_server.SimpleRequestHandler` "
|
|
"initialization if you use webhooks."
|
|
msgstr ""
|
|
|
|
#: ../../dispatcher/dependency_injection.rst:46
|
|
msgid "Analogy for webhook:"
|
|
msgstr ""
|
|
|
|
#: ../../dispatcher/dependency_injection.rst:55
|
|
msgid ""
|
|
":class:`aiogram.dispatcher.dispatcher.Dispatcher`'s workflow data also "
|
|
"can be supplemented by setting values as in a dictionary:"
|
|
msgstr ""
|
|
|
|
#: ../../dispatcher/dependency_injection.rst:63
|
|
msgid ""
|
|
"The middlewares updates the context quite often. You can read more about "
|
|
"them on this page:"
|
|
msgstr ""
|
|
|
|
#: ../../dispatcher/dependency_injection.rst:66
|
|
msgid ":ref:`Middlewares <middlewares>`"
|
|
msgstr ""
|
|
|
|
#: ../../dispatcher/dependency_injection.rst:68
|
|
msgid "The last way is to return a dictionary from the filter:"
|
|
msgstr ""
|
|
|
|
#: ../../dispatcher/dependency_injection.rst:72
|
|
msgid ""
|
|
"...or using :ref:`MagicFilter <magic-filters>` with :code:`.as_(...)` "
|
|
"method."
|
|
msgstr ""
|