From 19202fd2db33f5646944dcd03883d91a1f98442c Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Mon, 17 May 2021 16:32:12 +0200 Subject: [PATCH] WRaster: Create header for i18n helper functions This patch is just adding a single header, but because it also modifies all the C files to add the #include, it was made as a patch on its own to ease review. Signed-off-by: Christophe CURIS --- wrlib/Makefile.am | 1 + wrlib/alpha_combine.c | 4 ++++ wrlib/color.c | 2 ++ wrlib/context.c | 1 + wrlib/convert.c | 1 + wrlib/convolve.c | 3 +++ wrlib/draw.c | 2 ++ wrlib/flip.c | 1 + wrlib/gradient.c | 2 ++ wrlib/load.c | 1 + wrlib/load_gif.c | 2 ++ wrlib/load_jpeg.c | 2 ++ wrlib/load_magick.c | 1 + wrlib/load_png.c | 2 ++ wrlib/load_ppm.c | 2 ++ wrlib/load_tiff.c | 2 ++ wrlib/load_webp.c | 1 + wrlib/load_xpm.c | 2 ++ wrlib/load_xpm_normalized.c | 2 ++ wrlib/misc.c | 1 + wrlib/raster.c | 2 ++ wrlib/rotate.c | 1 + wrlib/save.c | 1 + wrlib/save_xpm.c | 2 ++ wrlib/scale.c | 2 ++ wrlib/wr_i18n.h | 41 +++++++++++++++++++++++++++++++++++++ wrlib/xpixmap.c | 2 ++ wrlib/xutil.c | 2 ++ 28 files changed, 88 insertions(+) create mode 100644 wrlib/wr_i18n.h diff --git a/wrlib/Makefile.am b/wrlib/Makefile.am index e9805387..c1facfb6 100644 --- a/wrlib/Makefile.am +++ b/wrlib/Makefile.am @@ -40,6 +40,7 @@ libwraster_la_SOURCES = \ flip.c \ convolve.c \ save_xpm.c \ + wr_i18n.h \ xutil.c \ xutil.h \ load_ppm.c diff --git a/wrlib/alpha_combine.c b/wrlib/alpha_combine.c index 7f08a50e..915f65b9 100644 --- a/wrlib/alpha_combine.c +++ b/wrlib/alpha_combine.c @@ -18,7 +18,11 @@ * MA 02110-1301, USA. */ +#include "config.h" + #include "wraster.h" +#include "wr_i18n.h" + void RCombineAlpha(unsigned char *d, unsigned char *s, int s_has_alpha, int width, int height, int dwi, int swi, int opacity) { diff --git a/wrlib/color.c b/wrlib/color.c index 085c461d..3403e898 100644 --- a/wrlib/color.c +++ b/wrlib/color.c @@ -30,6 +30,8 @@ #include #include "wraster.h" +#include "wr_i18n.h" + #define MIN(a,b) ((a)<(b) ? (a) : (b)) #define MAX(a,b) ((a)>(b) ? (a) : (b)) diff --git a/wrlib/context.c b/wrlib/context.c index 8e30a63f..69f040cf 100644 --- a/wrlib/context.c +++ b/wrlib/context.c @@ -39,6 +39,7 @@ #include "wraster.h" #include "scale.h" +#include "wr_i18n.h" #ifndef HAVE_FLOAT_MATHFUNC diff --git a/wrlib/convert.c b/wrlib/convert.c index 23df5c66..05a82487 100644 --- a/wrlib/convert.c +++ b/wrlib/convert.c @@ -36,6 +36,7 @@ #include "wraster.h" #include "convert.h" #include "xutil.h" +#include "wr_i18n.h" #define NFREE(n) if (n) free(n) diff --git a/wrlib/convolve.c b/wrlib/convolve.c index a152e267..8873a620 100644 --- a/wrlib/convolve.c +++ b/wrlib/convolve.c @@ -25,7 +25,10 @@ #include #include #include + #include "wraster.h" +#include "wr_i18n.h" + /* *---------------------------------------------------------------------- diff --git a/wrlib/draw.c b/wrlib/draw.c index bf44f8c3..49992600 100644 --- a/wrlib/draw.c +++ b/wrlib/draw.c @@ -28,6 +28,8 @@ #include #include "wraster.h" +#include "wr_i18n.h" + #define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b)) diff --git a/wrlib/flip.c b/wrlib/flip.c index f233238a..b884ab58 100644 --- a/wrlib/flip.c +++ b/wrlib/flip.c @@ -30,6 +30,7 @@ #include "wraster.h" #include "rotate.h" +#include "wr_i18n.h" static RImage *r_flip_vertically(RImage *source); diff --git a/wrlib/gradient.c b/wrlib/gradient.c index 31c0cdfb..84db1ce0 100644 --- a/wrlib/gradient.c +++ b/wrlib/gradient.c @@ -30,6 +30,8 @@ #include #include "wraster.h" +#include "wr_i18n.h" + static RImage *renderHGradient(unsigned width, unsigned height, int r0, int g0, int b0, int rf, int gf, int bf); static RImage *renderVGradient(unsigned width, unsigned height, int r0, int g0, int b0, int rf, int gf, int bf); diff --git a/wrlib/load.c b/wrlib/load.c index f71adba6..6fc4b678 100644 --- a/wrlib/load.c +++ b/wrlib/load.c @@ -36,6 +36,7 @@ #include "wraster.h" #include "imgformat.h" +#include "wr_i18n.h" typedef struct RCachedImage { diff --git a/wrlib/load_gif.c b/wrlib/load_gif.c index d70d0444..5921735f 100644 --- a/wrlib/load_gif.c +++ b/wrlib/load_gif.c @@ -30,6 +30,8 @@ #include "wraster.h" #include "imgformat.h" +#include "wr_i18n.h" + static int InterlacedOffset[] = { 0, 4, 2, 1 }; static int InterlacedJumps[] = { 8, 8, 4, 2 }; diff --git a/wrlib/load_jpeg.c b/wrlib/load_jpeg.c index 1ba0834a..76f7b662 100644 --- a/wrlib/load_jpeg.c +++ b/wrlib/load_jpeg.c @@ -37,6 +37,8 @@ #include "wraster.h" #include "imgformat.h" +#include "wr_i18n.h" + /* * is used for the optional error recovery mechanism shown in diff --git a/wrlib/load_magick.c b/wrlib/load_magick.c index 876db903..d7ff6941 100644 --- a/wrlib/load_magick.c +++ b/wrlib/load_magick.c @@ -32,6 +32,7 @@ #include "wraster.h" #include "imgformat.h" +#include "wr_i18n.h" static int RInitMagickIfNeeded(void); diff --git a/wrlib/load_png.c b/wrlib/load_png.c index aa5c629d..50135b51 100644 --- a/wrlib/load_png.c +++ b/wrlib/load_png.c @@ -30,6 +30,8 @@ #include "wraster.h" #include "imgformat.h" +#include "wr_i18n.h" + RImage *RLoadPNG(RContext *context, const char *file) { diff --git a/wrlib/load_ppm.c b/wrlib/load_ppm.c index 31bc4606..aed36033 100644 --- a/wrlib/load_ppm.c +++ b/wrlib/load_ppm.c @@ -31,6 +31,8 @@ #include "wraster.h" #include "imgformat.h" +#include "wr_i18n.h" + /* * fileio.c - routines to read elements based on Netpbm diff --git a/wrlib/load_tiff.c b/wrlib/load_tiff.c index 9bf033ba..bf21c187 100644 --- a/wrlib/load_tiff.c +++ b/wrlib/load_tiff.c @@ -31,6 +31,8 @@ #include "wraster.h" #include "imgformat.h" +#include "wr_i18n.h" + RImage *RLoadTIFF(const char *file, int index) { diff --git a/wrlib/load_webp.c b/wrlib/load_webp.c index f45ea8f8..367c8b0d 100644 --- a/wrlib/load_webp.c +++ b/wrlib/load_webp.c @@ -30,6 +30,7 @@ #include "wraster.h" #include "imgformat.h" +#include "wr_i18n.h" RImage *RLoadWEBP(const char *file_name) diff --git a/wrlib/load_xpm.c b/wrlib/load_xpm.c index 8f3592d1..f2c433cb 100644 --- a/wrlib/load_xpm.c +++ b/wrlib/load_xpm.c @@ -31,6 +31,8 @@ #include "wraster.h" #include "imgformat.h" +#include "wr_i18n.h" + static RImage *create_rimage_from_xpm(RContext *context, XpmImage xpm) { diff --git a/wrlib/load_xpm_normalized.c b/wrlib/load_xpm_normalized.c index 09371d1f..82be3c4e 100644 --- a/wrlib/load_xpm_normalized.c +++ b/wrlib/load_xpm_normalized.c @@ -30,6 +30,8 @@ #include "wraster.h" #include "imgformat.h" +#include "wr_i18n.h" + /* * Restricted support for XPM images. diff --git a/wrlib/misc.c b/wrlib/misc.c index 615777e1..c504a9a4 100644 --- a/wrlib/misc.c +++ b/wrlib/misc.c @@ -28,6 +28,7 @@ #include "wraster.h" #include "imgformat.h" #include "convert.h" +#include "wr_i18n.h" void RBevelImage(RImage * image, int bevel_type) diff --git a/wrlib/raster.c b/wrlib/raster.c index e2a2d997..0f8fdd11 100644 --- a/wrlib/raster.c +++ b/wrlib/raster.c @@ -26,7 +26,9 @@ #include #include #include + #include "wraster.h" +#include "wr_i18n.h" #include diff --git a/wrlib/rotate.c b/wrlib/rotate.c index 9ffaa30c..12cd41fd 100644 --- a/wrlib/rotate.c +++ b/wrlib/rotate.c @@ -30,6 +30,7 @@ #include "wraster.h" #include "rotate.h" +#include "wr_i18n.h" #include diff --git a/wrlib/save.c b/wrlib/save.c index 86a66c6e..351ec9c3 100644 --- a/wrlib/save.c +++ b/wrlib/save.c @@ -33,6 +33,7 @@ #include "wraster.h" #include "imgformat.h" +#include "wr_i18n.h" Bool RSaveImage(RImage * image, const char *filename, const char *format) diff --git a/wrlib/save_xpm.c b/wrlib/save_xpm.c index 08cb52ec..4be7be5e 100644 --- a/wrlib/save_xpm.c +++ b/wrlib/save_xpm.c @@ -30,6 +30,8 @@ #include "wraster.h" #include "imgformat.h" +#include "wr_i18n.h" + /* * Restricted support for XPM images. diff --git a/wrlib/scale.c b/wrlib/scale.c index 94612333..93c5172d 100644 --- a/wrlib/scale.c +++ b/wrlib/scale.c @@ -31,6 +31,8 @@ #include "wraster.h" #include "scale.h" +#include "wr_i18n.h" + /* *---------------------------------------------------------------------- diff --git a/wrlib/wr_i18n.h b/wrlib/wr_i18n.h new file mode 100644 index 00000000..328e69b5 --- /dev/null +++ b/wrlib/wr_i18n.h @@ -0,0 +1,41 @@ +/* + * Window Maker window manager + * + * Copyright (c) 2021 Window Maker Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program, see the file COPYING. + */ + +/* + * This file defines the basic stuff for WRaster's message + * internationalization in the code + */ + +#ifndef WRASTER_I18N_H +#define WRASTER_I18N_H + +#if defined(HAVE_LIBINTL_H) && defined(I18N) +# include +# define _(text) dgettext("WRaster", (text)) +#else +# define _(text) (text) +#endif + +/* + * the N_ macro is used for initializers, it will make xgettext pick the + * string for translation when generating PO files + */ +#define N_(text) (text) + +#endif diff --git a/wrlib/xpixmap.c b/wrlib/xpixmap.c index b3d38533..ff402e73 100644 --- a/wrlib/xpixmap.c +++ b/wrlib/xpixmap.c @@ -30,6 +30,8 @@ #include #include "wraster.h" +#include "wr_i18n.h" + static int get_shifts(unsigned long mask) { diff --git a/wrlib/xutil.c b/wrlib/xutil.c index 8e90333a..dde6517f 100644 --- a/wrlib/xutil.c +++ b/wrlib/xutil.c @@ -37,6 +37,8 @@ #include "wraster.h" #include "xutil.h" +#include "wr_i18n.h" + #ifdef USE_XSHM