refactor: use metaglot to take desktop file i18n over

This commit is contained in:
2026-09-22 15:29:09 +08:00
parent 447a6b45af
commit 22cae20707
7 changed files with 128 additions and 18 deletions
+15 -2
View File
@@ -256,9 +256,22 @@ elseif (UNIX)
RENAME net.blumia.pineapple-pictures.svg RENAME net.blumia.pineapple-pictures.svg
) )
# install shortcut # generate and install desktop entry file
set (PPIC_DESKTOP_FILE ${CMAKE_CURRENT_BINARY_DIR}/net.blumia.pineapple-pictures.desktop)
execute_process (
COMMAND ${UV_EXECUTABLE} tool run metaglot render desktop
--manifest ${CMAKE_SOURCE_DIR}/dist/net.blumia.pineapple-pictures.desktop.toml
--po ${CMAKE_SOURCE_DIR}/locales/desktop/*.po
--template ${CMAKE_SOURCE_DIR}/dist/net.blumia.pineapple-pictures.desktop.liquid
--output ${PPIC_DESKTOP_FILE}
RESULT_VARIABLE METAGLOT_DESKTOP_RESULT
)
if (NOT METAGLOT_DESKTOP_RESULT EQUAL 0)
message (FATAL_ERROR "Failed to generate net.blumia.pineapple-pictures.desktop via MetaGlot (exit code: ${METAGLOT_DESKTOP_RESULT}). If it is not installed yet, run: uv tool install git+https://github.com/SarasasChipWorkshop/metaglot.git")
endif ()
install ( install (
FILES dist/net.blumia.pineapple-pictures.desktop FILES ${PPIC_DESKTOP_FILE}
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications"
) )
-16
View File
@@ -1,16 +0,0 @@
[Desktop Entry]
Categories=Graphics;
Comment=Pineapple Pictures is a lightweight image viewer
Comment[zh_CN]=菠萝看图是一个轻量级的图像查看器
Exec=ppic %F
GenericName=Image Viewer
GenericName[zh_CN]=图像查看器
GenericName[ja]=画像ビューアー
Icon=net.blumia.pineapple-pictures
Keywords=Picture;Image;Viewer;Jpg;Jpeg;Png;
MimeType=image/bmp;image/bmp24;image/jpg;image/jpe;image/jpeg;image/jpeg24;image/jng;image/pcd;image/pcx;image/png;image/tif;image/tiff;image/tiff24;image/dds;image/gif;image/sgi;image/j2k;image/jp2;image/pct;image/wdp;image/arw;image/icb;image/dng;image/vda;image/vst;image/svg;image/ptif;image/mef;image/xbm;image/svg+xml;
Name=Pineapple Pictures
Name[zh_CN]=菠萝看图
StartupNotify=false
Type=Application
Terminal=false
+18
View File
@@ -0,0 +1,18 @@
[Desktop Entry]
Type=Application
Name={{ default.strings.name | desktop_escape }}
GenericName={{ default.strings.generic_name | desktop_escape }}
Comment={{ default.strings.comment | desktop_escape }}
Exec=ppic %F
Icon=net.blumia.pineapple-pictures
Terminal=false
StartupNotify=false
Categories=Graphics;
MimeType=image/bmp;image/bmp24;image/jpg;image/jpe;image/jpeg;image/jpeg24;image/jng;image/pcd;image/pcx;image/png;image/tif;image/tiff;image/tiff24;image/dds;image/gif;image/sgi;image/j2k;image/jp2;image/pct;image/wdp;image/arw;image/icb;image/dng;image/vda;image/vst;image/svg;image/ptif;image/mef;image/xbm;image/svg+xml;
Keywords={{ default.strings.keywords | desktop_escape }}
{% for lang in languages %}
Name[{{ lang.locale }}]={{ lang.strings.name | desktop_escape }}
GenericName[{{ lang.locale }}]={{ lang.strings.generic_name | desktop_escape }}
Comment[{{ lang.locale }}]={{ lang.strings.comment | desktop_escape }}
Keywords[{{ lang.locale }}]={{ lang.strings.keywords | desktop_escape }}
{% endfor %}
+18
View File
@@ -0,0 +1,18 @@
version = 1
source_language = "en"
[strings.name]
msgid = "Pineapple Pictures"
comment = "Display name of the application."
[strings.generic_name]
msgid = "Image Viewer"
comment = "Generic name describing the application category."
[strings.comment]
msgid = "Pineapple Pictures is a lightweight image viewer"
comment = "Tooltip-like description of the application."
[strings.keywords]
msgid = "Picture;Image;Viewer;Jpg;Jpeg;Png;"
comment = "Search keywords. Semicolon separated list; the trailing semicolon is required."
+29
View File
@@ -0,0 +1,29 @@
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: MetaGlot/polib\n"
#. Display name of the application.
msgid "Pineapple Pictures"
msgstr ""
#. Generic name describing the application category.
msgid "Image Viewer"
msgstr ""
#. Tooltip-like description of the application.
msgid "Pineapple Pictures is a lightweight image viewer"
msgstr ""
#. Search keywords. Semicolon separated list; the trailing semicolon is
#. required.
msgid "Picture;Image;Viewer;Jpg;Jpeg;Png;"
msgstr ""
+24
View File
@@ -0,0 +1,24 @@
msgid ""
msgstr ""
"Project-Id-Version: pineapple-pictures\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. Display name of the application.
msgid "Pineapple Pictures"
msgstr ""
#. Generic name describing the application category.
msgid "Image Viewer"
msgstr "画像ビューアー"
#. Tooltip-like description of the application.
msgid "Pineapple Pictures is a lightweight image viewer"
msgstr ""
#. Search keywords. Semicolon separated list; the trailing semicolon is required.
msgid "Picture;Image;Viewer;Jpg;Jpeg;Png;"
msgstr ""
+24
View File
@@ -0,0 +1,24 @@
msgid ""
msgstr ""
"Project-Id-Version: pineapple-pictures\n"
"Language: zh_CN\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. Display name of the application.
msgid "Pineapple Pictures"
msgstr "菠萝看图"
#. Generic name describing the application category.
msgid "Image Viewer"
msgstr "图像查看器"
#. Tooltip-like description of the application.
msgid "Pineapple Pictures is a lightweight image viewer"
msgstr "菠萝看图是一个轻量级的图像查看器"
#. Search keywords. Semicolon separated list; the trailing semicolon is required.
msgid "Picture;Image;Viewer;Jpg;Jpeg;Png;"
msgstr ""