Internationalization support
This patch adds i18n-support with gettext, all translatable strings in the code should be placed inside _() to make sure users see them in their own language (I only did this for print_version() for now)
This commit is contained in:
@@ -48,6 +48,8 @@ mark_as_advanced(RELEASE)
|
|||||||
|
|
||||||
option(MAINTAINER_MODE "Enable maintainer mode (builds docs)" false)
|
option(MAINTAINER_MODE "Enable maintainer mode (builds docs)" false)
|
||||||
|
|
||||||
|
set(LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale" CACHE STRING "Directory containing the locales")
|
||||||
|
|
||||||
# Some standard options
|
# Some standard options
|
||||||
set(SYSTEM_CONFIG_FILE "/etc/conky/conky.conf" CACHE STRING "Default system-wide Conky configuration file")
|
set(SYSTEM_CONFIG_FILE "/etc/conky/conky.conf" CACHE STRING "Default system-wide Conky configuration file")
|
||||||
# use FORCE below to make sure this changes when CMAKE_INSTALL_PREFIX is modified
|
# use FORCE below to make sure this changes when CMAKE_INSTALL_PREFIX is modified
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#define PACKAGE_LIBDIR "@PACKAGE_LIBRARY_DIR@"
|
#define PACKAGE_LIBDIR "@PACKAGE_LIBRARY_DIR@"
|
||||||
#define DEFAULTNETDEV "@DEFAULTNETDEV@"
|
#define DEFAULTNETDEV "@DEFAULTNETDEV@"
|
||||||
#define CONFIG_FILE "@CONFIG_FILE@"
|
#define CONFIG_FILE "@CONFIG_FILE@"
|
||||||
|
#define LOCALE_DIR "@LOCALE_DIR@"
|
||||||
#define MAX_USER_TEXT_DEFAULT @MAX_USER_TEXT_DEFAULT@
|
#define MAX_USER_TEXT_DEFAULT @MAX_USER_TEXT_DEFAULT@
|
||||||
#define DEFAULT_TEXT_BUFFER_SIZE @DEFAULT_TEXT_BUFFER_SIZE@
|
#define DEFAULT_TEXT_BUFFER_SIZE @DEFAULT_TEXT_BUFFER_SIZE@
|
||||||
#define MAX_NET_INTERFACES @MAX_NET_INTERFACES@
|
#define MAX_NET_INTERFACES @MAX_NET_INTERFACES@
|
||||||
|
81
src/conky.cc
81
src/conky.cc
@@ -80,6 +80,8 @@
|
|||||||
#ifdef BUILD_CURL
|
#ifdef BUILD_CURL
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <libintl.h>
|
||||||
|
#define _(string) gettext(string)
|
||||||
|
|
||||||
/* local headers */
|
/* local headers */
|
||||||
#include "core.h"
|
#include "core.h"
|
||||||
@@ -190,110 +192,110 @@ static void reload_config(void);
|
|||||||
|
|
||||||
static void print_version(void)
|
static void print_version(void)
|
||||||
{
|
{
|
||||||
std::cout << PACKAGE_NAME" "VERSION" compiled "BUILD_DATE" for "BUILD_ARCH"\n"
|
std::cout << _(PACKAGE_NAME" "VERSION" compiled "BUILD_DATE" for "BUILD_ARCH"\n"
|
||||||
"\nCompiled in features:\n\n"
|
"\nCompiled in features:\n\n"
|
||||||
"System config file: "SYSTEM_CONFIG_FILE"\n"
|
"System config file: "SYSTEM_CONFIG_FILE"\n"
|
||||||
"Package library path: "PACKAGE_LIBDIR"\n\n"
|
"Package library path: "PACKAGE_LIBDIR"\n\n")
|
||||||
#ifdef BUILD_X11
|
#ifdef BUILD_X11
|
||||||
" X11:\n"
|
<< " X11:\n"
|
||||||
# ifdef BUILD_XDAMAGE
|
# ifdef BUILD_XDAMAGE
|
||||||
" * Xdamage extension\n"
|
<< _(" * Xdamage extension\n")
|
||||||
# endif /* BUILD_XDAMAGE */
|
# endif /* BUILD_XDAMAGE */
|
||||||
# ifdef BUILD_XDBE
|
# ifdef BUILD_XDBE
|
||||||
" * XDBE (double buffer extension)\n"
|
<< _(" * XDBE (double buffer extension)\n")
|
||||||
# endif /* BUILD_XDBE */
|
# endif /* BUILD_XDBE */
|
||||||
# ifdef BUILD_XFT
|
# ifdef BUILD_XFT
|
||||||
" * Xft\n"
|
<< " * Xft\n"
|
||||||
# endif /* BUILD_XFT */
|
# endif /* BUILD_XFT */
|
||||||
# ifdef BUILD_ARGB
|
# ifdef BUILD_ARGB
|
||||||
" * ARGB visual\n"
|
<< _(" * ARGB visual\n")
|
||||||
# endif /* BUILD_ARGB */
|
# endif /* BUILD_ARGB */
|
||||||
#endif /* BUILD_X11 */
|
#endif /* BUILD_X11 */
|
||||||
"\n Music detection:\n"
|
<< _("\n Music detection:\n")
|
||||||
#ifdef BUILD_AUDACIOUS
|
#ifdef BUILD_AUDACIOUS
|
||||||
" * Audacious\n"
|
<< " * Audacious\n"
|
||||||
#endif /* BUILD_AUDACIOUS */
|
#endif /* BUILD_AUDACIOUS */
|
||||||
#ifdef BUILD_BMPX
|
#ifdef BUILD_BMPX
|
||||||
" * BMPx\n"
|
<< " * BMPx\n"
|
||||||
#endif /* BUILD_BMPX */
|
#endif /* BUILD_BMPX */
|
||||||
#ifdef BUILD_MPD
|
#ifdef BUILD_MPD
|
||||||
" * MPD\n"
|
<< " * MPD\n"
|
||||||
#endif /* BUILD_MPD */
|
#endif /* BUILD_MPD */
|
||||||
#ifdef BUILD_MOC
|
#ifdef BUILD_MOC
|
||||||
" * MOC\n"
|
<< " * MOC\n"
|
||||||
#endif /* BUILD_MOC */
|
#endif /* BUILD_MOC */
|
||||||
#ifdef BUILD_XMMS2
|
#ifdef BUILD_XMMS2
|
||||||
" * XMMS2\n"
|
<< " * XMMS2\n"
|
||||||
#endif /* BUILD_XMMS2 */
|
#endif /* BUILD_XMMS2 */
|
||||||
"\n General:\n"
|
<< _("\n General:\n")
|
||||||
#ifdef HAVE_OPENMP
|
#ifdef HAVE_OPENMP
|
||||||
" * OpenMP\n"
|
<< " * OpenMP\n"
|
||||||
#endif /* HAVE_OPENMP */
|
#endif /* HAVE_OPENMP */
|
||||||
#ifdef BUILD_MATH
|
#ifdef BUILD_MATH
|
||||||
" * math\n"
|
<< _(" * math\n")
|
||||||
#endif /* BUILD_MATH */
|
#endif /* BUILD_MATH */
|
||||||
#ifdef BUILD_HDDTEMP
|
#ifdef BUILD_HDDTEMP
|
||||||
" * hddtemp\n"
|
<< " * hddtemp\n"
|
||||||
#endif /* BUILD_HDDTEMP */
|
#endif /* BUILD_HDDTEMP */
|
||||||
#ifdef BUILD_PORT_MONITORS
|
#ifdef BUILD_PORT_MONITORS
|
||||||
" * portmon\n"
|
<< " * portmon\n"
|
||||||
#endif /* BUILD_PORT_MONITORS */
|
#endif /* BUILD_PORT_MONITORS */
|
||||||
#ifdef BUILD_HTTP
|
#ifdef BUILD_HTTP
|
||||||
" * HTTP\n"
|
<< " * HTTP\n"
|
||||||
#endif
|
#endif
|
||||||
#ifdef BUILD_IRC
|
#ifdef BUILD_IRC
|
||||||
" * IRC\n"
|
<< " * IRC\n"
|
||||||
#endif
|
#endif
|
||||||
#ifdef BUILD_CURL
|
#ifdef BUILD_CURL
|
||||||
" * Curl\n"
|
<< " * Curl\n"
|
||||||
#endif /* BUILD_CURL */
|
#endif /* BUILD_CURL */
|
||||||
#ifdef BUILD_RSS
|
#ifdef BUILD_RSS
|
||||||
" * RSS\n"
|
<< " * RSS\n"
|
||||||
#endif /* BUILD_RSS */
|
#endif /* BUILD_RSS */
|
||||||
#ifdef BUILD_WEATHER_METAR
|
#ifdef BUILD_WEATHER_METAR
|
||||||
" * Weather (METAR)\n"
|
<< _(" * Weather (METAR)\n")
|
||||||
#ifdef BUILD_WEATHER_XOAP
|
#ifdef BUILD_WEATHER_XOAP
|
||||||
" * Weather (XOAP)\n"
|
<< _(" * Weather (XOAP)\n")
|
||||||
#endif /* BUILD_WEATHER_XOAP */
|
#endif /* BUILD_WEATHER_XOAP */
|
||||||
#endif /* BUILD_WEATHER_METAR */
|
#endif /* BUILD_WEATHER_METAR */
|
||||||
#ifdef BUILD_WLAN
|
#ifdef BUILD_WLAN
|
||||||
" * wireless\n"
|
<< _(" * wireless\n")
|
||||||
#endif /* BUILD_WLAN */
|
#endif /* BUILD_WLAN */
|
||||||
#ifdef BUILD_IBM
|
#ifdef BUILD_IBM
|
||||||
" * support for IBM/Lenovo notebooks\n"
|
<< _(" * support for IBM/Lenovo notebooks\n")
|
||||||
#endif /* BUILD_IBM */
|
#endif /* BUILD_IBM */
|
||||||
#ifdef BUILD_NVIDIA
|
#ifdef BUILD_NVIDIA
|
||||||
" * nvidia\n"
|
<< " * nvidia\n"
|
||||||
#endif /* BUILD_NVIDIA */
|
#endif /* BUILD_NVIDIA */
|
||||||
#ifdef BUILD_EVE
|
#ifdef BUILD_EVE
|
||||||
" * eve-online\n"
|
<< _(" * eve-online\n")
|
||||||
#endif /* BUILD_EVE */
|
#endif /* BUILD_EVE */
|
||||||
#ifdef BUILD_BUILTIN_CONFIG
|
#ifdef BUILD_BUILTIN_CONFIG
|
||||||
" * builtin default configuration\n"
|
<< _(" * builtin default configuration\n")
|
||||||
#endif /* BUILD_BUILTIN_CONFIG */
|
#endif /* BUILD_BUILTIN_CONFIG */
|
||||||
#ifdef BUILD_IMLIB2
|
#ifdef BUILD_IMLIB2
|
||||||
" * Imlib2\n"
|
<< " * Imlib2\n"
|
||||||
#endif /* BUILD_IMLIB2 */
|
#endif /* BUILD_IMLIB2 */
|
||||||
#ifdef BUILD_MIXER_ALSA
|
#ifdef BUILD_MIXER_ALSA
|
||||||
" * ALSA mixer support\n"
|
<< _(" * ALSA mixer support\n")
|
||||||
#endif /* BUILD_MIXER_ALSA */
|
#endif /* BUILD_MIXER_ALSA */
|
||||||
#ifdef BUILD_APCUPSD
|
#ifdef BUILD_APCUPSD
|
||||||
" * apcupsd\n"
|
<< " * apcupsd\n"
|
||||||
#endif /* BUILD_APCUPSD */
|
#endif /* BUILD_APCUPSD */
|
||||||
#ifdef BUILD_IOSTATS
|
#ifdef BUILD_IOSTATS
|
||||||
" * iostats\n"
|
<< " * iostats\n"
|
||||||
#endif /* BUILD_IOSTATS */
|
#endif /* BUILD_IOSTATS */
|
||||||
#ifdef BUILD_NCURSES
|
#ifdef BUILD_NCURSES
|
||||||
" * ncurses\n"
|
<< " * ncurses\n"
|
||||||
#endif /* BUILD_NCURSES */
|
#endif /* BUILD_NCURSES */
|
||||||
#ifdef BUILD_LUA
|
#ifdef BUILD_LUA
|
||||||
" * Lua\n"
|
<< " * Lua\n"
|
||||||
"\n Lua bindings:\n"
|
<< _("\n Lua bindings:\n")
|
||||||
#ifdef BUILD_LUA_CAIRO
|
#ifdef BUILD_LUA_CAIRO
|
||||||
" * Cairo\n"
|
<< " * Cairo\n"
|
||||||
#endif /* BUILD_LUA_CAIRO */
|
#endif /* BUILD_LUA_CAIRO */
|
||||||
#ifdef BUILD_LUA_IMLIB2
|
#ifdef BUILD_LUA_IMLIB2
|
||||||
" * Imlib2\n"
|
<< " * Imlib2\n"
|
||||||
#endif /* BUILD_LUA_IMLIB2 */
|
#endif /* BUILD_LUA_IMLIB2 */
|
||||||
#endif /* BUILD_LUA */
|
#endif /* BUILD_LUA */
|
||||||
;
|
;
|
||||||
@@ -4392,6 +4394,9 @@ bool isutf8(const char* envvar) {
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
setlocale(LC_ALL, "");
|
||||||
|
bindtextdomain(PACKAGE_NAME, LOCALE_DIR);
|
||||||
|
textdomain(PACKAGE_NAME);
|
||||||
argc_copy = argc;
|
argc_copy = argc;
|
||||||
argv_copy = argv;
|
argv_copy = argv;
|
||||||
g_signal_pending = 0;
|
g_signal_pending = 0;
|
||||||
|
Reference in New Issue
Block a user