fix(report): keep the English edition when one phrase was untranslated
The English personal report was discarded whenever a Chinese fragment survived the trailing glossary. English sections now render the English fields that were already calculated. Co-Authored-By: Grok (agent loop) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Grok (agent loop)
Cursor
parent
9812f31737
commit
ba1ffeb35f
@@ -2070,14 +2070,43 @@ def _render_pl9_ai_density_raw_data_markdown_en(packet: dict) -> str:
|
||||
rows.append([name, item.get("sign"), item.get("degree_in_sign"), item.get("longitude")])
|
||||
lines.extend(["## Sahams", "", table(["Name", "Sign", "Degree in sign", "Longitude"], rows), ""])
|
||||
|
||||
english_report = _pl9_report_language(packet) == "en"
|
||||
strength_en_map: dict[str, str] = {}
|
||||
han_leaks = None
|
||||
if english_report:
|
||||
try:
|
||||
from yoga_engine import STRENGTH_EN as strength_en_map
|
||||
except ImportError:
|
||||
from scripts.yoga_engine import STRENGTH_EN as strength_en_map
|
||||
try:
|
||||
from pl9_reader_english import HAN as han_leaks
|
||||
except ImportError:
|
||||
from scripts.pl9_reader_english import HAN as han_leaks
|
||||
|
||||
def _english_plain(value: Any) -> str:
|
||||
text = str(value or "").strip()
|
||||
if not text or (han_leaks is not None and han_leaks.search(text)):
|
||||
return ""
|
||||
return text
|
||||
|
||||
yoga = dict_get(("advanced_systems", "yoga", "detected_yogas"), [])
|
||||
if isinstance(yoga, list):
|
||||
rows = []
|
||||
for item in yoga:
|
||||
if isinstance(item, dict):
|
||||
effects = [effect for effect in (clean_effect(e) for e in item.get("effects", [])) if effect]
|
||||
if english_report:
|
||||
effects_src = item.get("effects_en") if isinstance(item.get("effects_en"), list) else []
|
||||
effects = [text for text in (_english_plain(effect) for effect in effects_src) if text]
|
||||
combination = _english_plain(item.get("combination_en")) or "-"
|
||||
strength = _english_plain(item.get("strength_en"))
|
||||
if not strength:
|
||||
strength = _english_plain(strength_en_map.get(str(item.get("strength") or ""), ""))
|
||||
else:
|
||||
effects = [effect for effect in (clean_effect(e) for e in item.get("effects", [])) if effect]
|
||||
combination = item.get("combination")
|
||||
strength = item.get("strength")
|
||||
effects_text = "; ".join(effects) if effects else "-"
|
||||
rows.append([item.get("name"), item.get("category"), item.get("strength"), item.get("combination"), effects_text])
|
||||
rows.append([item.get("name"), item.get("category"), strength, combination, effects_text])
|
||||
lines.extend(["## Applicable Yogas", "", table(["Yoga", "Category", "Strength", "Combination", "Effects / notes"], rows), ""])
|
||||
|
||||
dosha = dict_get(("advanced_systems", "yogas_doshas"), {})
|
||||
@@ -2092,10 +2121,14 @@ def _render_pl9_ai_density_raw_data_markdown_en(packet: dict) -> str:
|
||||
for key in ["mangal_dosha", "kaal_sarp_dosha", "pitra_dosha", "sade_sati"]:
|
||||
item = dosha.get(key)
|
||||
if isinstance(item, dict):
|
||||
if english_report:
|
||||
summary = _english_plain(item.get("summary_en")) or "-"
|
||||
else:
|
||||
summary = item.get("summary") or item.get("phase") or item.get("type")
|
||||
rows.append([
|
||||
dosha_labels.get(key, key),
|
||||
item.get("present") or item.get("detected") or item.get("status"),
|
||||
item.get("summary") or item.get("phase") or item.get("type"),
|
||||
summary,
|
||||
])
|
||||
lines.extend(["## Dosha and Transit Summary", "", table(["Topic", "Detected / phase", "Summary"], rows), ""])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user