1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 12:27:52 +00:00

Make I18N optional

This commit is contained in:
Nikolas Garofil 2010-11-13 19:45:04 +01:00
parent a1f4984a4e
commit 9d7a914515
5 changed files with 53 additions and 7 deletions

View File

@ -48,7 +48,10 @@ mark_as_advanced(RELEASE)
option(MAINTAINER_MODE "Enable maintainer mode (builds docs)" false)
option(BUILD_I18N "Enable if you want internationalization support" true)
if(BUILD_I18N)
set(LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale" CACHE STRING "Directory containing the locales")
endif(BUILD_I18N)
# Some standard options
set(SYSTEM_CONFIG_FILE "/etc/conky/conky.conf" CACHE STRING "Default system-wide Conky configuration file")

View File

@ -21,6 +21,8 @@
#define MAX_NET_INTERFACES @MAX_NET_INTERFACES@
#define HTTPPORT @HTTPPORT@
#cmakedefine BUILD_I18N 1
#cmakedefine HAVE_SYS_STATFS_H 1
#cmakedefine HAVE_SYS_PARAM_H 1
#cmakedefine HAVE_SYS_INOTIFY_H 1

View File

@ -80,8 +80,6 @@
#ifdef BUILD_CURL
#include <curl/curl.h>
#endif
#define _(string) gettext(string)
#define _nop(string) string
/* local headers */
#include "core.h"
@ -298,6 +296,9 @@ static void print_version(void)
<< " * Imlib2\n"
#endif /* BUILD_LUA_IMLIB2 */
#endif /* BUILD_LUA */
#ifdef BUILD_I18N
<< " * Internationalization support\n"
#endif
#ifdef DEBUG
<< " * Debugging extensions\n"
#endif
@ -4399,9 +4400,11 @@ bool isutf8(const char* envvar) {
int main(int argc, char **argv)
{
#ifdef BUILD_I18N
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE_NAME, LOCALE_DIR);
textdomain(PACKAGE_NAME);
#endif
argc_copy = argc;
argv_copy = argv;
g_signal_pending = 0;

38
src/i18n.h Normal file
View File

@ -0,0 +1,38 @@
/* -*- mode: c++; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
* vim: ts=4 sw=4 noet ai cindent syntax=cpp
*
* Conky, a system monitor, based on torsmo
*
* Please see COPYING for details
*
* Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al.
* (see AUTHORS)
* All rights reserved.
*
* 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 3 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. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef I18N_H_
#define I18N_H_
#define _nop(string) string
#ifdef BUILD_I18N
#include <libintl.h>
#define _(string) gettext(string)
#else
#define _(string) string
#endif
#endif /*I18N_H_*/

View File

@ -31,7 +31,7 @@
#define _LOGGING_H
#include <cstdio>
#include <libintl.h>
#include "i18n.h"
#include "mail.h"
void clean_up(void *memtofree1, void* memtofree2);
@ -39,12 +39,12 @@ void clean_up_without_threads(void *memtofree1, void* memtofree2);
template<typename... Args>
void gettextize_format(const char *format, Args&&... args)
{ fprintf(stderr, gettext(format), args...); }
{ fprintf(stderr, _(format), args...); }
// explicit specialization for no arguments to avoid the
// "format not a string literal and no format arguments" warning
inline void gettextize_format(const char *format)
{ fputs(gettext(format), stderr); }
{ fputs(_(format), stderr); }
#define NORM_ERR(...) do { \
fprintf(stderr, PACKAGE_NAME": "); \