Skip to content

Commit

Permalink
gettext is now optional
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed May 13, 2024
1 parent cae3645 commit 57b843c
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@ target_link_libraries(httping ${OPENSSL_LIBRARIES})
target_include_directories(httping PUBLIC ${OPENSSL_INCLUDE_DIRS})
target_compile_options(httping PUBLIC ${OPENSSL_CFLAGS_OTHER})

if (USE_GETTEXT)
add_definitions(-DUSE_GETTEXT=1)

execute_process (
COMMAND bash -c "msgfmt -o nl.mo ${CMAKE_SOURCE_DIR}/nl.po"
)
execute_process (
COMMAND bash -c "msgfmt -o ru.mo ${CMAKE_SOURCE_DIR}/ru.po"
)
endif ()

configure_file(config.h.in config.h)
target_include_directories(httping PUBLIC "${PROJECT_BINARY_DIR}")
Expand All @@ -52,5 +56,7 @@ include(GNUInstallDirs)
install(TARGETS httping DESTINATION bin)
install(FILES README.md LICENSE plot-json.py DESTINATION ${CMAKE_INSTALL_DOCDIR})
install(FILES httping.1 DESTINATION ${CMAKE_INSTALL_MANDIR})
if (USE_GETTEXT)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nl.mo DESTINATION ${CMAKE_INSTALL_LOCALEDIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ru.mo DESTINATION ${CMAKE_INSTALL_LOCALEDIR})
endif ()
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ If you would like the TUI (text user interface) to be included (for -K),
use:
* cmake -DUSE_TUI=1 ..


If you want httping to use local translations, add "-DUSE_GETTEXT=1" to
the cmake commandline.
2 changes: 1 addition & 1 deletion error.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Released under AGPL v3 with exception for the OpenSSL library. See license.txt */

#include <libintl.h>
#include "gen.h"
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion fft.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "config.h"
#if HAVE_FFTW3
#include <libintl.h>
#include "gen.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
Expand Down
6 changes: 6 additions & 0 deletions gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
#define min(x, y) ((x) < (y) ? (x) : (y))
#define max(x, y) ((x) > (y) ? (x) : (y))

#if USE_GETTEXT
#include <libintl.h>
#else
#define gettext(x) (x)
#endif

typedef struct
{
double cur, min, avg, max, sd, med;
Expand Down
2 changes: 1 addition & 1 deletion help.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "config.h"
#include <libintl.h>
#include "gen.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion io.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Released under AGPL v3 with exception for the OpenSSL library. See license.txt */

#include <errno.h>
#include <libintl.h>
#include "gen.h"
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <sys/ioctl.h>
#include <stdio.h>
#include <locale.h>
#include <libintl.h>
#include "gen.h"
#include <stdlib.h>
#include <errno.h>
#include <math.h>
Expand Down
2 changes: 1 addition & 1 deletion mssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "config.h"
#ifndef NO_SSL
#include <errno.h>
#include <libintl.h>
#include "gen.h"
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
Expand Down
2 changes: 1 addition & 1 deletion nc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#if HAVE_NCURSES
#define _GNU_SOURCE
#include <stdio.h>
#include <libintl.h>
#include "gen.h"
#include <math.h>
#include <poll.h>
#include <stdarg.h>
Expand Down
2 changes: 1 addition & 1 deletion res.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <libintl.h>
#include "gen.h"
#include <netdb.h>
#include <errno.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion socks5.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <libintl.h>
#include "gen.h"
#include <unistd.h>
#include <stdio.h>
#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <libintl.h>
#include "gen.h"
#include <netdb.h>
#include <errno.h>
#include <stdio.h>
Expand Down
2 changes: 1 addition & 1 deletion utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <unistd.h>
#include <sys/time.h>
#include <time.h>
#include <libintl.h>
#include "gen.h"

#include "error.h"
#include "utils.h"
Expand Down

0 comments on commit 57b843c

Please sign in to comment.