refactor: use metaglot to enable i18n for Windows artifact

This commit is contained in:
2026-09-22 13:53:16 +08:00
parent f946247d1d
commit 447a6b45af
22 changed files with 519 additions and 83 deletions
+6
View File
@@ -9,6 +9,12 @@ jobs:
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Install MetaGlot
run: uv tool install git+https://github.com/SarasasChipWorkshop/metaglot.git
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
+6
View File
@@ -7,6 +7,12 @@ jobs:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Install MetaGlot
run: uv tool install git+https://github.com/SarasasChipWorkshop/metaglot.git
- name: Get build dept.
run: |
sudo apt update
+7 -40
View File
@@ -3,45 +3,6 @@ name: Windows CI
on: [push, pull_request, workflow_dispatch]
jobs:
msvc-qmake-build:
strategy:
matrix:
include:
- qt_ver: '6.11.2'
vs: '2022'
aqt_arch: 'win64_msvc2022_64'
msvc_arch: 'x64'
runs-on: windows-2022
steps:
- uses: actions/checkout@v6
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
arch: ${{ matrix.aqt_arch }}
version: ${{ matrix.qt_ver }}
modules: 'qtimageformats'
cache: true
# we need this until miurahr/aqtinstall#1007 ships 3.3.1 for Qt >= 6.11.0 for Windows.
aqtsource: 'aqtinstall @ git+https://github.com/miurahr/aqtinstall@16db45a70b5905ad596941b223469bc86a56901e'
- name: Build
shell: cmd
run: |
set VS=${{ matrix.vs }}
set VCVARS="C:\Program Files (x86)\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
if not exist %VCVARS% set VCVARS="C:\Program Files\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvarsall.bat"
call %VCVARS% ${{ matrix.msvc_arch }}
qmake pineapple-pictures.pro
nmake
nmake clean
windeployqt --verbose=2 --no-quick-import --no-translations --no-opengl-sw --no-system-d3d-compiler --no-system-dxc-compiler --skip-plugin-types tls,networkinformation release\ppic.exe
- uses: actions/upload-artifact@v6
with:
name: "windows-msvc${{ matrix.vs }}-qt${{ matrix.qt_ver }}-qmake-package"
path: release/*
msvc-cmake-build:
strategy:
@@ -56,6 +17,12 @@ jobs:
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Install MetaGlot
run: uv tool install git+https://github.com/SarasasChipWorkshop/metaglot.git
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
@@ -64,7 +31,7 @@ jobs:
modules: 'qtimageformats'
cache: true
# we need this until miurahr/aqtinstall#1007 ships 3.3.1 for Qt >= 6.11.0 for Windows.
aqtsource: 'aqtinstall @ git+https://github.com/miurahr/aqtinstall@16db45a70b5905ad596941b223469bc86a56901e'
aqtsource: 'aqtinstall @ git+https://github.com/miurahr/aqtinstall@16db45a70b5905ad596941b223469bc86a56901a'
- name: Build
shell: cmd
run: |
+24 -19
View File
@@ -99,9 +99,27 @@ set (EXE_NAME ppic)
file (GLOB PPIC_TS_FILES locales/app/*.ts)
set (PPIC_CPP_FILES_FOR_I18N ${PPIC_CPP_FILES})
find_program (UV_EXECUTABLE uv)
if (NOT UV_EXECUTABLE)
message (FATAL_ERROR "uv is required to run the metaglot tool, install it from https://docs.astral.sh/uv/")
endif ()
if (WIN32)
configure_file(assets/pineapple-pictures.rc.in pineapple-pictures.rc @ONLY)
list(APPEND PPIC_RC_FILES ${CMAKE_CURRENT_BINARY_DIR}/pineapple-pictures.rc)
set (PPIC_RC_TEMPLATE_FILE ${CMAKE_CURRENT_BINARY_DIR}/pineapple-pictures.rc.in)
execute_process (
COMMAND ${UV_EXECUTABLE} tool run metaglot render rc
--manifest ${CMAKE_SOURCE_DIR}/dist/pineapple-pictures.rc.in.toml
--po ${CMAKE_SOURCE_DIR}/locales/winrc/*.po
--template ${CMAKE_SOURCE_DIR}/dist/pineapple-pictures.rc.in.liquid
--output ${PPIC_RC_TEMPLATE_FILE}
RESULT_VARIABLE METAGLOT_RESULT
)
if (NOT METAGLOT_RESULT EQUAL 0)
message (FATAL_ERROR "Failed to generate pineapple-pictures.rc.in via MetaGlot (exit code: ${METAGLOT_RESULT}). If it is not installed yet, run: uv tool install git+https://github.com/SarasasChipWorkshop/metaglot.git")
endif ()
configure_file (${PPIC_RC_TEMPLATE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/pineapple-pictures.rc @ONLY)
list (APPEND PPIC_RC_FILES ${CMAKE_CURRENT_BINARY_DIR}/pineapple-pictures.rc)
endif ()
add_executable (${EXE_NAME}
@@ -211,17 +229,17 @@ if (WIN32)
WIN32_EXECUTABLE TRUE
)
elseif (APPLE)
set_source_files_properties(assets/icons/app-icon.icns PROPERTIES
set_source_files_properties(dist/sarasacw-picture.icns PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources"
)
target_sources(${EXE_NAME} PUBLIC assets/icons/app-icon.icns)
target_sources(${EXE_NAME} PUBLIC dist/sarasacw-picture.icns)
# See https://cmake.org/cmake/help/v3.15/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.html
set_target_properties(${EXE_NAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/dist/MacOSXBundleInfo.plist.in
MACOSX_BUNDLE_BUNDLE_NAME "Pineapple Pictures"
MACOSX_BUNDLE_GUI_IDENTIFIER net.blumia.pineapple-pictures
MACOSX_BUNDLE_ICON_FILE app-icon.icns # contains the .icns file name, *without* the path.
MACOSX_BUNDLE_ICON_FILE sarasacw-picture.icns # contains the .icns file name, *without* the path.
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
)
@@ -231,6 +249,7 @@ elseif (UNIX)
endif ()
# install icon
# TODO: assets/icons/app-icon.svg is missing (lost during an assets restructure), fix this later.
install (
FILES assets/icons/app-icon.svg
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps"
@@ -281,20 +300,6 @@ if (DEFINED QM_FILE_INSTALL_DIR)
DESTINATION ${QM_FILE_INSTALL_DIR}
)
endif()
if (WIN32)
install(
FILES
dist/passoc/generic.ico
dist/passoc/jpeg.ico
dist/passoc/gif.ico
dist/passoc/svg.ico
dist/passoc/png.ico
dist/passoc/psd.ico
DESTINATION "${CMAKE_INSTALL_BINDIR}/icons"
)
endif()
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
# CPACK: General Settings
+5 -5
View File
@@ -9,21 +9,21 @@ SPDX-FileCopyrightText = "None"
SPDX-License-Identifier = "CC0-1.0"
[[annotations]]
path = ["README**.md", "NEWS", "assets/**.rc.in", "assets/**.qrc", "dist/appstream/**", "dist/**.in", "dist/**.desktop"]
path = ["README**.md", "NEWS", "assets/**.rc.in", "assets/**.qrc", "dist/appstream/**", "dist/**.in", "dist/**.desktop", "dist/**.rc.in.toml", "dist/**.rc.in.liquid"]
precedence = "aggregate"
SPDX-FileCopyrightText = "None"
SPDX-License-Identifier = "CC0-1.0"
[[annotations]]
path = ["dist/passoc/**"]
path = ["locales/app/**.ts", "locales/winrc/**", "assets/plain/translators.html"]
precedence = "aggregate"
SPDX-FileCopyrightText = "2025 Gary Wang"
SPDX-FileCopyrightText = "Translators from hosted.weblate.org"
SPDX-License-Identifier = "MIT"
[[annotations]]
path = ["locales/app/**.ts", "assets/plain/translators.html"]
path = "tool/**"
precedence = "aggregate"
SPDX-FileCopyrightText = "Translators from hosted.weblate.org"
SPDX-FileCopyrightText = "2026 yyc12345"
SPDX-License-Identifier = "MIT"
[[annotations]]
-18
View File
@@ -1,18 +0,0 @@
IDI_ICON1 ICON DISCARDABLE "@CMAKE_CURRENT_SOURCE_DIR@/assets/embeds/app.ico"
1 VERSIONINFO
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", "Pineapple Pictures - Image Viewer"
VALUE "LegalCopyright", "MIT/Expat License - Copyright (C) 2026 Gary Wang"
VALUE "ProductName", "Pineapple Pictures"
VALUE "ProductVersion", "@PROJECT_VERSION@"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
View File

Before

Width:  |  Height:  |  Size: 114 KiB

After

Width:  |  Height:  |  Size: 114 KiB

View File

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 132 KiB

View File

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB

View File

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 105 KiB

View File

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

+72
View File
@@ -0,0 +1,72 @@
// Generated by MetaGlot. DO NOT EDIT.
// Sources: dist/pineapple-pictures.rc.in.toml, locales/winrc/*.po (CMake placeholders are substituted later).
#pragma code_page(65001)
// ---------------------------------------------------------------------------
// Icon resources (referenced from the registry as "<exe path>,-<id>")
// ---------------------------------------------------------------------------
101 ICON "@CMAKE_CURRENT_SOURCE_DIR@/dist/embeds/app.ico" // app
102 ICON "@CMAKE_CURRENT_SOURCE_DIR@/dist/embeds/bmp.ico" // bmp
103 ICON "@CMAKE_CURRENT_SOURCE_DIR@/dist/embeds/gif.ico" // gif
104 ICON "@CMAKE_CURRENT_SOURCE_DIR@/dist/embeds/jpg.ico" // jpg
105 ICON "@CMAKE_CURRENT_SOURCE_DIR@/dist/embeds/png.ico" // png
// ---------------------------------------------------------------------------
// String tables (file type descriptions, referenced as "@<exe path>,-<id>")
// ---------------------------------------------------------------------------
{% for lang in languages -%}
// {{ lang.name }}
LANGUAGE {{ lang.primary }}, {{ lang.sublanguage }}
STRINGTABLE
BEGIN
{%- for i in (1000..1028) -%}
{% assign key = i | to_string %}
{{ i }} "{{ lang.strings[key] | rc_escape }}"
{%- endfor %}
END
{% endfor -%}
// ---------------------------------------------------------------------------
// Version information (one VERSIONINFO resource per language; Windows picks by resource language)
// ---------------------------------------------------------------------------
{% for lang in languages -%}
LANGUAGE {{ lang.primary }}, {{ lang.sublanguage }}
1 VERSIONINFO
FILEVERSION @PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@, 0
PRODUCTVERSION @PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@, 0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L // VOS_NT_WINDOWS32
FILETYPE 0x1L // VFT_APP
FILESUBTYPE 0x0L // VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "{{ lang.block_key }}"
BEGIN
VALUE "Comments", "https://github.com/BLumia/pineapple-pictures"
VALUE "CompanyName", "Gary Wang"
VALUE "FileDescription", "{{ lang.strings.file_description | rc_escape }}"
VALUE "FileVersion", "@PROJECT_VERSION@"
VALUE "InternalName", "ppic"
VALUE "LegalCopyright", "MIT/Expat License - Copyright (C) 2026 Gary Wang"
VALUE "OriginalFilename", "ppic.exe"
VALUE "ProductName", "{{ lang.strings.product_name | rc_escape }}"
VALUE "ProductVersion", "@PROJECT_VERSION@"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", {{ lang.langid }}, {{ lang.code_page }}
END
END
{% endfor -%}
+127
View File
@@ -0,0 +1,127 @@
version = 1
source_language = "en"
[strings.1000]
msgid = "Pineapple Pictures"
context = "Explorer"
comment = "Application friendly name shown by Explorer, e.g. in the 'Open with' menu."
[strings.1001]
msgid = "JPEG Image"
comment = "File type name for: jpg, jpeg, jfif"
[strings.1002]
msgid = "GIF Animation Image"
comment = "File type name for: gif"
[strings.1003]
msgid = "PNG Image"
comment = "File type name for: png"
[strings.1004]
msgid = "Scalable Vector Graphics"
comment = "File type name for: svg"
[strings.1005]
msgid = "WebP Image"
comment = "File type name for: webp"
[strings.1006]
msgid = "AV1 Image File"
comment = "File type name for: avif"
[strings.1007]
msgid = "Windows Icon Image"
comment = "File type name for: ico"
[strings.1008]
msgid = "Apple Icon Image"
comment = "File type name for: icns"
[strings.1009]
msgid = "Photoshop Document"
comment = "File type name for: psd, psb, pdd, psdt"
[strings.1010]
msgid = "Krita Document"
comment = "File type name for: kra"
[strings.1011]
msgid = "GIMP Document"
comment = "File type name for: xcf"
[strings.1012]
msgid = "TARGA Image"
comment = "File type name for: tga"
[strings.1013]
msgid = "Tagged Image File Format"
comment = "File type name for: tif, tiff"
[strings.1014]
msgid = "Bitmap"
comment = "File type name for: bmp"
[strings.1015]
msgid = "Wireless Bitmap"
comment = "File type name for: wbmp"
[strings.1016]
msgid = "DirectDraw Surface"
comment = "File type name for: dds"
[strings.1017]
msgid = "High Dynamic Range Image"
comment = "File type name for: hdr"
[strings.1018]
msgid = "Interchange File Format"
comment = "File type name for: iff"
[strings.1019]
msgid = "Softimage Picture"
comment = "File type name for: pic"
[strings.1020]
msgid = "PiCture eXchange PC Paintbrush Image"
comment = "File type name for: pcx"
[strings.1021]
msgid = "Quite OK Image"
comment = "File type name for: qoi"
[strings.1022]
msgid = "Sun Raster Image"
comment = "File type name for: ras, sun"
[strings.1023]
msgid = "OpenRaster Image"
comment = "File type name for: ora"
[strings.1024]
msgid = "Animated Cursor"
comment = "File type name for: ani"
[strings.1025]
msgid = "Portable Float Map"
comment = "File type name for: pfm, phm"
[strings.1026]
msgid = "Silicon Graphics Image"
comment = "File type name for: rgb, rgba, bw, sgi"
[strings.1027]
msgid = "Pixar Raster Image"
comment = "File type name for: pxr"
[strings.1028]
msgid = "Scitex Continuous Tone"
comment = "File type name for: sct"
[strings.file_description]
msgid = "Pineapple Pictures - Image Viewer"
comment = "File description of the executable."
[strings.product_name]
msgid = "Pineapple Pictures"
comment = "Display name of the product."
+137
View File
@@ -0,0 +1,137 @@
#
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"
#. Application friendly name shown by Explorer, e.g. in the 'Open with' menu.
msgctxt "Explorer"
msgid "Pineapple Pictures"
msgstr ""
#. File type name for: jpg, jpeg, jfif
msgid "JPEG Image"
msgstr ""
#. File type name for: gif
msgid "GIF Animation Image"
msgstr ""
#. File type name for: png
msgid "PNG Image"
msgstr ""
#. File type name for: svg
msgid "Scalable Vector Graphics"
msgstr ""
#. File type name for: webp
msgid "WebP Image"
msgstr ""
#. File type name for: avif
msgid "AV1 Image File"
msgstr ""
#. File type name for: ico
msgid "Windows Icon Image"
msgstr ""
#. File type name for: icns
msgid "Apple Icon Image"
msgstr ""
#. File type name for: psd, psb, pdd, psdt
msgid "Photoshop Document"
msgstr ""
#. File type name for: kra
msgid "Krita Document"
msgstr ""
#. File type name for: xcf
msgid "GIMP Document"
msgstr ""
#. File type name for: tga
msgid "TARGA Image"
msgstr ""
#. File type name for: tif, tiff
msgid "Tagged Image File Format"
msgstr ""
#. File type name for: bmp
msgid "Bitmap"
msgstr ""
#. File type name for: wbmp
msgid "Wireless Bitmap"
msgstr ""
#. File type name for: dds
msgid "DirectDraw Surface"
msgstr ""
#. File type name for: hdr
msgid "High Dynamic Range Image"
msgstr ""
#. File type name for: iff
msgid "Interchange File Format"
msgstr ""
#. File type name for: pic
msgid "Softimage Picture"
msgstr ""
#. File type name for: pcx
msgid "PiCture eXchange PC Paintbrush Image"
msgstr ""
#. File type name for: qoi
msgid "Quite OK Image"
msgstr ""
#. File type name for: ras, sun
msgid "Sun Raster Image"
msgstr ""
#. File type name for: ora
msgid "OpenRaster Image"
msgstr ""
#. File type name for: ani
msgid "Animated Cursor"
msgstr ""
#. File type name for: pfm, phm
msgid "Portable Float Map"
msgstr ""
#. File type name for: rgb, rgba, bw, sgi
msgid "Silicon Graphics Image"
msgstr ""
#. File type name for: pxr
msgid "Pixar Raster Image"
msgstr ""
#. File type name for: sct
msgid "Scitex Continuous Tone"
msgstr ""
#. File description of the executable.
msgid "Pineapple Pictures - Image Viewer"
msgstr ""
#. Display name of the product.
msgid "Pineapple Pictures"
msgstr ""
+134
View File
@@ -0,0 +1,134 @@
msgid ""
msgstr ""
"Project-Id-Version: pineapple-pictures\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\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"
#. Application friendly name shown by Explorer, e.g. in the 'Open with' menu.
msgctxt "Explorer"
msgid "Pineapple Pictures"
msgstr "菠萝看图"
#. File type name for: jpg, jpeg, jfif
msgid "JPEG Image"
msgstr "JPEG 图像"
#. File type name for: gif
msgid "GIF Animation Image"
msgstr "GIF 动图"
#. File type name for: png
msgid "PNG Image"
msgstr "PNG 图像"
#. File type name for: svg
msgid "Scalable Vector Graphics"
msgstr "可缩放矢量图像"
#. File type name for: webp
msgid "WebP Image"
msgstr "WebP 图像"
#. File type name for: avif
msgid "AV1 Image File"
msgstr "AV1 图像文件"
#. File type name for: ico
msgid "Windows Icon Image"
msgstr "Windows 图标图像"
#. File type name for: icns
msgid "Apple Icon Image"
msgstr "苹果图标图像"
#. File type name for: psd, psb, pdd, psdt
msgid "Photoshop Document"
msgstr "Photoshop 文档"
#. File type name for: kra
msgid "Krita Document"
msgstr "Krita 文档"
#. File type name for: xcf
msgid "GIMP Document"
msgstr "GIMP 文档"
#. File type name for: tga
msgid "TARGA Image"
msgstr "TARGA 图像"
#. File type name for: tif, tiff
msgid "Tagged Image File Format"
msgstr "标签图像文件格式"
#. File type name for: bmp
msgid "Bitmap"
msgstr "位图"
#. File type name for: wbmp
msgid "Wireless Bitmap"
msgstr "无线位图"
#. File type name for: dds
msgid "DirectDraw Surface"
msgstr "DirectDraw 表面"
#. File type name for: hdr
msgid "High Dynamic Range Image"
msgstr "高动态范围图像"
#. File type name for: iff
msgid "Interchange File Format"
msgstr "可交换文件格式"
#. File type name for: pic
msgid "Softimage Picture"
msgstr "Softimage 图像"
#. File type name for: pcx
msgid "PiCture eXchange PC Paintbrush Image"
msgstr "PC Paintbrush 图像"
#. File type name for: qoi
msgid "Quite OK Image"
msgstr "挺 OK 图像"
#. File type name for: ras, sun
msgid "Sun Raster Image"
msgstr "Sun 栅格图象"
#. File type name for: ora
msgid "OpenRaster Image"
msgstr "OpenRaster 图象"
#. File type name for: ani
msgid "Animated Cursor"
msgstr "动态光标"
#. File type name for: pfm, phm
msgid "Portable Float Map"
msgstr "便携式浮点图"
#. File type name for: rgb, rgba, bw, sgi
msgid "Silicon Graphics Image"
msgstr "Silicon Graphics 图像"
#. File type name for: pxr
msgid "Pixar Raster Image"
msgstr "Pixar 栅格图像"
#. File type name for: sct
msgid "Scitex Continuous Tone"
msgstr "Scitex 连续色调图像"
#. File description of the executable.
msgid "Pineapple Pictures - Image Viewer"
msgstr "菠萝看图 - 图像查看器"
#. Display name of the product.
msgid "Pineapple Pictures"
msgstr "菠萝看图"