Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fdo menu section translation. #751

Open
tumashu opened this issue Nov 3, 2023 · 8 comments
Open

fdo menu section translation. #751

tumashu opened this issue Nov 3, 2023 · 8 comments
Assignees
Labels
bug The issue exposes a bug.
Milestone

Comments

@tumashu
Copy link

tumashu commented Nov 3, 2023

I use 'includeprog icewm-menu-fdo --no-sep-others --seps --no-sub-cats -t x-terminal-emulator', but some menu section can not be translated to Chinese properly, for example: Audio, AudioVideo,Newwork,Utility, Video, I have checked zh_CN.po file, translate can be found. any suggestion?



I use 'includeprog icewm-menu-fdo --no-sep-others --seps --no-sub-cats -t x-terminal-emulator', but some menu section can not be translated to Chinese properly, I have checked zh_CN.po file, translate can be found. any suggestion?

feng@Tumashu ~ $ icewm-menu-fdo --no-sep-others --seps --no-sub-cats -t x-terminal-emulator
separator
menu "办公" applications-office {
prog "词典" org.xfce.Dictionary xfce4-dict
prog "文档查看器" org.gnome.Evince evince
prog "Atril 文档查看器" atril atril
prog "Evolution 邮件及日历" evolution evolution
prog "GoldenDict" goldendict goldendict
prog "LibreOffice Calc" libreoffice-calc icewm-menu-fdo "/usr/share/applications/libreoffice-calc.desktop"
prog "LibreOffice Draw" libreoffice-draw icewm-menu-fdo "/usr/share/applications/libreoffice-draw.desktop"
prog "LibreOffice Math" libreoffice-math icewm-menu-fdo "/usr/share/applications/libreoffice-math.desktop"
prog "LibreOffice Start Center" libreoffice-startcenter libreoffice
prog "LibreOffice Writer" libreoffice-writer icewm-menu-fdo "/usr/share/applications/libreoffice-writer.desktop"
prog "mutt" mutt /usr/bin/x-terminal-emulator -e mutt
prog "MyGNUHealth" org.gnuhealth.mygnuhealth mygnuhealth
prog "WPS 2019" wps-office2019-kprometheus /usr/bin/wps
prog "WPS 表格" wps-office2019-etmain /usr/bin/et
prog "WPS 文字" wps-office2019-wpsmain /usr/bin/wps
prog "WPS 演示" wps-office2019-wppmain /usr/bin/wpp
prog "WPS PDF" wps-office2019-pdfmain /usr/bin/wpspdf
}
menu "教育" applications-science {
prog "GoldenDict" goldendict goldendict
}
menu "开发" applications-development {
prog "Emacs (Client)" emacs icewm-menu-fdo "/usr/share/applications/emacsclient.desktop"
prog "Emacs (GUI)" emacs /usr/bin/emacs
prog "Emacs (Terminal)" emacs /usr/bin/x-terminal-emulator -e /usr/bin/emacs -nw %F
prog "pgAdmin 4" pgadmin4 /usr/pgadmin4/bin/pgadmin4
}
menu "科学" applications-science {
prog "MyGNUHealth" org.gnuhealth.mygnuhealth mygnuhealth
}
menu "设置" preferences-desktop {
prog "打印设置" printer system-config-printer
prog "电源管理器" org.xfce.powermanager xfce4-power-manager-settings
prog "高级网络配置" preferences-system-network nm-connection-editor
prog "可移动驱动器和介质" org.xfce.volman thunar-volman-settings
prog "输入法" input-keyboard im-config
prog "文本编辑器设置" org.xfce.mousepad mousepad --preferences
prog "文件管理器设置" org.xfce.thunar thunar-settings
prog "新立得软件包管理器" synaptic synaptic-pkexec
prog "IBus 首选项" ibus-setup ibus-setup
prog "PulseAudio 音量控制" multimedia-volume-control pavucontrol
prog "Xfce 终端设置" org.xfce.terminal-settings xfce4-terminal --preferences
prog "XScreenSaver Settings" xscreensaver xscreensaver-settings
}
menu "图形" applications-graphics {
prog "火焰截图" org.flameshot.Flameshot flameshot
prog "文档查看器" org.gnome.Evince evince
prog "GNU 图像处理程序" gimp gimp-2.10
prog "ImageMagick (color depth=q16)" display-im6.q16 icewm-menu-fdo "/usr/share/applications/display-im6.q16.desktop"
prog "Inkscape Vector Graphics Editor" org.inkscape.Inkscape inkscape
prog "LibreOffice Draw" libreoffice-draw icewm-menu-fdo "/usr/share/applications/libreoffice-draw.desktop"
prog "Ristretto 图片查看器" org.xfce.ristretto ristretto
prog "XSane" xsane xsane
}
menu "系统" applications-system {
prog "打印设置" printer system-config-printer
prog "任务管理器" org.xfce.taskmanager xfce4-taskmanager
prog "新立得软件包管理器" synaptic synaptic-pkexec
prog "虚拟系统管理器" virt-manager virt-manager
prog "dconf 编辑器" ca.desrt.dconf-editor dconf-editor
prog "GParted 分区编辑器" gparted /usr/sbin/gparted
prog "Grsync" grsync icewm-menu-fdo "/usr/share/applications/grsync.desktop"
prog "Htop" htop /usr/bin/x-terminal-emulator -e htop
prog "Thunar 文件管理器" org.xfce.thunar thunar
prog "UXTerm" mini.xterm uxterm
prog "Xfce 终端" org.xfce.terminal xfce4-terminal
prog "XTerm" mini.xterm xterm
}
menu "Audio" folder {
prog "退出 Libet" io.github.quodlibet.QuodLibet icewm-menu-fdo "/usr/share/applications/io.github.quodlibet.QuodLibet.desktop"
prog "Audacity" audacity icewm-menu-fdo "/usr/share/applications/audacity.desktop"
prog "Ex Falso" io.github.quodlibet.ExFalso exfalso
prog "mpv 媒体播放器" mpv icewm-menu-fdo "/usr/share/applications/mpv.desktop"
prog "PulseAudio 音量控制" multimedia-volume-control pavucontrol
}
menu "AudioVideo" folder {
prog "退出 Libet" io.github.quodlibet.QuodLibet icewm-menu-fdo "/usr/share/applications/io.github.quodlibet.QuodLibet.desktop"
prog "Audacity" audacity icewm-menu-fdo "/usr/share/applications/audacity.desktop"
prog "Ex Falso" io.github.quodlibet.ExFalso exfalso
prog "mpv 媒体播放器" mpv icewm-menu-fdo "/usr/share/applications/mpv.desktop"
prog "Parole 媒体播放器" org.xfce.parole parole
prog "PulseAudio 音量控制" multimedia-volume-control pavucontrol
}
menu "Network" folder {
prog "百度网盘" baidunetdisk icewm-menu-fdo "/usr/share/applications/baidunetdisk.desktop"
prog "远程查看程序" virt-viewer remote-viewer
prog "Chromium 网页浏览器" chromium /usr/bin/chromium
prog "Firefox ESR Web Browser" firefox-esr /usr/lib/firefox-esr/firefox-esr
prog "Hv3 Web Browser" - hv3
prog "mutt" mutt /usr/bin/x-terminal-emulator -e mutt
prog "Notmuch (emacs interface)" emblem-mail icewm-menu-fdo "/usr/share/applications/notmuch-emacs-mua.desktop"
prog "QQ" /usr/share/icons/hicolor/512x512/apps/qq.png /opt/QQ/qq
prog "Remmina Remote Desktop Client" org.remmina.Remmina remmina-file-wrapper
prog "Start Syncthing" syncthing /usr/bin/syncthing serve --no-browser --logfile=default
prog "Syncthing GTK" syncthing-gtk syncthing-gtk
prog "Syncthing Web UI" syncthing /usr/bin/syncthing -browser-only
prog "Thunderbird 邮件/新闻" thunderbird /usr/bin/thunderbird
}
menu "Utility" folder {
prog "截图" org.xfce.screenshooter xfce4-screenshooter
prog "批量重命名" org.xfce.thunar icewm-menu-fdo "/usr/share/applications/thunar-bulk-rename.desktop"
prog "任务管理器" org.xfce.taskmanager xfce4-taskmanager
prog "应用程序查找器" org.xfce.appfinder xfce4-appfinder
prog "Catfish 文件搜索" org.xfce.catfish /usr/bin/catfish
prog "Emacs (GUI)" emacs /usr/bin/emacs
prog "Emacs (Terminal)" emacs /usr/bin/x-terminal-emulator -e /usr/bin/emacs -nw %F
prog "Engrampa 归档管理器" engrampa engrampa
prog "Mousepad" org.xfce.mousepad mousepad
}
menu "Video" folder {
prog "mpv 媒体播放器" mpv icewm-menu-fdo "/usr/share/applications/mpv.desktop"
prog "Parole 媒体播放器" org.xfce.parole parole
}
separator

@gijsbers
Copy link
Collaborator

gijsbers commented Nov 3, 2023

Thank you for bringing this to our attention. As far as I can tell the translations should be retrieved from files like /usr/share/desktop-directories/AudioVideo.directory, /usr/share/desktop-directories/Network.directory and /usr/share/desktop-directories/Utility.directory, but apparently they aren't? Maybe our expert in this matter @Code7R can share his insights?

@Code7R Code7R added the bug The issue exposes a bug. label Jan 13, 2024
@Code7R Code7R added this to the 3.4.6 milestone Jan 13, 2024
@Code7R Code7R self-assigned this Jan 13, 2024
@Code7R Code7R added enhancement The report requests an enhancement beyond the intended behaviour. not a bug The issue was reported as a bug, but has not turned out to be a bug. and removed bug The issue exposes a bug. labels Jan 13, 2024
@Code7R
Copy link
Collaborator

Code7R commented Jan 13, 2024

The top level menu titles are mostly translated using our icewm MO data, not via desktop files, since those additional *.directory files were not always available when the code was implemented. Even now, those *.directory files are part of the "gnome-menus" package on Debian, and their content is incomplete. But I found more issues and fishy code, worth overhauling some parts of data handling in fdomenu.c . Updates will follow soon.

@Code7R Code7R added bug The issue exposes a bug. and removed enhancement The report requests an enhancement beyond the intended behaviour. not a bug The issue was reported as a bug, but has not turned out to be a bug. labels Jan 14, 2024
@tumashu
Copy link
Author

tumashu commented Jan 14, 2024

@Code7R @gijsbers

The top level menu titles are mostly translated using our icewm MO data

I think fdo do not use MO at all, when ret->title == nullptr, fdo will use MO data,

GHashTable* meta_lookup_data;
tListMeta* lookup_category(LPCSTR key)
{
    tListMeta* ret = (tListMeta*) g_hash_table_lookup(meta_lookup_data, key);
    if (ret)
    {
        // auto-translate the default title for the user's language
        if (ret->title == nullptr)
            ret->title = _(ret->key);
    }
    return ret;
}

but, from below code, I think 'ret->title != nullptr' always, when I change

    meta_lookup_data = g_hash_table_new(g_str_hash, g_str_equal);

    for (unsigned i = 0; i < ACOUNT(spec::menuinfo); ++i) {
        tListMeta& what = spec::menuinfo[i];
        if (no_sub_cats && what.parent_sec)
            continue;
        // enforce non-const since we are not destroying that data ever, no key_destroy_func set!
        g_hash_table_insert(meta_lookup_data, (gpointer) what.key, &what);
    }

when I change 'if (ret->title == nullptr)' to 'if (true)', MO data is used.

@tumashu
Copy link
Author

tumashu commented Jan 14, 2024

I think ret->title alway is a string.

tListMeta menuinfo[] =
{
// TRANSLATORS: This is a menu category name from freedesktop.org. Please add spaces as needed but no double-quotes. Context: Graphics
    { N_("2DGraphics"), "2DGraphics", "folder", (char**) &Graphics, 0, 0},
// TRANSLATORS: This is a menu category name from freedesktop.org. Please add spaces as needed but no double-quotes. Context: Graphics
    { N_("3DGraphics"), "3DGraphics", "folder", (char**) &Graphics, 0, 0},
// TRANSLATORS: This is a menu category name from freedesktop.org. Please add spaces as needed but no double-quotes. Context: Settings or Utility
    { N_("Accessibility"), "Accessibility", "folder", (char**) &SettingsorUtility, 0, 0},
// TRANSLATORS: This is a menu category name from freedesktop.org. Please add spaces as needed but no double-quotes. Context: Settings or Utility
    { N_("Accessibility"), "Accessibility", "folder", (char**) &SettingsorUtility, 0, 0},

@Code7R
Copy link
Collaborator

Code7R commented Feb 6, 2024

@tumashu Yes, that's the location where the translation is missing. However, you also don't want to apply gettext() multiple times, but the code is too messy to track this as of now (there were actually preparations to track the translation but it's IMHO buggy).

In the meantime I have decided to reimplement the whole thing from inside, at least the major parts of data collection. It's just too messy, back in 2015 when I decided to use GLib containers (just "because", to avoid further STL or libice framework), that made the code way too awkward. Also this focus on the building of the tree from top to bottom maybe was not the best idea. You can have a look, if you want: https://github.com/Code7R/icewm/tree/ftr_rebuilding_fdomenu (still a snapshot, the code between lines ~350 and ~900 is supposed to be gone, removed or replaced with compacter/better version, changing paradigm to loosely coupled dictionaries, some tree based, some unordered, separating the menu output creation completely from menu filling). ATM I am not sure whether the deeper menu structuring should be performed, and I tend to say: NO, use only main and one sub category level. Otherwise it would become creepy, lots of submenus with just one or two entries in each on a typical user system.

@tumashu
Copy link
Author

tumashu commented Mar 15, 2024

@Code7R wow, good job, when this feature will be merged?

@Code7R
Copy link
Collaborator

Code7R commented Oct 7, 2024

@tumashu Merged on icewm-1-4-BRANCH now. Considering to release it as soon as enough translations have arrived.

@tumashu
Copy link
Author

tumashu commented Oct 22, 2024

good news.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue exposes a bug.
Projects
None yet
Development

No branches or pull requests

3 participants