mirror of
https://github.com/ZhuLinsen/daily_stock_analysis
synced 2026-09-20 02:43:35 +08:00
* feat(i18n): add Korean to report language label maps Extend the report language layer with a third code `ko` so reports can render deterministic labels in Korean. Adds `ko` to the supported list, aliases (korean/kr/ko-kr), every translation map, the full report label set, sentiment bands, the config registry enum and `.env.example`. `zh`/`en` behavior is unchanged and unknown languages still fall back to the default. Prompt and Web surfaces follow in later changes. Refs #1614 * feat(i18n): emit Korean output directives in analysis prompts Make the analysis and market-review prompts produce Korean output when REPORT_LANGUAGE=ko. The decision agent now appends a Korean output-language directive (JSON keys and decision_type enum unchanged), and the market-review prompt reuses the English structural scaffolding while instructing the model to write the shell, headings and conclusion in Korean. Market-phase and context-pack prompt sections route ko to the English structural base. The market-review payload keeps the truthful language code via a dedicated output-language helper, leaving zh/en behavior unchanged. Refs #1614 * fix(i18n): localize phase and market-context guardrails for Korean Route Korean reports through the English structural scaffolding for market-phase and market-context prompt sections, and add Korean output, detection markers, negations and recap patterns to the phase-decision and daily-market-context guardrails so they operate on Korean model output. Confidence and operation labels now flow through the shared localize helpers. zh/en behavior is unchanged. Refs #1614 * feat(i18n): localize Korean fallback output across analysis pipeline Add Korean output to the deterministic strings emitted outside the LLM: per-stock and executor output-language directives, no-API-key / backend / parse error fallbacks, hold-watch advice and reasons, market-review titles and summaries, and history and notification report labels. Fund flow, trend and confidence values now flow through the shared localize helpers, and language-keyed advice tables no longer raise KeyError for a third language. Structural prompt sections route ko to the English scaffolding. zh/en output is unchanged. Refs #1614 * feat(web): add Korean report language rendering Extend the Web ReportLanguage type with ko and add Korean copy to the report detail surfaces: report text, sentiment labels, market-phase labels, analysis-context summary, market-review view, diagnostics and news source. Run-flow chrome that is keyed by UI language falls back to English for ko. The report-language selector is driven by the backend config schema, so Korean appears automatically. zh/en rendering is unchanged. Refs #1614 * docs(i18n): document Korean report language support Note that REPORT_LANGUAGE accepts ko in the bilingual guides and the analyze / market-review request-language parameters, and add a CHANGELOG entry for Korean report output. Refs #1614 * fix(i18n): canonicalize Korean values and accept ko in API schemas Add Korean aliases to the operation-advice, trend, confidence, chip and bias canonical maps so Korean model output (매수/매도/보유/관망 etc.) resolves to the correct decision_type and signal level instead of falling back to hold or a score-band signal. Accept ko in the analyze, market-review and decision-signal request schemas (and the static API spec) so the typed client and backend agree and per-request Korean analysis is not rejected with 422. Refs #1614
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Korean (ko) deterministic fallback coverage for the report-language sweep (#1614)."""
|
|
|
|
import unittest
|
|
|
|
from src.core.market_review import _get_market_review_text
|
|
from src.report_language import (
|
|
get_no_data_text,
|
|
get_placeholder_text,
|
|
get_unknown_text,
|
|
)
|
|
|
|
|
|
class KoreanFallbackTextTestCase(unittest.TestCase):
|
|
def test_placeholder_unknown_no_data_have_korean(self) -> None:
|
|
self.assertEqual(get_placeholder_text("ko"), "미정")
|
|
self.assertEqual(get_unknown_text("ko"), "알 수 없음")
|
|
self.assertEqual(get_no_data_text("ko"), "데이터 없음")
|
|
|
|
def test_market_review_titles_korean(self) -> None:
|
|
text = _get_market_review_text("ko")
|
|
self.assertEqual(text["push_title"], "🎯 시황 리뷰")
|
|
self.assertIn("시황 리뷰", text["root_title"])
|
|
self.assertIn("한국", text["kr_title"])
|
|
|
|
def test_market_review_titles_unchanged_for_en_zh(self) -> None:
|
|
self.assertEqual(_get_market_review_text("en")["push_title"], "🎯 Market Review")
|
|
self.assertEqual(_get_market_review_text("zh")["push_title"], "🎯 大盘复盘")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|