From 976e480903381595893bcbf14b0a6664bd2580e6 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 29 Mar 2011 23:18:02 -0400 Subject: [PATCH] i18n - Added en-US.h, which will be a header file full of string defines. - Added logic to i18n.h to include en-US.h based on cmake command line argument (cmake ... -DPACKAGE_LANGUAGE=1). - Added one sample string. --- cmake.h.in | 9 ++++ src/Context.cpp | 2 +- src/en-US.h | 47 +++++++++++++++++++++ src/i18n.h | 108 +++--------------------------------------------- src/main.cpp | 5 ++- 5 files changed, 65 insertions(+), 106 deletions(-) create mode 100644 src/en-US.h diff --git a/cmake.h.in b/cmake.h.in index 0fc2aa9dc..5d340a5c1 100644 --- a/cmake.h.in +++ b/cmake.h.in @@ -9,6 +9,15 @@ #define PACKAGE_VERSION "${PACKAGE_VERSION}" #define PACKAGE_STRING "${PACKAGE_STRING}" +/* Localization */ +#define PACKAGE_LANGUAGE 1 +#define LANGUAGE_EN_US 1 + +/* +Override PACKAGE_LANGUAGE, then +#define LANGUAGE_XX_YY 2 +*/ + /* git information */ #cmakedefine HAVE_COMMIT diff --git a/src/Context.cpp b/src/Context.cpp index 6fa19d11a..d59455aad 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -135,9 +135,9 @@ void Context::initialize () initializeColorRules (); Directory location (config.get ("data.location")); - std::string locale = config.get ("locale"); // If there is a locale variant (en-US.), then strip it. + std::string locale = config.get ("locale"); std::string::size_type period = locale.find ('.'); if (period != std::string::npos) locale = locale.substr (0, period); diff --git a/src/en-US.h b/src/en-US.h new file mode 100644 index 000000000..9a28e8eba --- /dev/null +++ b/src/en-US.h @@ -0,0 +1,47 @@ +//////////////////////////////////////////////////////////////////////////////// +// taskwarrior - a command line task list manager. +// +// Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez. +// 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 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; if not, write to the +// +// Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, +// Boston, MA +// 02110-1301 +// USA +// +//////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////// +// +// Strings that should be localized: +// - All text output that the user sees or types +// +// Strings that should NOT be localized: +// - ./taskrc configuration variable names +// - certain literals associated with parsing +// +//////////////////////////////////////////////////////////////////////////////// + +#ifndef INCLUDED_EN_US +#define INCLUDED_EN_US + +// To localize, clone and rename this file, then change all the defines below. + +#define STRING_UNKNOWN_ERROR "Unknown error." + +#endif + diff --git a/src/i18n.h b/src/i18n.h index 542600cd7..19d708fbf 100644 --- a/src/i18n.h +++ b/src/i18n.h @@ -39,106 +39,14 @@ #ifndef INCLUDED_I18N #define INCLUDED_I18N -// 1xx task shell -#define SHELL_UNKNOWN_ERROR 100 -#define SHELL_READ_PASSWD 101 +#include "../cmake.h" -#define CONFIRM_YES_NO 102 +#if PACKAGE_LANGUAGE == LANGUAGE_EN_US +#include +#endif -#define SEQUENCE_BAD_SEQ 103 -#define SEQUENCE_BAD_RANGE 104 -#define SEQUENCE_INVERTED 105 -#define SEQUENCE_RANGE_MAX 106 -#define SEQUENCE_NOT_A_SEQUENCE 107 +// Other languages here. -#define INTERACTIVE_NO_NCURSES 108 - -#define RECORD_EMPTY 109 -#define RECORD_EXTRA 110 -#define RECORD_NOT_FF4 111 - -#define SUBST_EMPTY 112 -#define SUBST_BAD_CHARS 113 -#define SUBST_MALFORMED 114 - -#define TAGS_NO_COMMA 115 - -#define CMD_MISSING 116 - -// 2xx Commands -#define CMD_ACTIVE 200 -#define CMD_ADD 201 -#define CMD_APPEND 202 -#define CMD_ANNOTATE 203 -#define CMD_CALENDAR 204 -#define CMD_COLORS 205 -#define CMD_COMPLETED 206 -#define CMD_DELETE 207 -#define CMD_DONE 208 -#define CMD_DUPLICATE 209 -#define CMD_EDIT 210 -#define CMD_DENOTATE 211 - -#define CMD_HELP 212 - -#define CMD_IMPORT 215 -#define CMD_INFO 216 -#define CMD_PREPEND 217 -#define CMD_OVERDUE 218 -#define CMD_PROJECTS 219 -#define CMD_START 220 -#define CMD_STATS 221 -#define CMD_STOP 222 -#define CMD_SUMMARY 223 -#define CMD_TAGS 224 -#define CMD_TIMESHEET 225 -#define CMD_LOG 226 -#define CMD_UNDO 227 -#define CMD_VERSION 228 -#define CMD_SHELL 229 -#define CMD_CONFIG 230 -#define CMD_SHOW 231 -#define CMD_MERGE 232 -#define CMD_PUSH 233 -#define CMD_PULL 234 -#define CMD_DIAGNOSTICS 235 - -// 3xx Attributes -#define ATT_PROJECT 300 -#define ATT_PRIORITY 301 -#define ATT_FG 302 -#define ATT_BG 303 -#define ATT_DUE 304 -#define ATT_ENTRY 305 -#define ATT_START 306 -#define ATT_END 307 -#define ATT_RECUR 308 -#define ATT_UNTIL 309 -#define ATT_MASK 310 -#define ATT_IMASK 311 - -#define ATT_MOD_BEFORE 350 -#define ATT_MOD_AFTER 351 -#define ATT_MOD_NOT 352 -#define ATT_MOD_NONE 353 -#define ATT_MOD_ANY 354 -#define ATT_MOD_SYNTH 355 -#define ATT_MOD_UNDER 356 -#define ATT_MOD_OVER 357 -#define ATT_MOD_FIRST 358 -#define ATT_MOD_LAST 359 -#define ATT_MOD_THIS 360 -#define ATT_MOD_NEXT 361 -#define ATT_MOD_IS 362 -#define ATT_MOD_ISNT 363 -#define ATT_MOD_HAS 364 -#define ATT_MOD_HASNT 365 -#define ATT_MOD_STARTSWITH 366 -#define ATT_MOD_ENDSWITH 367 - -// 4xx Columns - -// 5xx Colors #define CCOLOR_BOLD 500 #define CCOLOR_UNDERLINE 501 #define CCOLOR_ON 502 @@ -155,11 +63,5 @@ #define CCOLOR_OFF 520 #define CCOLOR_UNKNOWN 521 -// 6xx Config - -// 7xx TDB - -// 8xx Reports - #endif diff --git a/src/main.cpp b/src/main.cpp index 2e11d34cd..047e194e2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,7 +34,8 @@ #include #endif -#include "Context.h" +#include +#include #include "../cmake.h" Context context; @@ -96,7 +97,7 @@ int main (int argc, char** argv) catch (...) { - std::cerr << "Unknown error." << "\n"; + std::cerr << STRING_UNKNOWN_ERROR << "\n"; return -2; }