fix(notification): 独立展示区(standalone)的国外 RSS 标题在推送中不翻译#1162
Open
KatyaSilva wants to merge 1 commit into
Open
Conversation
启用 AI 翻译且独立展示区(standalone)包含 RSS 源时,国外 RSS 标题在 Webhook 推送中永远保持原文(如英文),未被翻译。 根因: - __main__ 的预翻译调用 translate_content() 未传入 standalone_data, 因此 standalone 的 rss_feeds 不会在上游被翻译; - 推送路径 dispatch_all() 内部以 skip_rss=True 调用 translate_content(), 而其中 standalone 的 rss_feeds 翻译被 `if not skip_rss:` 一并跳过。 - 两条路径都不翻译 standalone 的 rss_feeds,导致其标题恒为原文。 修复:standalone 的 rss_feeds 从不会在上游翻译,不应受 skip_rss 影响。 移除该处的 skip_rss 守卫,使其在推送时正常翻译。standalone 的热榜平台 标题原本就在此分支内翻译,本次仅补齐 rss_feeds,行为对齐。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
启用 AI 翻译(
ai_translation.enabled: true)、且独立展示区(display.standalone)包含 RSS 源(rss_feeds)时,这些国外 RSS 的标题在 Webhook 推送中始终保持原文(例如英文),不会被翻译成目标语言。(同一配置下,
RSS 订阅区域的标题能正常翻译,仅独立展示区的 RSS 源不翻译。)复现
config.yaml:推送到飞书/钉钉等:国内热榜(standalone 平台)正常,但 standalone 的国外 RSS 标题仍是英文。
根因
trendradar/notification/dispatcher.py的translate_content()中,独立展示区 RSS 源的翻译被if not skip_rss:守卫:而:
__main__.py的预翻译调用translate_content(...)未传入standalone_data,所以 standalone 的rss_feeds不会在上游被翻译;dispatch_all()内部以skip_rss=True调用translate_content()(本意是避免rss_items/rss_new_items被重复翻译),却把 standalone 的rss_feeds也一并跳过。结果:standalone 的
rss_feeds在两条路径下都不会被翻译,标题恒为原文。修复
standalone 的
rss_feeds与rss_items是两套独立数据,前者从不会在上游被翻译,因此不应受skip_rss影响。移除该处的skip_rss守卫即可(同分支内 standalone 的热榜平台标题本就在此翻译,本次仅补齐rss_feeds,行为对齐)。改动仅一处,已加注释说明原因。
备注
HTML 报告中的独立展示区标题同样未翻译(
__main__.py预翻译未传standalone_data),不确定是否为有意设计,故本 PR 未改动该路径,仅修复推送翻译。如需要也可一并处理。