关于xfce4-pulseaudio-plugin中文翻译的bug

文章首发于个人博客

背景

系统从debian 12升到debian 13后,一直有个地方很不爽:鼠标放到状态栏的音量图标上时无法显示当前的具体音量。但是,由于升级过程出了点状况(详见Debian从12升到13的翻车记),一时不确定是自己搞出来的问题还是本来就有bug。

过程

新发现

今天无意间查看~/.xsession-errors内容时,看到大段如下重复的内容:

vbnet 复制代码
(wrapper-2.0:1621): Gtk-WARNING **: 21:29:52.802: Failed to set text '音量 30%
</b><small>内置音频 模拟立体声</small>' from markup due to error parsing markup: 第 2 行第 5 个字符出错: 元素"b"已经闭合,当前仍开放的元素是"markup"

然后瞬间就觉得这可能是个bug!查看插件的关于信息:xfce4-pulseaudio-plugin 0.4.9,卸载并重装插件:

sh 复制代码
# 卸载
sudo apt purge xfce4-pulseaudio-plugin
# 重新安装
sudo apt install xfce4-pulseaudio-plugin
# 重启面板
xfce4-panel -r

重启后,问题仍在。全盘搜索相关文件:

sh 复制代码
sudo find / -name "*xfce4-pulseaudio-plugin*"
# 部分结果如下
/usr/share/icons/hicolor/48x48/apps/xfce4-pulseaudio-plugin.png
/usr/share/icons/hicolor/scalable/apps/xfce4-pulseaudio-plugin.svg
/usr/share/doc/xfce4-pulseaudio-plugin
/usr/share/locale/zh_TW/LC_MESSAGES/xfce4-pulseaudio-plugin.mo
/usr/share/locale/da/LC_MESSAGES/xfce4-pulseaudio-plugin.mo
/usr/share/locale/sv/LC_MESSAGES/xfce4-pulseaudio-plugin.mo
/usr/share/locale/hy_AM/LC_MESSAGES/xfce4-pulseaudio-plugin.mo
/usr/share/locale/ar/LC_MESSAGES/xfce4-pulseaudio-plugin.mo
/usr/share/locale/de/LC_MESSAGES/xfce4-pulseaudio-plugin.mo
/usr/share/locale/sr/LC_MESSAGES/xfce4-pulseaudio-plugin.mo
...

出现了很多xfce4-pulseaudio-plugin.mo的文件,都是在/usr/share/locale/xxx/LC_MESSAGES/这样的文件夹下,很明显这些都是不同语言的翻译。查看简体中文的文件:

sh 复制代码
cat /usr/share/locale/zh_CN/LC_MESSAGES/xfce4-pulseaudio-plugin.mo

果然发现了日志中相似的内容:

xml 复制代码
Plural-Forms: nplurals=1; plural=0;
音量 %d%% (已静音)
</b><small>%s</small>音量 %d%%
</b><small>%s</small><big><b>运行命令 "%s" 失败。</b></big>

再查看繁体中文的文件:

sh 复制代码
cat /usr/share/locale/zh_TW/LC_MESSAGES/xfce4-pulseaudio-plugin.mo

相似的内容如下:

javascript 复制代码
Plural-Forms: nplurals=1; plural=0;
<b>音量 %d%%(已靜音)</b>
<small>%s</small><b>音量 %d%%</b>
<small>%s</small><big><b>執行指令「%s」失敗。</b></big>

两相对比,果然与~/.xsession-errors中记录的日志一致,bug实锤了!

问题修复

邪修

既然是xfce4-pulseaudio-plugin.mo文件的问题,那就改一下好了:

sh 复制代码
# 先备份
sudo cp /usr/share/locale/zh_CN/LC_MESSAGES/xfce4-pulseaudio-plugin.mo /usr/share/locale/zh_CN/LC_MESSAGES/xfce4-pulseaudio-plugin.mo.bak
# 再修改
# 注意:*.mo 文件实际是二进制文件,当做文本文件修改是有风险的
sudo vi /usr/share/locale/zh_CN/LC_MESSAGES/xfce4-pulseaudio-plugin.mo

保存后重启面板。

现在有提示了,但是是中英混合的,虽然能看了,但还是不完美。

正修

网上查了下,*.mo文件是由*.po编译出来的,那就找一下xfce4-pulseaudio-plugin的po吧。

在插件的关于信息中有网站的链接,进去后有gitlab的仓库地址,然后就看到源码的po目录,找到zh_CN.po文件,下载下来,编译一下:

sh 复制代码
sudo msgfmt -o /usr/share/locale/zh_CN/LC_MESSAGES/xfce4-pulseaudio-plugin.mo zh_CN.po

重启面板。OK!搞定了!

回头看了下源码下的NEWS,0.5.1 (2025-04-24)才更新了一些*.po文件,估计是已经过了debian 13的合并窗口期,所以debian 13的仓库中还只是有问题的0.4.9。

总结

邪修不靠谱,还得正经来。

  1. 到官方仓库地址下载po/zh_CN.po文件

  2. 把*.po编译为*.mo

sh 复制代码
sudo msgfmt -o /usr/share/locale/zh_CN/LC_MESSAGES/xfce4-pulseaudio-plugin.mo zh_CN.po
  1. 重启面板

    xfce4-panel -r

相关推荐
mounter6256 小时前
Linux 内核热升级(Live Update)技术详解:PCI、VFIO 与 IOMMU 子系统的演进与实战解析引言
linux·linux kernel·kernel·iommu·vfio
砚凝霜6 小时前
【软考信息安全】第十九章 Unix/Linux安全分析与防护
linux·安全·unix
creator_Li6 小时前
Linux 的 Page Cache
linux·page cache
KING-WU5128 小时前
Linux GDB 调试实战指南:从编译到断点调试
linux·运维·服务器
Lucis__8 小时前
深入理解程序链接与加载—从动静态链接到库加载
linux·elf·链接·程序·动静态库
影视飓风TIM8 小时前
Linux 进程信号原理与剖析
linux·运维·服务器
缘友一世9 小时前
开源 Linux截图工具闪构(SnapForge)
linux·运维·ubuntu·开源·截图
朱包林10 小时前
iTerm2终端配置指南
linux·javascript·python·云原生·容器·kubernetes·云计算
祖力5510 小时前
Linux系统移植、烧录与环境的搭建
linux·运维·服务器
张小姐的猫11 小时前
【Linux】网络编程 —— 多路转接:epoll
linux·运维·网络