diff options
author | Jon Lund Steffensen <jonlst@gmail.com> | 2010-02-02 00:51:50 +0100 |
---|---|---|
committer | Jon Lund Steffensen <jonlst@gmail.com> | 2010-02-02 00:51:50 +0100 |
commit | 59db9546e5f67ab39c89d3e29d2a88ee7beb297b (patch) | |
tree | 44a19a6918aef7ceea3325af7033c9871b95e907 | |
parent | Change bug report address to launchpad bugs url. (diff) | |
download | redshift-ng-59db9546e5f67ab39c89d3e29d2a88ee7beb297b.tar.gz redshift-ng-59db9546e5f67ab39c89d3e29d2a88ee7beb297b.tar.bz2 redshift-ng-59db9546e5f67ab39c89d3e29d2a88ee7beb297b.tar.xz |
Add gettext support in redshift.
-rw-r--r-- | po/redshift/redshift.pot | 200 | ||||
-rw-r--r-- | src/colorramp.c | 2 | ||||
-rw-r--r-- | src/colorramp.h | 2 | ||||
-rw-r--r-- | src/randr.c | 39 | ||||
-rw-r--r-- | src/randr.h | 2 | ||||
-rw-r--r-- | src/redshift.c | 179 | ||||
-rw-r--r-- | src/solar.c | 2 | ||||
-rw-r--r-- | src/solar.h | 2 | ||||
-rw-r--r-- | src/vidmode.c | 25 | ||||
-rw-r--r-- | src/vidmode.h | 2 |
10 files changed, 358 insertions, 97 deletions
diff --git a/po/redshift/redshift.pot b/po/redshift/redshift.pot new file mode 100644 index 0000000..b3d8ac5 --- /dev/null +++ b/po/redshift/redshift.pot @@ -0,0 +1,200 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-02-02 00:50+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/redshift.c:172 +#, c-format +msgid "Period: Night\n" +msgstr "" + +#: src/redshift.c:179 +#, c-format +msgid "Period: Transition (%.2f%% day)\n" +msgstr "" + +#: src/redshift.c:183 +#, c-format +msgid "Period: Daytime\n" +msgstr "" + +#. TRANSLATORS: --help output 1 +#. LAT is latitude, LON is longitude, +#. DAY is temperature at daytime, +#. NIGHT is temperature at night +#. no-wrap +#: src/redshift.c:198 +#, c-format +msgid "Usage: %s -l LAT:LON -t DAY:NIGHT [OPTIONS...]\n" +msgstr "" + +#. TRANSLATORS: --help output 2 +#. no-wrap +#: src/redshift.c:204 +msgid "Set color temperature of display according to time of day.\n" +msgstr "" + +#. TRANSLATORS: --help output 3 +#. no-wrap +#: src/redshift.c:210 +msgid "" +" -h\t\tDisplay this help message\n" +" -v\t\tVerbose output\n" +msgstr "" + +#. TRANSLATORS: --help output 4 +#. no-wrap +#: src/redshift.c:216 +msgid "" +" -g R:G:B\tAdditional gamma correction to apply\n" +" -l LAT:LON\tYour current location\n" +" -m METHOD\tMethod to use to set color temperature (randr or vidmode)\n" +" -o\t\tOne shot mode (do not continously adjust color temperature)\n" +" -r\t\tDisable initial temperature transition\n" +" -s SCREEN\tX screen to apply adjustments to\n" +" -t DAY:NIGHT\tColor temperature to set at daytime/night\n" +msgstr "" + +#: src/redshift.c:278 +msgid "Malformed gamma argument.\n" +msgstr "" + +#: src/redshift.c:280 src/redshift.c:299 src/redshift.c:350 src/redshift.c:363 +#: src/redshift.c:373 +msgid "Try `--help' for more information.\n" +msgstr "" + +#: src/redshift.c:297 +msgid "Malformed location argument.\n" +msgstr "" + +#: src/redshift.c:313 +msgid "RANDR method was not enabled at compile time.\n" +msgstr "" + +#: src/redshift.c:323 +msgid "VidMode method was not enabled at compile time.\n" +msgstr "" + +#. TRANSLATORS: This refers to the method +#. used to adjust colors e.g VidMode +#: src/redshift.c:331 +#, c-format +msgid "Unknown method `%s'.\n" +msgstr "" + +#: src/redshift.c:348 +msgid "Malformed temperature argument.\n" +msgstr "" + +#: src/redshift.c:362 +#, c-format +msgid "Unknown parameter `%c'.\n" +msgstr "" + +#: src/redshift.c:372 +msgid "Latitude and longitude must be set.\n" +msgstr "" + +#. TRANSLATORS: Append degree symbols if possible. +#: src/redshift.c:380 +#, c-format +msgid "Location: %f, %f\n" +msgstr "" + +#: src/redshift.c:387 +#, c-format +msgid "Latitude must be between %.1f and %.1f.\n" +msgstr "" + +#: src/redshift.c:396 +#, c-format +msgid "Longitude must be between %.1f and %.1f.\n" +msgstr "" + +#: src/redshift.c:404 src/redshift.c:412 +#, c-format +msgid "Temperature must be between %uK and %uK.\n" +msgstr "" + +#: src/redshift.c:422 +#, c-format +msgid "Gamma value must be between %.1f and %.1f.\n" +msgstr "" + +#: src/redshift.c:428 +#, c-format +msgid "Gamma: %.3f, %.3f, %.3f\n" +msgstr "" + +#: src/redshift.c:440 +msgid "Initialization of RANDR failed.\n" +msgstr "" + +#: src/redshift.c:442 +msgid "Trying other method...\n" +msgstr "" + +#: src/redshift.c:457 +msgid "Initialization of VidMode failed.\n" +msgstr "" + +#. TRANSLATORS: Append degree symbol if possible. +#: src/redshift.c:480 +#, c-format +msgid "Solar elevation: %f\n" +msgstr "" + +#: src/redshift.c:487 src/redshift.c:649 +#, c-format +msgid "Color temperature: %uK\n" +msgstr "" + +#: src/redshift.c:493 src/redshift.c:658 +msgid "Temperature adjustment failed.\n" +msgstr "" + +#: src/vidmode.c:42 src/vidmode.c:54 src/vidmode.c:64 src/vidmode.c:94 +#: src/vidmode.c:125 src/vidmode.c:154 +#, c-format +msgid "X request failed: %s\n" +msgstr "" + +#: src/vidmode.c:71 src/randr.c:157 +#, c-format +msgid "Gamma ramp size too small: %i\n" +msgstr "" + +#: src/randr.c:57 src/randr.c:104 src/randr.c:144 src/randr.c:172 +#: src/randr.c:231 src/randr.c:283 +#, c-format +msgid "`%s' returned error %d\n" +msgstr "" + +#: src/randr.c:65 +#, c-format +msgid "Unsupported RANDR version (%u.%u)\n" +msgstr "" + +#: src/randr.c:88 +#, c-format +msgid "Screen %i could not be found.\n" +msgstr "" + +#: src/randr.c:233 +#, c-format +msgid "Unable to restore CRTC %i\n" +msgstr "" diff --git a/src/colorramp.c b/src/colorramp.c index 2743036..9bc3b94 100644 --- a/src/colorramp.c +++ b/src/colorramp.c @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with Redshift. If not, see <http://www.gnu.org/licenses/>. - Copyright (c) 2009 Jon Lund Steffensen <jonlst@gmail.com> + Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com> */ #include <stdio.h> diff --git a/src/colorramp.h b/src/colorramp.h index e7f5554..88aa984 100644 --- a/src/colorramp.h +++ b/src/colorramp.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with Redshift. If not, see <http://www.gnu.org/licenses/>. - Copyright (c) 2009 Jon Lund Steffensen <jonlst@gmail.com> + Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com> */ #ifndef _REDSHIFT_COLORRAMP_H diff --git a/src/randr.c b/src/randr.c index b67484c..7c05b26 100644 --- a/src/randr.c +++ b/src/randr.c @@ -14,13 +14,16 @@ You should have received a copy of the GNU General Public License along with Redshift. If not, see <http://www.gnu.org/licenses/>. - Copyright (c) 2009 Jon Lund Steffensen <jonlst@gmail.com> + Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com> */ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <libintl.h> +#define _(s) gettext(s) + #include <xcb/xcb.h> #include <xcb/randr.h> @@ -51,15 +54,15 @@ randr_init(randr_state_t *state, int screen_num) xcb_randr_query_version_reply(state->conn, ver_cookie, &error); if (error) { - fprintf(stderr, "RANDR Query Version, error: %d\n", - error->error_code); + fprintf(stderr, _("`%s' returned error %d\n"), + "RANDR Query Version", error->error_code); xcb_disconnect(state->conn); return -1; } if (ver_reply->major_version < RANDR_VERSION_MAJOR || ver_reply->minor_version < RANDR_VERSION_MINOR) { - fprintf(stderr, "Unsupported RANDR version (%u.%u)\n", + fprintf(stderr, _("Unsupported RANDR version (%u.%u)\n"), ver_reply->major_version, ver_reply->minor_version); free(ver_reply); xcb_disconnect(state->conn); @@ -82,7 +85,7 @@ randr_init(randr_state_t *state, int screen_num) } if (state->screen == NULL) { - fprintf(stderr, "Screen %i could not be found.\n", + fprintf(stderr, _("Screen %i could not be found.\n"), screen_num); xcb_disconnect(state->conn); return -1; @@ -98,8 +101,9 @@ randr_init(randr_state_t *state, int screen_num) &error); if (error) { - fprintf(stderr, "RANDR Get Screen Resources Current," - " error: %d\n", error->error_code); + fprintf(stderr, _("`%s' returned error %d\n"), + "RANDR Get Screen Resources Current", + error->error_code); xcb_disconnect(state->conn); return -1; } @@ -137,8 +141,9 @@ randr_init(randr_state_t *state, int screen_num) &error); if (error) { - fprintf(stderr, "RANDR Get CRTC Gamma Size," - " error: %d\n", error->error_code); + fprintf(stderr, _("`%s' returned error %d\n"), + "RANDR Get CRTC Gamma Size", + error->error_code); xcb_disconnect(state->conn); return -1; } @@ -149,7 +154,7 @@ randr_init(randr_state_t *state, int screen_num) free(gamma_size_reply); if (ramp_size == 0) { - fprintf(stderr, "Gamma ramp size too small: %i\n", + fprintf(stderr, _("Gamma ramp size too small: %i\n"), ramp_size); xcb_disconnect(state->conn); return -1; @@ -164,8 +169,8 @@ randr_init(randr_state_t *state, int screen_num) &error); if (error) { - fprintf(stderr, "RANDR Get CRTC Gamma, error: %d\n", - error->error_code); + fprintf(stderr, _("`%s' returned error %d\n"), + "RANDR Get CRTC Gamma", error->error_code); xcb_disconnect(state->conn); return -1; } @@ -223,9 +228,9 @@ randr_restore(randr_state_t *state) error = xcb_request_check(state->conn, gamma_set_cookie); if (error) { - fprintf(stderr, "RANDR Set CRTC Gamma, error: %d\n" - "Unable to restore CRTC %i\n", - error->error_code, i); + fprintf(stderr, _("`%s' returned error %d\n"), + "RANDR Set CRTC Gamma", error->error_code); + fprintf(stderr, _("Unable to restore CRTC %i\n"), i); } } } @@ -275,8 +280,8 @@ randr_set_temperature(randr_state_t *state, int temp, float gamma[3]) error = xcb_request_check(state->conn, gamma_set_cookie); if (error) { - fprintf(stderr, "RANDR Set CRTC Gamma, error: %d\n", - error->error_code); + fprintf(stderr, _("`%s' returned error %d\n"), + "RANDR Set CRTC Gamma", error->error_code); free(gamma_ramps); return -1; } diff --git a/src/randr.h b/src/randr.h index 3a50099..94d653f 100644 --- a/src/randr.h +++ b/src/randr.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with Redshift. If not, see <http://www.gnu.org/licenses/>. - Copyright (c) 2009 Jon Lund Steffensen <jonlst@gmail.com> + Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com> */ #ifndef _REDSHIFT_RANDR_H diff --git a/src/redshift.c b/src/redshift.c index 8f39260..c022224 100644 --- a/src/redshift.c +++ b/src/redshift.c @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with Redshift. If not, see <http://www.gnu.org/licenses/>. - Copyright (c) 2009 Jon Lund Steffensen <jonlst@gmail.com> + Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com> */ #ifdef HAVE_CONFIG_H @@ -30,6 +30,9 @@ #include <locale.h> #include <sys/signal.h> +#include <libintl.h> +#define _(s) gettext(s) + #include "solar.h" @@ -84,30 +87,6 @@ typedef union { #define TRANSITION_HIGH 3.0 -/* Help and usage messages */ -#define USAGE \ - "Usage: %s -l LAT:LON -t DAY:NIGHT [OPTIONS...]\n" -#define HELP \ - USAGE \ - " " PACKAGE_STRING "\n" \ - " Set color temperature of display according to time of day.\n" \ - " -g R:G:B\tAdditional gamma correction to apply\n" \ - " -h\t\tDisplay this help message\n" \ - " -l LAT:LON\tYour current location\n" \ - " -m METHOD\tMethod to use to set color temperature" \ - " (randr or vidmode)\n" \ - " -o\t\tOne shot mode (do not continously adjust" \ - " color temperature)\n" \ - " -r\t\tDisable initial temperature transition\n" \ - " -s SCREEN\tX screen to apply adjustments to\n" \ - " -t DAY:NIGHT\tColor temperature to set at daytime/night\n" \ - " -v\t\tVerbose output\n" \ - "Please report bugs to <" PACKAGE_BUGREPORT ">\n" - -/* DEGREE SIGN is Unicode U+00b0 */ -#define DEG_CHAR 0xb0 - - static volatile sig_atomic_t exiting = 0; static volatile sig_atomic_t disable = 0; @@ -190,35 +169,81 @@ calculate_temp(double elevation, int temp_day, int temp_night, int temp = 0; if (elevation < TRANSITION_LOW) { temp = temp_night; - if (verbose) printf("Period: Night\n"); + if (verbose) printf(_("Period: Night\n")); } else if (elevation < TRANSITION_HIGH) { /* Transition period: interpolate */ float a = (TRANSITION_LOW - elevation) / (TRANSITION_LOW - TRANSITION_HIGH); temp = (1.0-a)*temp_night + a*temp_day; if (verbose) { - printf("Period: Transition (%.2f%% day)\n", a*100); + printf(_("Period: Transition (%.2f%% day)\n"), a*100); } } else { temp = temp_day; - if (verbose) printf("Period: Daytime\n"); + if (verbose) printf(_("Period: Daytime\n")); } return temp; } +static void +print_help(const char *program_name) +{ + /* TRANSLATORS: --help output 1 + LAT is latitude, LON is longitude, + DAY is temperature at daytime, + NIGHT is temperature at night + no-wrap */ + printf(_("Usage: %s -l LAT:LON -t DAY:NIGHT [OPTIONS...]\n"), + program_name); + fputs("\n", stdout); + + /* TRANSLATORS: --help output 2 + no-wrap */ + fputs(_("Set color temperature of display" + " according to time of day.\n"), stdout); + fputs("\n", stdout); + + /* TRANSLATORS: --help output 3 + no-wrap */ + fputs(_(" -h\t\tDisplay this help message\n" + " -v\t\tVerbose output\n"), stdout); + fputs("\n", stdout); + + /* TRANSLATORS: --help output 4 + no-wrap */ + fputs(_(" -g R:G:B\tAdditional gamma correction to apply\n" + " -l LAT:LON\tYour current location\n" + " -m METHOD\tMethod to use to set color temperature" + " (randr or vidmode)\n" + " -o\t\tOne shot mode (do not continously adjust" + " color temperature)\n" + " -r\t\tDisable initial temperature transition\n" + " -s SCREEN\tX screen to apply adjustments to\n" + " -t DAY:NIGHT\tColor temperature to set at daytime/night\n"), + stdout); + fputs("\n", stdout); + + /* TRANSLATORS: --help output 5 */ + printf("Please report bugs to <%s>\n", PACKAGE_BUGREPORT); +} + + int main(int argc, char *argv[]) { int r; - /* Init locale for degree symbol. */ - char *loc = setlocale(LC_CTYPE, ""); - if (loc == NULL) { - fprintf(stderr, "Unable to set locale.\n"); - exit(EXIT_FAILURE); - } + /* Init locale */ + setlocale(LC_CTYPE, ""); + setlocale(LC_MESSAGES, ""); + +#ifdef ENABLE_NLS + /* Internationalisation */ + bindtextdomain("redshift", "/usr/share/locale"); + textdomain("redshift"); +#endif /* Initialize to defaults */ float lat = NAN; @@ -250,7 +275,10 @@ main(int argc, char *argv[]) char *g_s = s; s = strchr(s, ':'); if (s == NULL) { - fprintf(stderr, USAGE, argv[0]); + fputs(_("Malformed gamma argument.\n"), + stderr); + fputs(_("Try `--help' for more" + " information.\n"), stderr); exit(EXIT_FAILURE); } @@ -260,13 +288,16 @@ main(int argc, char *argv[]) } break; case 'h': - printf(HELP, argv[0]); + print_help(argv[0]); exit(EXIT_SUCCESS); break; case 'l': s = strchr(optarg, ':'); if (s == NULL) { - fprintf(stderr, USAGE, argv[0]); + fputs(_("Malformed location argument.\n"), + stderr); + fputs(_("Try `--help' for more" + " information.\n"), stderr); exit(EXIT_FAILURE); } *(s++) = '\0'; @@ -279,8 +310,9 @@ main(int argc, char *argv[]) #ifdef ENABLE_RANDR use_randr = 1; #else - fprintf(stderr, "RANDR method was not" - " enabled at compile time.\n"); + fputs(_("RANDR method was not" + " enabled at compile time.\n"), + stderr); exit(EXIT_FAILURE); #endif } else if (strcmp(optarg, "vidmode") == 0 || @@ -288,12 +320,15 @@ main(int argc, char *argv[]) #ifdef ENABLE_VIDMODE use_randr = 0; #else - fprintf(stderr, "VidMode method was not" - " enabled at compile time.\n"); + fputs(_("VidMode method was not" + " enabled at compile time.\n"), + stderr); exit(EXIT_FAILURE); #endif } else { - fprintf(stderr, "Unknown method `%s'.\n", + /* TRANSLATORS: This refers to the method + used to adjust colors e.g VidMode */ + fprintf(stderr, _("Unknown method `%s'.\n"), optarg); exit(EXIT_FAILURE); } @@ -310,7 +345,10 @@ main(int argc, char *argv[]) case 't': s = strchr(optarg, ':'); if (s == NULL) { - fprintf(stderr, USAGE, argv[0]); + fputs(_("Malformed temperature argument.\n"), + stderr); + fputs(_("Try `--help' for more" + " information.\n"), stderr); exit(EXIT_FAILURE); } *(s++) = '\0'; @@ -321,7 +359,9 @@ main(int argc, char *argv[]) verbose = 1; break; default: - fprintf(stderr, USAGE, argv[0]); + fprintf(stderr, _("Unknown parameter `%c'.\n"), opt); + fputs(_("Try `--help' for more" + " information.\n"), stderr); exit(EXIT_FAILURE); break; } @@ -329,42 +369,47 @@ main(int argc, char *argv[]) /* Latitude and longitude must be set */ if (isnan(lat) || isnan(lon)) { - fprintf(stderr, USAGE, argv[0]); - fprintf(stderr, "Latitude and longitude must be set.\n"); + fputs(_("Latitude and longitude must be set.\n"), stderr); + fputs(_("Try `--help' for more" + " information.\n"), stderr); exit(EXIT_FAILURE); } if (verbose) { - printf("Location: %f%lc, %f%lc\n", - lat, DEG_CHAR, lon, DEG_CHAR); + /* TRANSLATORS: Append degree symbols if possible. */ + printf(_("Location: %f, %f\n"), lat, lon); } /* Latitude */ if (lat < MIN_LAT || lat > MAX_LAT) { + /* TRANSLATORS: Append degree symbols if possible. */ fprintf(stderr, - "Latitude must be between %.1f%lc and %.1f%lc.\n", - MIN_LAT, DEG_CHAR, MAX_LAT, DEG_CHAR); + _("Latitude must be between %.1f and %.1f.\n"), + MIN_LAT, MAX_LAT); exit(EXIT_FAILURE); } /* Longitude */ if (lon < MIN_LON || lon > MAX_LON) { + /* TRANSLATORS: Append degree symbols if possible. */ fprintf(stderr, - "Longitude must be between %.1f%lc and %.1f%lc.\n", - MIN_LON, DEG_CHAR, MAX_LON, DEG_CHAR); + _("Longitude must be between %.1f and %.1f.\n"), + MIN_LON, MAX_LON); exit(EXIT_FAILURE); } /* Color temperature at daytime */ if (temp_day < MIN_TEMP || temp_day >= MAX_TEMP) { - fprintf(stderr, "Temperature must be between %uK and %uK.\n", + fprintf(stderr, + _("Temperature must be between %uK and %uK.\n"), MIN_TEMP, MAX_TEMP); exit(EXIT_FAILURE); } /* Color temperature at night */ if (temp_night < MIN_TEMP || temp_night >= MAX_TEMP) { - fprintf(stderr, "Temperature must be between %uK and %uK.\n", + fprintf(stderr, + _("Temperature must be between %uK and %uK.\n"), MIN_TEMP, MAX_TEMP); exit(EXIT_FAILURE); } @@ -373,13 +418,14 @@ main(int argc, char *argv[]) if (gamma[0] < MIN_GAMMA || gamma[0] > MAX_GAMMA || gamma[1] < MIN_GAMMA || gamma[1] > MAX_GAMMA || gamma[2] < MIN_GAMMA || gamma[2] > MAX_GAMMA) { - fprintf(stderr, "Gamma value must be between %.1f and %.1f.\n", + fprintf(stderr, + _("Gamma value must be between %.1f and %.1f.\n"), MIN_GAMMA, MAX_GAMMA); exit(EXIT_FAILURE); } if (verbose) { - printf("Gamma: %.3f, %.3f, %.3f\n", + printf(_("Gamma: %.3f, %.3f, %.3f\n"), gamma[0], gamma[1], gamma[2]); } @@ -391,9 +437,9 @@ main(int argc, char *argv[]) /* Initialize RANDR state */ r = randr_init(&state.randr, screen_num); if (r < 0) { - fprintf(stderr, "Initialization of RANDR failed.\n"); + fputs(_("Initialization of RANDR failed.\n"), stderr); if (use_randr < 0) { - fprintf(stderr, "Trying other method...\n"); + fputs(_("Trying other method...\n"), stderr); } else { exit(EXIT_FAILURE); } @@ -408,7 +454,8 @@ main(int argc, char *argv[]) /* Initialize VidMode state */ r = vidmode_init(&state.vidmode, screen_num); if (r < 0) { - fprintf(stderr, "Initialization of VidMode failed.\n"); + fputs(_("Initialization of VidMode failed.\n"), + stderr); exit(EXIT_FAILURE); } else { use_randr = 0; @@ -429,21 +476,21 @@ main(int argc, char *argv[]) double elevation = solar_elevation(now, lat, lon); if (verbose) { - printf("Solar elevation: %f%lc\n", elevation, - DEG_CHAR); + /* TRANSLATORS: Append degree symbol if possible. */ + printf(_("Solar elevation: %f\n"), elevation); } /* Use elevation of sun to set color temperature */ int temp = calculate_temp(elevation, temp_day, temp_night, verbose); - if (verbose) printf("Color temperature: %uK\n", temp); + if (verbose) printf(_("Color temperature: %uK\n"), temp); /* Adjust temperature */ r = gamma_state_set_temperature(&state, use_randr, temp, gamma); if (r < 0) { - fprintf(stderr, "Temperature adjustment failed.\n"); + fputs(_("Temperature adjustment failed.\n"), stderr); gamma_state_free(&state, use_randr); exit(EXIT_FAILURE); } @@ -599,7 +646,7 @@ main(int argc, char *argv[]) if (done && !short_trans) break; if (verbose) { - printf("Temperature: %iK\n", temp); + printf(_("Color temperature: %uK\n"), temp); } /* Adjust temperature */ @@ -608,8 +655,8 @@ main(int argc, char *argv[]) use_randr, temp, gamma); if (r < 0) { - fprintf(stderr, "Temperature" - " adjustment failed.\n"); + fputs(_("Temperature adjustment" + " failed.\n"), stderr); gamma_state_free(&state, use_randr); exit(EXIT_FAILURE); } diff --git a/src/solar.c b/src/solar.c index 5029872..9b63c40 100644 --- a/src/solar.c +++ b/src/solar.c @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with Redshift. If not, see <http://www.gnu.org/licenses/>. - Copyright (c) 2009 Jon Lund Steffensen <jonlst@gmail.com> + Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com> */ /* Ported from javascript code by U.S. Department of Commerce, diff --git a/src/solar.h b/src/solar.h index 304b8ec..a55c83a 100644 --- a/src/solar.h +++ b/src/solar.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with Redshift. If not, see <http://www.gnu.org/licenses/>. - Copyright (c) 2009 Jon Lund Steffensen <jonlst@gmail.com> + Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com> */ #ifndef _SOLAR_H diff --git a/src/vidmode.c b/src/vidmode.c index 9ce729f..4da1831 100644 --- a/src/vidmode.c +++ b/src/vidmode.c @@ -14,13 +14,16 @@ You should have received a copy of the GNU General Public License along with Redshift. If not, see <http://www.gnu.org/licenses/>. - Copyright (c) 2009 Jon Lund Steffensen <jonlst@gmail.com> + Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com> */ #include <stdlib.h> #include <stdio.h> #include <stdint.h> +#include <libintl.h> +#define _(s) gettext(s) + #include <X11/Xlib.h> #include <X11/extensions/xf86vmode.h> @@ -36,7 +39,8 @@ vidmode_init(vidmode_state_t *state, int screen_num) /* Open display */ state->display = XOpenDisplay(NULL); if (state->display == NULL) { - fprintf(stderr, "XOpenDisplay failed.\n"); + fprintf(stderr, _("X request failed: %s\n"), + "XOpenDisplay"); return -1; } @@ -47,7 +51,8 @@ vidmode_init(vidmode_state_t *state, int screen_num) int major, minor; r = XF86VidModeQueryVersion(state->display, &major, &minor); if (!r) { - fprintf(stderr, "XF86VidModeQueryVersion failed.\n"); + fprintf(stderr, _("X request failed: %s\n"), + "XF86VidModeQueryVersion"); XCloseDisplay(state->display); return -1; } @@ -56,13 +61,14 @@ vidmode_init(vidmode_state_t *state, int screen_num) r = XF86VidModeGetGammaRampSize(state->display, state->screen_num, &state->ramp_size); if (!r) { - fprintf(stderr, "XF86VidModeGetGammaRampSize failed.\n"); + fprintf(stderr, _("X request failed: %s\n"), + "XF86VidModeGetGammaRampSize"); XCloseDisplay(state->display); return -1; } if (state->ramp_size == 0) { - fprintf(stderr, "Gamma ramp size too small: %i\n", + fprintf(stderr, _("Gamma ramp size too small: %i\n"), state->ramp_size); XCloseDisplay(state->display); return -1; @@ -85,7 +91,8 @@ vidmode_init(vidmode_state_t *state, int screen_num) state->ramp_size, gamma_r, gamma_g, gamma_b); if (!r) { - fprintf(stderr, "XF86VidModeGetGammaRamp failed.\n"); + fprintf(stderr, _("X request failed: %s\n"), + "XF86VidModeGetGammaRamp"); XCloseDisplay(state->display); return -1; } @@ -115,7 +122,8 @@ vidmode_restore(vidmode_state_t *state) state->ramp_size, gamma_r, gamma_g, gamma_b); if (!r) { - fprintf(stderr, "XF86VidModeSetGammaRamp failed.\n"); + fprintf(stderr, _("X request failed: %s\n"), + "XF86VidModeSetGammaRamp"); } } @@ -143,7 +151,8 @@ vidmode_set_temperature(vidmode_state_t *state, int temp, float gamma[3]) state->ramp_size, gamma_r, gamma_g, gamma_b); if (!r) { - fprintf(stderr, "XF86VidModeSetGammaRamp failed.\n"); + fprintf(stderr, _("X request failed: %s\n"), + "XF86VidModeSetGammaRamp"); free(gamma_ramps); return -1; } diff --git a/src/vidmode.h b/src/vidmode.h index e4a3e1c..9503441 100644 --- a/src/vidmode.h +++ b/src/vidmode.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with Redshift. If not, see <http://www.gnu.org/licenses/>. - Copyright (c) 2009 Jon Lund Steffensen <jonlst@gmail.com> + Copyright (c) 2010 Jon Lund Steffensen <jonlst@gmail.com> */ #ifndef _REDSHIFT_VIDMODE_H |