Единая интернационализация сервера без доменов
This commit is contained in:
parent
f0d5481dfe
commit
ec054bbaad
29 changed files with 1313 additions and 1412 deletions
|
|
@ -1,14 +1,14 @@
|
|||
from typing import Dict, Any
|
||||
from fastapi import APIRouter, Body, HTTPException, Depends
|
||||
from services.ip_service import IPService
|
||||
from utils.i18n import get_translations, _
|
||||
from utils.i18n import get_translations
|
||||
from babel.support import Translations
|
||||
|
||||
router = APIRouter()
|
||||
ip_service = IPService()
|
||||
|
||||
@router.post("/check_ip")
|
||||
async def check_ip_config(data: Dict[str, Any] = Body(...), translations: Translations = Depends(get_translations("api_v1"))):
|
||||
async def check_ip_config(data: Dict[str, Any] = Body(...), translations: Translations = Depends(get_translations())):
|
||||
"""Проверяет доступность IP-адреса перед его применением.
|
||||
|
||||
Выполняет ARP-сканирование для проверки, занят ли указанный IP-адрес,
|
||||
|
|
@ -28,7 +28,7 @@ async def check_ip_config(data: Dict[str, Any] = Body(...), translations: Transl
|
|||
HTTPException: Если произошла внутренняя ошибка (status_code=500).
|
||||
"""
|
||||
try:
|
||||
result = await ip_service.check_ip_config(data)
|
||||
result = await ip_service.check_ip_config(data, translations)
|
||||
return result
|
||||
except Exception as e:
|
||||
raise HTTPException(
|
||||
|
|
@ -37,7 +37,7 @@ async def check_ip_config(data: Dict[str, Any] = Body(...), translations: Transl
|
|||
)
|
||||
|
||||
@router.post("/apply_ip")
|
||||
async def apply_ip_config(data: Dict[str, Any] = Body(...), translations: Translations = Depends(get_translations("api_v1"))):
|
||||
async def apply_ip_config(data: Dict[str, Any] = Body(...), translations: Translations = Depends(get_translations())):
|
||||
"""Применяет проверенные IP-настройки к указанному сетевому профилю.
|
||||
|
||||
Обновляет настройки соединения через NetworkManager, отключает и
|
||||
|
|
@ -58,7 +58,7 @@ async def apply_ip_config(data: Dict[str, Any] = Body(...), translations: Transl
|
|||
произошла внутренняя ошибка (status_code=500).
|
||||
"""
|
||||
try:
|
||||
await ip_service.apply_ip_config(data)
|
||||
await ip_service.apply_ip_config(data, translations)
|
||||
return {
|
||||
"success": True,
|
||||
"message": translations.gettext("Настройки сетевого профиля для {connection_id} применены").format(
|
||||
|
|
@ -74,7 +74,7 @@ async def apply_ip_config(data: Dict[str, Any] = Body(...), translations: Transl
|
|||
)
|
||||
|
||||
@router.post("/save_ip")
|
||||
async def save_ip_config(data: Dict[str, Any] = Body(...), translations: Translations = Depends(get_translations("api_v1"))):
|
||||
async def save_ip_config(data: Dict[str, Any] = Body(...), translations: Translations = Depends(get_translations())):
|
||||
"""Применяет проверенные IP-настройки для отката сетевого профиля.
|
||||
|
||||
Используется для сохранения и отката настроек сетевого профиля к предыдущему
|
||||
|
|
@ -95,7 +95,7 @@ async def save_ip_config(data: Dict[str, Any] = Body(...), translations: Transla
|
|||
произошла внутренняя ошибка (status_code=500).
|
||||
"""
|
||||
try:
|
||||
await ip_service.apply_ip_config(data)
|
||||
await ip_service.apply_ip_config(data, translations)
|
||||
return {
|
||||
"success": True,
|
||||
"message": translations.gettext("Настройки сетевого профиля для {connection_id} применены").format(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue