翻訳言語定義を YAML に移行しロード処理を実装
- 言語マッピングを src-python/models/translation/languages/languages.yml として追加 - translation_languages.py を全面リファクタ:YAML から読み込み、構造検証、スレッドロック、キャッシュ対応を導入 - config.py に loadTranslationLanguages のインポート/フォールバックを追加し、Config 初期化時に言語定義を読み込むよう変更 - PyYAML を requirements.txt / requirements_cuda.txt に追記 - PyInstaller spec (backend.spec / backend_cuda.spec) に言語ファイル配布先を追加 - translation_ollama.py の loadPromptConfig 呼び出しを修正(ファイル名を明示)
This commit is contained in:
@@ -16,9 +16,11 @@ except Exception: # pragma: no cover - optional runtime
|
||||
device_manager = None # type: ignore
|
||||
|
||||
try:
|
||||
from models.translation.translation_languages import translation_lang
|
||||
from models.translation.translation_languages import translation_lang, loadTranslationLanguages
|
||||
except Exception: # pragma: no cover - optional runtime
|
||||
translation_lang = {} # type: ignore
|
||||
def loadTranslationLanguages(path: str, force: bool = False) -> Dict[str, Any]:
|
||||
return {}
|
||||
|
||||
try:
|
||||
from models.translation.translation_utils import ctranslate2_weights
|
||||
@@ -1227,6 +1229,7 @@ class Config:
|
||||
# these external mappings may be empty dicts if the optional modules failed to import
|
||||
self._SELECTABLE_CTRANSLATE2_WEIGHT_TYPE_LIST = getattr(ctranslate2_weights, 'keys', lambda: [])()
|
||||
self._SELECTABLE_WHISPER_WEIGHT_TYPE_LIST = getattr(whisper_models, 'keys', lambda: [])()
|
||||
translation_lang = loadTranslationLanguages(self.PATH_LOCAL)
|
||||
self._SELECTABLE_TRANSLATION_ENGINE_LIST = getattr(translation_lang, 'keys', lambda: [])()
|
||||
try:
|
||||
# transcription_lang is nested dict; attempt to extract keys defensively
|
||||
|
||||
Reference in New Issue
Block a user