From 4af19d4350814e62ec6acc28eb1027933a9aad3d Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Thu, 16 Jun 2022 18:31:37 +0800 Subject: [PATCH] Visual Studio builds: Add optional rules to generate translations Add a target in the install-msvc.mak file that enables one to generate the translations (.mo) files using msgfmt from the .po catalog files. Add an entry in config-msvc.mak[.in] so that one can use it to configure a custom location for the msgfmt.exe program, since it is harder to install with Visual Studio, so that one can use a prebuilt copy from Cygwin or MSYS2, for instance. --- win32/README_FEATURES_MSVC.txt | 11 +++++++++++ win32/config-msvc.mak.in | 4 ++++ win32/install-msvc.mak | 14 +++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/win32/README_FEATURES_MSVC.txt b/win32/README_FEATURES_MSVC.txt index 2a37aea19f..0cf8efda13 100644 --- a/win32/README_FEATURES_MSVC.txt +++ b/win32/README_FEATURES_MSVC.txt @@ -71,3 +71,14 @@ NMake command line. The gtk3-demo project files will also be updated with the appropriate dependent libraries linked in-please check that the project settings contain the correct .lib file names for your system, as they assume the most common names are used there. + +========================= +Building the translations +========================= +Building translations is supported via Meson builds or via the Visual Studio projects, +both of which require a working msgfmt.exe (from gettext-tools, a part of gettext) in the +PATH, or for the Visual Studio projects, passed into the arguments in "InstallBuildsBase" +in gtk3-build-defines.[props|vsprops] with MSGFMT=xxx. For the Visual Studio projects, for +this to work one needs to also supply a "INSTALL_TRANSLATIONS=1" (without the quotes) +argument to the same "InstallBuildsBase" in the afore-mentioned property sheet. Using +msgfmt.exe from Cygwin or MSYS2 is supported as well. diff --git a/win32/config-msvc.mak.in b/win32/config-msvc.mak.in index 26ab2186ba..d3fc362377 100644 --- a/win32/config-msvc.mak.in +++ b/win32/config-msvc.mak.in @@ -42,6 +42,10 @@ GDBUS_CODEGEN = $(PREFIX)\bin\gdbus-codegen GLIB_COMPILE_SCHEMAS = $(PREFIX)\bin\glib-compile-schemas.exe !endif +!ifndef MSGFMT +MSGFMT = msgfmt +!endif + !if "$(PLAT)" == "x64" AT_PLAT=x86_64 !elseif "$(PLAT)" == "arm64" diff --git a/win32/install-msvc.mak b/win32/install-msvc.mak index 5fe35d8762..b39764727a 100644 --- a/win32/install-msvc.mak +++ b/win32/install-msvc.mak @@ -51,7 +51,13 @@ GTK_TYPE_BULITINS_H = .\vs$(VSVER)\$(CFG)\$(PLAT)\obj\gtk-$(GTK_API_VERSION)\gtk GTK_VERSION_H = .\vs$(VSVER)\$(CFG)\$(PLAT)\obj\gtk-$(GTK_API_VERSION)\gtk\gtkversion.h GTK_GENERATED_PUBLIC_H = $(GTK_TYPE_BULITINS_H) $(GTK_VERSION_H) -all: install-bin install-headers install-data +!ifdef INSTALL_TRANSLATIONS +DATA_TARGETS = install-data install-translations +!else +DATA_TARGETS = install-data +!endif + +all: install-bin install-headers $(DATA_TARGETS) # Copy the built files install-bin: @@ -131,3 +137,9 @@ install-data: @for %x in (its loc) do @copy ..\gtk\gtkbuilder.%x $(PREFIX)\share\gettext\its @for %x in (rng) do @copy ..\gtk\gtkbuilder.%x $(PREFIX)\share\gtk-3.0 @for %l in (de es fr zh) do @for %f in ($(BASE_BUILT_BIN_DIR)\%l.gresource) do @copy %f $(PREFIX)\share\gtk-3.0\emoji + +# Generate and install the translations +install-translations: + @for %d in (po po-properties) do @for %l in (..\%d\*.po) do @if not exist $(PREFIX)\share\locale\%~nl\LC_MESSAGES\ md $(PREFIX)\share\locale\%~nl\LC_MESSAGES + @for %l in (..\po\*.po) do @$(MSGFMT) -c -v -o $(PREFIX)\share\locale\%~nl\LC_MESSAGES\gtk30.mo %l + @for %l in (..\po-properties\*.po) do @$(MSGFMT) -c -v -o $(PREFIX)\share\locale\%~nl\LC_MESSAGES\gtk30-properties.mo %l