New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🌐 Add Persian translation for docs/fa/docs/advanced/sub-applications.md
#9692
Changes from 5 commits
ce4ea70
6226e54
14550db
f3062d3
ebd5eb5
402960b
b7572cc
22bcb14
cad7ac6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# زیر برنامه ها - نصب | ||
|
||
اگر نیاز دارید که دو برنامه مستقل FastAPI، با OpenAPI مستقل و رابطهای کاربری اسناد خود داشته باشید، میتوانید یک برنامه | ||
اصلی داشته باشید و یک (یا چند) زیر برنامه را "mount" (سوار) کنید. | ||
|
||
## نصب کردن یک برنامه **FastAPI** | ||
|
||
"Mounting" به معنای افزودن یک برنامه کاملاً مستقل در یک مسیر خاص است، که پس از آن به مدیریت همه چیز در آن مسیر، با | ||
عملیات مسیر اعلام شده در آن زیر برنامه، رسیدگی می کند. | ||
|
||
### برنامه سطح بالا | ||
|
||
ابتدا برنامه اصلی سطح بالا، **FastAPI** و عملیات مسیر آن را ایجاد کنید: | ||
|
||
```Python hl_lines="3 6-8" | ||
{!../../../ docs_src / sub_applications / tutorial001.py!} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. {!../../../docs_src/sub_applications/tutorial001.py!} |
||
``` | ||
|
||
### زیر برنامه | ||
|
||
سپس، زیر برنامه خود و عملیات مسیر آن را ایجاد کنید. | ||
|
||
این زیر برنامه فقط یکی دیگر از برنامه های استاندارد FastAPI است، اما این برنامه ای است که "mount" می شود: | ||
|
||
```Python hl_lines="11 14-16" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. {!../../../docs_src/sub_applications/tutorial001.py!} |
||
{!../../../ docs_src / sub_applications / tutorial001.py!} | ||
``` | ||
|
||
### نصب زیر برنامه | ||
|
||
در برنامه سطح بالا `app` نصب میکند زیر برنامه `subapi` در این نمونه `/subapi` در مسیر قرار میگیرد و میشود: | ||
|
||
```Python hl_lines="11 19" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. {!../../../docs_src/sub_applications/tutorial001.py!} |
||
{!../../../ docs_src / sub_applications / tutorial001.py!} | ||
``` | ||
|
||
### اسناد API خودکار را بررسی کنید | ||
|
||
حالا ‘uvicorn’ را برای برنامه اصلی اجرا کنید، برای مثال اگر فایل شما`main.py` هست: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. برنامه را با استفاده از uvicorn اجرا کنید، اگر فایل شما main.py نام دارد، دستور زیر را وارد کنید همچنین تو ترجمه ای که انجام دادی یک space برای main.py جا افتاده 😃 |
||
<div class="termy"> | ||
|
||
```console | ||
$ uvicorn main:app --reload | ||
|
||
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) | ||
``` | ||
|
||
</div> | ||
|
||
و باز کنید مستندات را در | ||
آدرس <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. صفحه مستندات را در آدرس http://127.0.0.1:8000/docs باز کنید. |
||
اسناد API خودکار برنامه اصلی را مشاهده خواهید کرد که فقط شامل عملیات مسیر خود می شود: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. خب الان مشاهده میکنید که اسناد API خودکار برنامه اصلی فقط شامل path operations خود میباشد این ترجمه و ترجمه بالا باید تو دو خط جدا باشند |
||
|
||
<img src="/img/tutorial/sub-applications/image01.png"> | ||
|
||
و سپس اسناد زیر برنامه را در آدرس <a href="http://127.0.0.1:8000/subapi/docs" class="external-link" target="_blank">http://127.0.0.1:8000/subapi/docs</a>. باز کنید. | ||
|
||
اسناد API خودکار برای زیر برنامه را خواهید دید، که فقط شامل عملیات مسیر خود می شود، همه در زیر مسیر `/subapi` قرار دارند: | ||
|
||
<img src="/img/tutorial/sub-applications/image02.png"> | ||
|
||
اگر سعی کنید با هر یک از این دو رابط کاربری تعامل داشته باشید، آنها به درستی کار می کنند، زیرا مرورگر می تواند با هر یک از برنامه ها یا زیر برنامه های خاص صحبت کند. | ||
|
||
### جرئیات فنی : `root_path` | ||
|
||
هنگامی که یک زیر برنامه را همانطور که در بالا توضیح داده شد نصب می کنید,FastAPI با استفاده از مکانیزمی از مشخصات ASGI به نام `root_path` ارتباط مسیر mount را برای زیر برنامه انجام می دهد. | ||
|
||
به این ترتیب، زیر برنامه می داند که از آن پیشوند مسیر برای رابط کاربری اسناد (docs UI) استفاده کند. | ||
|
||
و زیر برنامه ها نیز می تواند زیر برنامه های نصب شده خود را داشته باشد و همه چیز به درستی کار کند، زیرا FastAPI تمام این مسیرهای `root_path` را به طور خودکار مدیریت می کند. | ||
|
||
در بخش [پشت پراکسی](./behind-a-proxy.md){.internal-link target=_blank}. درباره `root_path` و نحوه استفاده درست از آن بیشتر خواهید آموخت. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
به نظرم تو ترجمه مطالب تکنیکال نباید تمام کلمات به فارسی ترجمه بشن چون معنی, خوانایی و درک جمله رو پایین میارن, برای مثال تو این قسمت استفاده از path operations به جای "عملیات مسیر" هم معنی بهتری داره و هم خواناتر هستش یا اینکه استفاده کلمه sub-application بهتر از کلمه "زیر برنامه" هستش, برای عنوان هم فکر میکنم اینجا کلمه اتصال بهتر از نصب باشه
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the suggestion, but there’s a limit that you need to draw the line.
For example you are right that “path operations” should not be translated, but we can translate sub-application as we already have a good translation for application.