Listed 33 items in current directory
Read requirements.txt
L1-68
bash
Apply to log_config.i...
Run
pip install Flask-Babel
Read main.py
L1-50
bash
Apply to log_config.i...
Run
pip install fastapi-i18n
shellscript
Apply to log_config.i...
pip install fastapi-i18n
i18n.py(new)+34-1
from fastapi_i18n import I18nMiddleware, I18nConfig
from fastapi_i18n.lazy import lazy_gettext as _
from fastapi import Request
from typing import Optional
# 번역 파일 경로 설정
i18n_config = I18nConfig(
translations_path="translations",
default_locale="ko",
supported_locales=["ko", "en"]
)
def get_locale(request: Request) -> Optional[str]:
"""요청에서 언어 설정을 추출하는 함수"""
main.py+6-1
from core.database import DBConnect
from core.exception import AlertException, regist_core_exception_handler, template_response
from core.middleware import regist_core_middleware, should_run_middleware
from core.plugin import (
cache_plugin_menu, cache_plugin_state, get_plugin_state_change_time,
import_plugin_by_states, read_plugin_state, register_plugin,
debug=settings.APP_IS_DEBUG, # 디버그 모드가 활성화 설정
lifespan=lifespan,
title="그누보드6",
description=""
description=""
from core.database import DBConnect
from core.exception import AlertException, regist_core_exception_handler, template_response
from core.middleware import regist_core_middleware, should_run_middleware
from core.i18n import i18n_middleware
from core.plugin import (
cache_plugin_menu, cache_plugin_state, get_plugin_state_change_time,
import_plugin_by_states, read_plugin_state, register_plugin,
debug=settings.APP_IS_DEBUG, # 디버그 모드가 활성화 설정
lifespan=lifespan,
title="그누보드6",
description="G6 API",
version="1.0.0"
38 hidden lines
generate_translations.py(new)+39-1
import os
from pathlib import Path
from babel.messages import frontend as babel
def generate_translations():
"""번역 파일을 생성하고 관리하는 스크립트"""
# 번역 디렉토리 생성
translations_dir = Path("translations")
translations_dir.mkdir(exist_ok=True)
# 템플릿 디렉토리에서 번역 텍스트 추출
extract_cmd = babel.extract_messages()
extract_cmd.initialize_options()
extract_cmd.output_file = "messages.pot"
main.py+22-1
from core.database import DBConnect
from core.exception import AlertException, regist_core_exception_handler, template_response
from core.middleware import regist_core_middleware, should_run_middleware
from core.i18n import i18n_middleware
from core.plugin import (
cache_plugin_menu, cache_plugin_state, get_plugin_state_change_time,
import_plugin_by_states, read_plugin_state, register_plugin,
referer = request.headers.get("Referer", "/")
return RedirectResponse(referer, status_code=303)
from core.i18n import i18n_middleware
from core.database import DBConnect
from core.exception import AlertException, regist_core_exception_handler, template_response
from core.middleware import regist_core_middleware, should_run_middleware
from core.i18n import i18n_middleware, i18n_config
from core.plugin import (
cache_plugin_menu, cache_plugin_state, get_plugin_state_change_time,
import_plugin_by_states, read_plugin_state, register_plugin,
referer = request.headers.get("Referer", "/")
return RedirectResponse(referer, status_code=303)
@app.get("/language/{lang}")
bash
Apply to log_config.i...
Run
python scripts/generate_translations.py
html
Apply to log_config.i...
<!-- templates/example.html -->
<h1>{{ _("Welcome") }}</h1>
<p>{{ _("Hello, %(name)s", name=user.name) }}</p>
python
Apply to log_config.i...
from core.i18n import _
message = _("Welcome to our site")
html
Apply to log_config.i...
python scripts/generate_translations.py
댓글목록
등록된 댓글이 없습니다.