Skip to content

Commit

Permalink
Add rc file localisation infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
J5lx committed Sep 22, 2023
1 parent 8b3a5d7 commit 83febdd
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ setup_macos() {
}

setup_windows() {
pip install --ignore-requires-python translate-toolkit[rc]
curl -fsSLO https://okapiframework.org/binaries/main/1.45.0/okapi-apps_win32-x86_64_1.45.0.zip
mkdir okapi
"${WINDIR}\\System32\\tar" xfC okapi-apps_win32-x86_64_1.45.0.zip okapi
Expand Down
41 changes: 40 additions & 1 deletion app/app.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ UI_DIR = .ui

RESOURCES += data/app.qrc

MUI_TRANSLATIONS += \
translations/mui_de.po

RC_LANGS.de = --lang LANG_GERMAN --sublang SUBLANG_NEUTRAL

EXTRA_TRANSLATIONS += \
$$PWD/../translations/pencil_ar.ts \
$$PWD/../translations/pencil_ca.ts \
Expand Down Expand Up @@ -222,7 +227,41 @@ macx {
}

win32 {
RC_FILE = data/pencil2d.rc
RC_FILES = data/version.rc data/mui.rc

ensurePathEnv()
isEmpty(PO2RC): for(dir, QMAKE_PATH_ENV) {
exists("$$dir/po2rc.exe") {
PO2RC = "$$dir/po2rc.exe"
break()
}
}
!isEmpty(PO2RC) {
defineReplace(rcLang) {
name = $$basename(1)
base = $$section(name, ., 0, -2)
return($$member(RC_LANGS.$$section(base, _, 1), 0, -1))
}
po2rc.name = po2rc
po2rc.input = MUI_TRANSLATIONS
po2rc.output = ${QMAKE_FILE_IN_BASE}.rc
po2rc.commands = $$shell_path($$PO2RC) -t $$PWD/data/mui.rc ${QMAKE_FILE_IN} ${QMAKE_FUNC_FILE_IN_rcLang} ${QMAKE_FILE_OUT}
silent: makepri.commands = @echo po2rc ${QMAKE_FILE_IN} && $$makepri.commands
po2rc.CONFIG = no_link
QMAKE_EXTRA_COMPILERS += po2rc
# variable_out doesn't seem to work in this case
for(file, MUI_TRANSLATIONS): {
name = $$basename(file)
RC_FILES += $$replace(name, .po, .rc)
}
} else {
warning("po2rc was not found. MUI resources will not be translated. You can safely ignore this warning if you do not plan to distribute this build of Pencil2D through its installer.")
}

for(file, RC_FILES): RC_INCLUDES += "$${LITERAL_HASH}include \"$$file\""
write_file($$OUT_PWD/pencil2d.rc, RC_INCLUDES)|error()
RC_FILE = $$OUT_PWD/pencil2d.rc
RC_INCLUDEPATH += $$PWD $$PWD/data
}

unix:!macx {
Expand Down
15 changes: 15 additions & 0 deletions app/data/mui.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#if defined(__MINGW32__) || defined(__MINGW64__)
// This is needed for MinGW versions < 8
// (not to be confused with the GCC version by which Qt labels their MinGW packages)
#include <winresrc.h>
#else
#include <winres.h>
#endif

STRINGTABLE
LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
{
0 "Pencil2D"
1 "Pencil2D Animation"
2 "Pencil2D Animation (Old Format)"
}
12 changes: 2 additions & 10 deletions app/data/pencil2d.rc → app/data/version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ FILETYPE VFT_APP
{
BLOCK "StringFileInfo"
{
BLOCK "040904B0"
BLOCK "000904B0"
{
VALUE "ProductName", "Pencil2D"
#ifdef __GNUC__
Expand All @@ -61,14 +61,6 @@ FILETYPE VFT_APP

BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0409, 0x04B0
VALUE "Translation", 0x0009, 0x04B0
}
}

STRINGTABLE
LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
{
0 "Pencil2D"
1 "Pencil2D Animation"
2 "Pencil2D Animation (Old Format)"
}
27 changes: 27 additions & 0 deletions app/translations/mui.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#. extracted from data\mui.rc
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-22 15:26+0200\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-Accelerator-Marker: &\n"
"X-Generator: Translate Toolkit 3.9.0\n"
"X-Merge-On: location\n"

#: STRINGTABLE.0
msgid "Pencil2D"
msgstr ""

#: STRINGTABLE.1
msgid "Pencil2D Animation"
msgstr ""

#: STRINGTABLE.2
msgid "Pencil2D Animation (Old Format)"
msgstr ""
32 changes: 32 additions & 0 deletions app/translations/mui_de.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Translators:
# Jakob <j5lx@fmail.co.uk>, 2023
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-22 15:26+0200\n"
"PO-Revision-Date: 2023-09-22 14:10+0000\n"
"Last-Translator: Jakob <j5lx@fmail.co.uk>, 2023\n"
"Language-Team: German (https://app.transifex.com/pencil2d/teams/76612/de/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Accelerator-Marker: &\n"
"X-Generator: Translate Toolkit 3.9.0\n"
"X-Merge-On: location\n"

#: STRINGTABLE.0
msgid "Pencil2D"
msgstr "Pencil2D"

#: STRINGTABLE.1
msgid "Pencil2D Animation"
msgstr "Pencil2D-Animation"

#: STRINGTABLE.2
msgid "Pencil2D Animation (Old Format)"
msgstr "Pencil2D-Animation (altes Format)"
2 changes: 1 addition & 1 deletion util/common.pri
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

VERSION = 0.6.6
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
DEFINES += APP_VERSION_RC=$$replace(VERSION, "\.", ",")
RC_DEFINES += APP_VERSION=\\\"$$VERSION\\\" APP_VERSION_RC=$$replace(VERSION, "\.", ",")

PENCIL2D_NIGHTLY {
DEFINES += PENCIL2D_NIGHTLY_BUILD
Expand Down

0 comments on commit 83febdd

Please sign in to comment.