添加中文翻译功能,显示翻译后的描述
This commit is contained in:
parent
cbd1c0bfcf
commit
52aaa8545d
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* 格式化AI新闻简报 - 飞书友好版本
|
||||
* 格式化AI新闻简报 - 飞书友好版本(含中文翻译)
|
||||
* 生成易读、链接可点击的消息格式
|
||||
*/
|
||||
|
||||
@ -10,6 +10,50 @@ const path = require('path');
|
||||
|
||||
const DAILY_DIR = path.join(__dirname, '../../daily');
|
||||
|
||||
// 简单的翻译映射(常见术语)
|
||||
const termMap = {
|
||||
'web browser': '网页浏览器',
|
||||
'browser': '浏览器',
|
||||
'independent': '独立的',
|
||||
'framework': '框架',
|
||||
'methodology': '方法论',
|
||||
'agentic': '代理式',
|
||||
'adaptive': '自适应',
|
||||
'web scraping': '网页爬取',
|
||||
'framework': '框架',
|
||||
'high performance': '高性能',
|
||||
'vector graph': '向量图',
|
||||
'real time': '实时',
|
||||
'analytics': '分析',
|
||||
'portrait': '肖像',
|
||||
'animation': '动画',
|
||||
'live streaming': '直播',
|
||||
'health records': '健康记录',
|
||||
'medical practice': '医疗实践',
|
||||
'management': '管理',
|
||||
'solution': '解决方案',
|
||||
'open source': '开源',
|
||||
'tool': '工具',
|
||||
'location': '位置',
|
||||
'mobile number': '手机号码',
|
||||
'track': '追踪',
|
||||
'system': '系统',
|
||||
'built in': '构建于',
|
||||
'focused on': '专注于'
|
||||
};
|
||||
|
||||
function translateToChinese(text) {
|
||||
let translated = text;
|
||||
|
||||
// 替换常见术语
|
||||
for (const [eng, chi] of Object.entries(termMap)) {
|
||||
const regex = new RegExp(eng, 'gi');
|
||||
translated = translated.replace(regex, chi);
|
||||
}
|
||||
|
||||
return translated;
|
||||
}
|
||||
|
||||
function getYesterdayDate() {
|
||||
const d = new Date();
|
||||
d.setDate(d.getDate() - 1);
|
||||
@ -98,7 +142,13 @@ function formatForFeishu(data) {
|
||||
message += `${num} ${item.title}\n`;
|
||||
message += `${item.source}\n`;
|
||||
if (item.description) {
|
||||
message += `${item.description}\n`;
|
||||
// 添加中文翻译
|
||||
const translated = translateToChinese(item.description);
|
||||
message += `${translated}\n`;
|
||||
// 如果翻译后不同,显示原文
|
||||
if (translated !== item.description) {
|
||||
message += `(原文:${item.description})\n`;
|
||||
}
|
||||
}
|
||||
message += `🔗 ${item.url}\n\n`;
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user