From aadd694a6b6a42e0893180467779bf1abd6e703a Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Mon, 17 May 2021 16:32:10 +0200 Subject: [PATCH] WRaster: Create structure to make the library translatable The library did not propose the mechanisms to be translated, this patch is creating the structure in autoconf/automake and the translation directory so its messages can be also translated. Signed-off-by: Christophe CURIS --- Makefile.am | 2 +- configure.ac | 2 +- doc/build/Translations.texi | 7 ++-- m4/wm_i18n.m4 | 7 +++- wrlib/Makefile.am | 2 +- wrlib/po/Makefile.am | 90 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 102 insertions(+), 8 deletions(-) create mode 100644 wrlib/po/Makefile.am diff --git a/Makefile.am b/Makefile.am index 786d3e89..167c657a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -80,7 +80,7 @@ if HAVE_XGETTEXT ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) update-lang || exit $$?); \ done -SUBDIRS_PO = WINGs/po po util/po WPrefs.app/po +SUBDIRS_PO = wrlib/po WINGs/po po util/po WPrefs.app/po else @echo "Error: the program 'xgettext' was not found by configure, it is mandatory for this operation" >&2 ; exit 1 endif diff --git a/configure.ac b/configure.ac index d8a4c354..de761848 100644 --- a/configure.ac +++ b/configure.ac @@ -906,7 +906,7 @@ AC_CONFIG_FILES( Makefile dnl WRaster Library - wrlib/Makefile + wrlib/Makefile wrlib/po/Makefile wrlib/tests/Makefile dnl WINGs toolkit diff --git a/doc/build/Translations.texi b/doc/build/Translations.texi index b2faa437..d5a786c9 100644 --- a/doc/build/Translations.texi +++ b/doc/build/Translations.texi @@ -419,23 +419,24 @@ submit your contribution to the project: this is done with @command{git}. @end itemize -In @sc{Window Maker}, you have actually 4 @code{po} files to take care of: +In @sc{Window Maker}, you have actually 5 @code{po} files to take care of: @itemize @minus @item @file{po/@emph{}.po}: for @sc{Window Maker} itself @item @file{WPrefs.app/po/@emph{}.po}: for the Preference Editor program @item @file{WINGs/po/@emph{}.po}: for the graphic toolkit library +@item @file{wrlib/po/@emph{}.po}: for the image processing library @item @file{util/po/@emph{}.po}: for the command-line tools of @sc{Window Maker} @end itemize As stated previously, there is a @command{make} target that can help you to automatically generate -the POT and update the PO for these 4 cases: +the POT and update the PO for these 5 cases: @example make update-lang PO= @end example -Once run, it will have updated as needed the 4 @code{po} files against the latest source code. +Once run, it will have updated as needed the 5 @code{po} files against the latest source code. You may wish to use the command @command{git gui} to view the changes; you can now edit the files to complete the translation, correct them, remove deprecated stuff, ... Please note that the encoding should be set to @emph{UTF-8} as this is now the standard. diff --git a/m4/wm_i18n.m4 b/m4/wm_i18n.m4 index 307481e3..4da91e2c 100644 --- a/m4/wm_i18n.m4 +++ b/m4/wm_i18n.m4 @@ -37,7 +37,7 @@ AC_DEFUN_ONCE([WM_I18N_LANGUAGES], [AC_ARG_VAR([LINGUAS], [list of language translations to support (I18N), use 'list' to get the list of supported languages, default: none])dnl AC_DEFUN([WM_ALL_LANGUAGES], - [m4_esyscmd([( ls WINGs/po/ ; ls po/ ; ls WPrefs.app/po/ ; ls util/po/ ) | sed -n -e '/po$/{s,\.po,,;p}' | sort -u | tr '\n' ' '])])dnl + [m4_esyscmd([( ls wrlib/po/ ; ls WINGs/po/ ; ls po/ ; ls WPrefs.app/po/ ; ls util/po/ ) | sed -n -e '/po$/{s,\.po,,;p}' | sort -u | tr '\n' ' '])])dnl dnl We 'divert' the macro to have it executed as soon as the option list have dnl been processed, so the list of locales will be printed after the configure dnl options have been parsed, but before any test have been run @@ -66,6 +66,7 @@ AS_IF([test "x$LINGUAS" != "x"], supported_locales="" # This is the list of locales that our archive currently supports + wraster_locales=" m4_esyscmd([ls wrlib/po/ | sed -n '/po$/{s,.po,,;p}' | tr '\n' ' '])" wings_locales=" m4_esyscmd([ls WINGs/po/ | sed -n '/po$/{s,.po,,;p}' | tr '\n' ' '])" wmaker_locales=" m4_esyscmd([ls po/ | sed -n '/po$/{s,.po,,;p}' | tr '\n' ' '])" wprefs_locales=" m4_esyscmd([ls WPrefs.app/po/ | sed -n '/po$/{s,.po,,;p}' | tr '\n' ' '])" @@ -81,7 +82,7 @@ AS_IF([test "x$LINGUAS" != "x"], for lang in $LINGUAS; do found=0 wm_missing="" - m4_foreach([REGION], [WINGs, wmaker, WPrefs, util, man], + m4_foreach([REGION], [WRaster, WINGs, wmaker, WPrefs, util, man], [AS_IF([echo "$[]m4_tolower(REGION)[]_locales" | grep " $lang " > /dev/null], [m4_toupper(REGION)MOFILES="$[]m4_toupper(REGION)MOFILES $lang.mo" found=1], @@ -103,6 +104,7 @@ AS_IF([test "x$LINGUAS" != "x"], MANLANGDIRS="`echo $MANMOFILES | sed -e 's,\.mo,,g' `" ], [INTLIBS="" + WRASTERMOFILES="" WINGSMOFILES="" WMAKERMOFILES="" WPREFSMOFILES="" @@ -112,6 +114,7 @@ AS_IF([test "x$LINGUAS" != "x"], dnl dnl The variables that are used in the Makefiles: AC_SUBST([INTLIBS])dnl +AC_SUBST([WRASTERMOFILES])dnl AC_SUBST([WINGSMOFILES])dnl AC_SUBST([WMAKERMOFILES])dnl AC_SUBST([WPREFSMOFILES])dnl diff --git a/wrlib/Makefile.am b/wrlib/Makefile.am index d2d67cf6..e9805387 100644 --- a/wrlib/Makefile.am +++ b/wrlib/Makefile.am @@ -1,6 +1,6 @@ ## automake input file for wrlib -SUBDIRS = . +SUBDIRS = . po DIST_SUBDIRS = $(SUBDIRS) tests AUTOMAKE_OPTIONS = diff --git a/wrlib/po/Makefile.am b/wrlib/po/Makefile.am new file mode 100644 index 00000000..d70e056d --- /dev/null +++ b/wrlib/po/Makefile.am @@ -0,0 +1,90 @@ +DOMAIN = WRaster + +CATALOGS = @WRASTERMOFILES@ + +CLEANFILES = $(CATALOGS) $(DOMAIN).pot + +EXTRA_DIST = + +POTFILES = \ + $(top_srcdir)/wrlib/raster.c \ + $(top_srcdir)/wrlib/alpha_combine.c \ + $(top_srcdir)/wrlib/draw.c \ + $(top_srcdir)/wrlib/color.c \ + $(top_srcdir)/wrlib/load.c \ + $(top_srcdir)/wrlib/save.c \ + $(top_srcdir)/wrlib/gradient.c \ + $(top_srcdir)/wrlib/xpixmap.c \ + $(top_srcdir)/wrlib/convert.c \ + $(top_srcdir)/wrlib/context.c \ + $(top_srcdir)/wrlib/misc.c \ + $(top_srcdir)/wrlib/scale.c \ + $(top_srcdir)/wrlib/rotate.c \ + $(top_srcdir)/wrlib/flip.c \ + $(top_srcdir)/wrlib/convolve.c \ + $(top_srcdir)/wrlib/save_xpm.c \ + $(top_srcdir)/wrlib/xutil.c \ + $(top_srcdir)/wrlib/load_ppm.c \ + $(top_srcdir)/wrlib/load_gif.c \ + $(top_srcdir)/wrlib/load_jpeg.c \ + $(top_srcdir)/wrlib/load_png.c \ + $(top_srcdir)/wrlib/load_tiff.c \ + $(top_srcdir)/wrlib/load_xpm.c \ + $(top_srcdir)/wrlib/load_xpm_normalized.c \ + $(top_srcdir)/wrlib/load_webp.c \ + $(top_srcdir)/wrlib/load_magick.c + +SUFFIXES = .po .mo + +.po.mo: + $(AM_V_GEN)$(MSGFMT) -c -o $@ $< + + +all-local: $(CATALOGS) + + +.PHONY: update-lang + +if HAVE_XGETTEXT +update-lang: $(DOMAIN).pot + $(AM_V_GEN)$(top_srcdir)/script/generate-po-from-template.sh \ + -n "$(PACKAGE_NAME)" -v "$(PACKAGE_VERSION)" -b "$(PACKAGE_BUGREPORT)" \ + -t "$(DOMAIN).pot" "$(srcdir)/$(PO).po" + +$(DOMAIN).pot: $(POTFILES) + $(AM_V_GEN)$(XGETTEXT) --default-domain=$(DOMAIN) \ + --add-comments --keyword=_ --keyword=N_ $(POTFILES) + @if cmp -s $(DOMAIN).po $(DOMAIN).pot; then \ + rm -f $(DOMAIN).po; \ + else \ + mv -f $(DOMAIN).po $(DOMAIN).pot; \ + fi +endif + + +install-data-local: $(CATALOGS) + $(mkinstalldirs) $(DESTDIR)$(localedir) + for n in $(CATALOGS) __DuMmY ; do \ + if test "$$n" -a "$$n" != "__DuMmY" ; then \ + l=`basename $$n .mo`; \ + $(mkinstalldirs) $(DESTDIR)$(localedir)/$$l/LC_MESSAGES; \ + $(INSTALL_DATA) -m 644 $$n $(DESTDIR)$(localedir)/$$l/LC_MESSAGES/$(DOMAIN).mo; \ + fi; \ + done + +uninstall-local: + for n in $(CATALOGS) ; do \ + l=`basename $$n .mo`; \ + rm -f $(DESTDIR)$(localedir)/$$l/LC_MESSAGES/$(DOMAIN).mo; \ + done + +# Create a 'silent rule' for our make check the same way automake does +AM_V_CHKTRANS = $(am__v_CHKTRANS_$(V)) +am__v_CHKTRANS_ = $(am__v_CHKTRANS_$(AM_DEFAULT_VERBOSITY)) +am__v_CHKTRANS_0 = @echo " CHK translations" ; +am__v_CHKTRANS_1 = + +# 'make check' will make sure the tranlation sources are in line with the compiled source +check-local: + $(AM_V_CHKTRANS)$(top_srcdir)/script/check-translation-sources.sh \ + "$(srcdir)" -s "$(top_srcdir)/wrlib/Makefile.am" -- 2.11.4.GIT