惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
N
News and Events Feed by Topic
S
Schneier on Security
G
GRAHAM CLULEY
Scott Helme
Scott Helme
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
C
CERT Recently Published Vulnerability Notes
T
The Exploit Database - CXSecurity.com
C
Cisco Blogs
T
The Blog of Author Tim Ferriss
Cisco Talos Blog
Cisco Talos Blog
P
Privacy & Cybersecurity Law Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 司徒正美
Blog — PlanetScale
Blog — PlanetScale
Project Zero
Project Zero
MyScale Blog
MyScale Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
The Last Watchdog
The Last Watchdog
Vercel News
Vercel News
The Cloudflare Blog
C
Check Point Blog
Help Net Security
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
Stack Overflow Blog
Stack Overflow Blog
腾讯CDC
NISL@THU
NISL@THU
S
Security @ Cisco Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
S
SegmentFault 最新的问题
MongoDB | Blog
MongoDB | Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
AWS News Blog
AWS News Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
PCI Perspectives
PCI Perspectives
S
Securelist
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
V
Vulnerabilities – Threatpost
S
Secure Thoughts

mephisto.cc

修复rime-ice无法弹出候选框的问题 开机滚动字体显示优化 个人网站安全防护 树莓派上部署Vaultwarden 使用goaccess实时分析Caddy日志 个人网站监控 Hugo全站AVIF记 Linux下尝试使用Godot开发小游戏 Arch linux dae 透明代理 Airflow接管galler-dl下载任务 如何使用gallery-dl批量下载图像 Arch核显下如何愉快玩Dota2和CS2 Arch/labwc 环境网络相关设置 Rime添加dota2词库 Arch 重装记录 Supertuxkart iOS版终于发布了 打造自己的流媒体音乐服务 剪切板管理工具clipcat推荐 MangoHud性能监控 微信小程序开发记 Rofi试用 解决Arch下VSCode无法输入中文的问题 独立窗口管理器下无法录屏问题处理 上海市二手房成交数据监控 OpenLDAP监控 Arch linux如何顺畅连接蓝牙设备 使用Git和Ansible管理配置文件 Arch Linux SSL VPN 客户端配置 简单获取celery任务实时结果 Arch linux下iNode客户端的安装和使用方法 券商费率调整记 迷你主机组装记 Labwc更换定制皮肤 树莓派跑分流代理 实用自动代理配置示例 九年老鼠标复活记 Openvpn示例 Mac下如何旋转webp图片 如何隐藏Vscode中Markdown PDF插件的头部内容 解决Linux下网络配置无法变更保存的问题 labwc环境启用wlogout Ubuntu下新官方微信尝鲜 简单检测用户是否开启广告屏蔽 Atuin ZFS下卡顿问题解决 Wine安装64位微信 Fish 和 Atuin使用记 Fastapi简单实现临时下载链接 Fastapi微信公众号开发简要 Hugo根据语种展示不同内容 如何修复Waybar微信图标错误 信封加密简要 Linux环境下维护公众号记录 快速隐藏和呼出终端 Wayland环境自动切换壁纸 SuperTuxKart 试玩 简单抓取雪球股票快讯 为什么你的kill命令不能列出信号表 Wine安装微信保姆教程 Hysteria科学上网简要 Ubuntu 23.10 钉钉无法启动解决方法 网站导航栏防止插入Adsense自动广告 Linux环境按键检测 Hugo文末添加最后修改时间 Wayland环境ksnip无法复制问题解决 我眼中的股票市场 Caddy简单图片防盗链 greetd和regreet使用教程 Wayland环境下截图加后期修改 Wayland 环境下gif录屏 Firefox的一些有趣功能 Ubuntu 切换系统语言 Firefox 标题栏高度调整 网站添加回到顶部功能 Hugo自定义字体 Labwc 便捷配置 Wofi使用教程 窗口管理器labwc使用记 文件共享软件Dufs推荐 Hugo静态站点接入Adsense广告 Fcitx5配置详解 Ubuntu安装chrome的方法总结 一种Xterm.js的全屏方案 Google网址收录api Python示例 手机听离线音乐 Snipe it资产导入 应用启动器yofi使用配置 Snipe it资产管理系统安装使用 Ubuntu开机启动加速 Vue3 vite TypeScript跨域等相关设置 Ubuntu手动升级Libreoffice Ubuntu设置alacritty为默认终端 使用Inkscape调整svg图片大小 实用命令 使用mitmproxy给手机app抓包 Python中rstrip方法细解 Github同主机多仓库部署deploy key问题处理 Linux安装最新版本Python KeePassXC使用教程 Ubuntu 22.10连接蓝牙耳机报错br-connection-profile-unavailable解决方法 Caddy日志配置轮转和格式化
简体文章批量转换为繁体
2022-12-06 · via mephisto.cc

简体繁体相互转化是个常见需求,比如网站的多语言支持、多语言的操作手册、输入法等。最近,我发现本站有部分繁体用户访问,因此有必要提供繁体语言支持。

Linux 操作系统下的简繁转换操作如下:

1.安装 opencc

1sudo apt-get install opencc

opencc 是个开源项目,感谢相关人员的无私奉献。

2.单文件转换示例:

1➜  ~ cat simplified.txt
2静夜思
3床前明月光,疑是地上霜。
4举头望明月,低头思故乡。
5➜  ~ opencc -i simplified.txt -o traditional.txt -c s2t.json
6➜  ~ cat traditional.txt
7靜夜思
8牀前明月光,疑是地上霜。
9舉頭望明月,低頭思故鄉。

就这么简单,一首《静夜思》简繁转换就完成了。

参数说明

-i 输入文件

-o 输出文件

-c 配置文件

  • s2t.json Simplified Chinese to Traditional Chinese 简体到繁体
  • t2s.json Traditional Chinese to Simplified Chinese 繁体到简体
  • s2tw.json Simplified Chinese to Traditional Chinese (Taiwan Standard) 简体到台湾正体
  • tw2s.json Traditional Chinese (Taiwan Standard) to Simplified Chinese 台湾正体到简体
  • s2hk.json Simplified Chinese to Traditional Chinese (Hong Kong variant) 简体到香港繁体
  • hk2s.json Traditional Chinese (Hong Kong variant) to Simplified Chinese 香港繁体到简体
  • s2twp.json Simplified Chinese to Traditional Chinese (Taiwan Standard) with Taiwanese idiom 简体到繁体(台湾正体标准)并转换为台湾常用词汇
  • tw2sp.json Traditional Chinese (Taiwan Standard) to Simplified Chinese with Mainland Chinese idiom 繁体(台湾正体标准)到简体并转换为中国大陆常用词汇
  • t2tw.json Traditional Chinese (OpenCC Standard) to Taiwan Standard 繁体(OpenCC 标准)到台湾正体
  • hk2t.json Traditional Chinese (Hong Kong variant) to Traditional Chinese 香港繁体到繁体(OpenCC 标准)
  • t2hk.json Traditional Chinese (OpenCC Standard) to Hong Kong variant 繁体(OpenCC 标准)到香港繁体
  • t2jp.json Traditional Chinese Characters (Kyūjitai) to New Japanese Kanji (Shinjitai) 繁体(OpenCC 标准,旧字体)到日文新字体
  • jp2t.json New Japanese Kanji (Shinjitai) to Traditional Chinese Characters (Kyūjitai) 日文新字体到繁体(OpenCC 标准,旧字体)
  • tw2t.json Traditional Chinese (Taiwan standard) to Traditional Chinese 台湾正体到繁体(OpenCC 标准)
 1    ➜  ~ opencc --help
 2
 3    Open Chinese Convert (OpenCC) Command Line Tool
 4    Author: Carbo Kuo <byvoid@byvoid.com>
 5    Bug Report: http://github.com/BYVoid/OpenCC/issues
 6
 7    Usage:
 8
 9    opencc  [--noflush <bool>] [-i <file>] [-o <file>] [-c <file>] [--]
10            [--version] [-h]
11
12    Options:
13
14    --noflush <bool>
15        Disable flush for every line
16
17    -i <file>,  --input <file>
18        Read original text from <file>.
19
20    -o <file>,  --output <file>
21        Write converted text to <file>.
22
23    -c <file>,  --config <file>
24        Configuration file
25
26    --,  --ignore_rest
27        Ignores the rest of the labeled arguments following this flag.
28
29    --version
30        Displays version information and exits.
31
32    -h,  --help
33        Displays usage information and exits.
34
35
36    Open Chinese Convert (OpenCC) Command Line Tool

3.多文件批量转换

使用fd 命令, 以批量转换 markdown 文件为例:

1fd -e .md -x opencc -i {} -o {/.}.zh-tw.md -c s2t.json
  • fd -e .md 意为查找以.md结尾的文件

  • -x/--exec 对上一步搜索的每个结果执行额外操作

  • opencc -i {} -o {/.}.zh-tw.md -c s2t.json 对每个文件文件执行简繁转换,{}{./}为 fd 命令的语法(示例意思为,假设输入为 aaa.md 输出就为 aaa.zh-tw.md,之所以这么写是博客系统的多语言规则要求,读者可根据下面说明适当更改):

    • {}: A placeholder token that will be replaced with the path of the search result (documents/images/party.jpg).
    • {.}: Like {}, but without the file extension (documents/images/party).
    • {/}: A placeholder that will be replaced by the basename of the search result (party.jpg).
    • {//}: The parent of the discovered path (documents/images).
    • {/.}: The basename, with the extension removed (party).

想要转换文件,只要写对搜索匹配规则,输出为自己想要的文件名即可,笔者用openccfd命令,十多分钟就把几千篇文章从简体转换为繁体了,汉字的各种体间随意转换,方便好用。