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.
This commit is contained in:
Chun-wei Fan 2022-06-16 18:31:37 +08:00
parent 52d01d63db
commit 4af19d4350
3 changed files with 28 additions and 1 deletions

View File

@ -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.

View File

@ -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"

View File

@ -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