Skip to content

Conversation

@alv2017
Copy link
Contributor

@alv2017 alv2017 commented Feb 23, 2025

No description provided.

@github-actions github-actions bot added the lang-all Translations label Feb 23, 2025
@alv2017 alv2017 changed the title Russian translation added: docs/ru/docs/tutorial/middleware.md Add Russian translation for docs/ru/docs/tutorial/middleware.md Feb 23, 2025
@github-actions
Copy link
Contributor

@alv2017 alv2017 marked this pull request as ready for review February 23, 2025 01:02
@svlandeg svlandeg changed the title Add Russian translation for docs/ru/docs/tutorial/middleware.md 🌐 Add Russian translation for docs/ru/docs/tutorial/middleware.md Feb 24, 2025
@svlandeg svlandeg added lang-ru Russian translations awaiting-review labels Feb 24, 2025
@github-actions
Copy link
Contributor

@alv2017
Copy link
Contributor Author

alv2017 commented Feb 24, 2025

@Rishat-F, @Yarous, @Xewus, @Stepakinoyan, @gitgernit

сделайте review пожалуйста 😊

@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

@alv2017 alv2017 requested review from Rishat-F and Yarous February 25, 2025 10:28
@github-actions
Copy link
Contributor

@alv2017 alv2017 requested a review from Rishat-F February 25, 2025 12:10
@alv2017
Copy link
Contributor Author

alv2017 commented Feb 25, 2025

@Rishat-F : последние поправки удобно просмотреть здесь: bb4077a

@alv2017 alv2017 requested a review from Rishat-F February 25, 2025 15:28
@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor


Вы можете добавить промежуточный слой (middleware) в **FastAPI** приложения.

"Middleware" это функция, которая выполняется с каждым запросом до его обработки *функцией эндпоинта*.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не знаю, как лучше, но в оригинале используется "path operation", да и в других местах доки это называют операцией пути

Copy link
Contributor Author

@alv2017 alv2017 Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yarous: имхо, функция эндпоинта понятнее и используется чаще. Но можно и обсудить. 😊

"Middleware" это функция, которая выполняется с каждым запросом до его обработки функцией эндпоинта.

"Middleware" это функция, которая выполняется с каждым запросом до его обработки операцией пути.

"эндпоинт at fastapi.tiangolo.com"

Copy link
Contributor

@Rishat-F Rishat-F Feb 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я согласен с @Yarous.
@alv2017, ведь в переводе "Большие приложения, в которых много файлов", ты все "path operation" перевела либо как "операция пути", либо как "эндпоинт".
А "функция операции пути" или "функция эндпоинта" - это уже "operation path function".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

я исхожу из контекста, в данном контексте нужно переводить operation как функцию (тут проблем нет), а
path как эндпоинт (это некорректно с точки зрения русского языка)

вообще-то, если дословно, то "path operation" = "функция пути"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исходя из предыдущих переводов я думал так:
"path operation" = "операция пути" или "эндпоинт"
"path operation function" = "функция операции пути" или "функция эндпоинта"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rishat-F

endpoint -> url
pass operations -> набор функций/операций, обслуживающих запросы на определенный url
pass operation -> "операция пути" ~ "операция эндпоинта" ~ "функция эндпоинта"
path operation decorator: @app.get("/")
path operation function: async def root()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alv2017 , разве мы не можем просто следующим образом переводить:

  • если в оригинале написано "path operation", то переводим "операция пути"
  • если в оригинале написано "path operation function", то переводим "функция операции пути"

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rishat-F

  1. можем, но это не всегда работает.
  2. операция пути не( самый )удачный термин, и в обычной жизни не используется
  3. и хочется объяснить более доступно, но не всегда получается 😊

Copy link
Contributor

@Rishat-F Rishat-F Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alv2017 , но ведь мы можем пока придерживаться такой (пусть и не самой удачной) терминологии, просто чтобы везде было однообразно.
И потом если кому-то в голову придет более удачный термин, то тогда массово разом везде поправить.
И если везде будут одинаковые неудачные термины, то массово поправить будет легче, чем если они будут везде по-разному прописаны.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rishat-F, мы такой стратегии и придерживаемся, разве нет? 😄

@alv2017
Copy link
Contributor Author

alv2017 commented Feb 26, 2025

экспериментальная middleware 😄

from fastapi import FastAPI, Request

app = FastAPI()


@app.get("/")
def hello():
    return {"message": "Hello from GET"}


@app.post("/")
def hello():
    return {"message": "Hello from POST"}


@app.middleware("http")
async def add_demo_middleware(request: Request, call_next):
    if request.scope["method"] == "GET":
        request.scope["method"] = "POST"
    elif request.scope["method"] == "POST":
        request.scope["method"] = "GET"

    response = await call_next(request)
    response.headers["X-Method"] = f"Request method: {request.method}"
    return response


if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="localhost", port=8080, lifespan="on")

@github-actions
Copy link
Contributor

@alv2017
Copy link
Contributor Author

alv2017 commented Feb 27, 2025

@Yarous, @Rishat-F: добавила поправки и уточнила перевод 😇

@alv2017 alv2017 requested review from Rishat-F and Yarous February 27, 2025 09:14
@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

@alv2017
Copy link
Contributor Author

alv2017 commented Feb 28, 2025

@Yarous, уже всё поправили, ждём тебя 😄

Copy link
Contributor

@Yarous Yarous left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хорошая работа 👍

@github-actions
Copy link
Contributor

@alejsdev alejsdev merged commit bb98f7d into fastapi:master Feb 28, 2025
52 checks passed
@alejsdev
Copy link
Member

Great, thank you for your contribution! @alv2017 🚀
And thanks for your reviews @Rishat-F @Yarous

@Rishat-F
Copy link
Contributor

@alv2017 , молодчина! Отличная работа!

@alv2017
Copy link
Contributor Author

alv2017 commented Feb 28, 2025

@Rishat-F, народное творчество! 😄

@alv2017 alv2017 deleted the translate-ru-tutorial-middleware branch March 6, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved-2 lang-all Translations lang-ru Russian translations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants