From c502f0216a62e3fd4084547b4d081414e99cdcee Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 27 Mar 2011 02:06:09 -0400 Subject: [PATCH] i18n - Eliminated StringTable.{h,cpp}. - Eliminated strings. files. This is not the way to do it. --- i18n/CMakeLists.txt | 3 +- i18n/strings.de-DE | 157 ----------------------------------------- i18n/strings.en-US | 125 -------------------------------- i18n/strings.es-ES | 11 --- i18n/strings.fr-FR | 11 --- i18n/strings.nl-NL | 11 --- i18n/strings.sv-SE | 157 ----------------------------------------- src/CMakeLists.txt | 19 +++-- src/Cmd.cpp | 127 ++++++++++++++++----------------- src/Context.cpp | 24 ++----- src/Context.h | 2 - src/Record.cpp | 9 +-- src/Sequence.cpp | 10 +-- src/StringTable.cpp | 98 ------------------------- src/StringTable.h | 47 ------------ src/Subst.cpp | 9 +-- src/command.cpp | 2 +- src/main.cpp | 2 +- src/ui/interactive.cpp | 5 +- src/util.cpp | 4 +- test/.gitignore | 1 - test/CMakeLists.txt | 9 +-- test/limit.t | 2 +- test/stringtable.t.cpp | 61 ---------------- 24 files changed, 99 insertions(+), 807 deletions(-) delete mode 100644 i18n/strings.de-DE delete mode 100644 i18n/strings.en-US delete mode 100644 i18n/strings.es-ES delete mode 100644 i18n/strings.fr-FR delete mode 100644 i18n/strings.nl-NL delete mode 100644 i18n/strings.sv-SE delete mode 100644 src/StringTable.cpp delete mode 100644 src/StringTable.h delete mode 100644 test/stringtable.t.cpp diff --git a/i18n/CMakeLists.txt b/i18n/CMakeLists.txt index 2ca0cfef8..663b964ca 100644 --- a/i18n/CMakeLists.txt +++ b/i18n/CMakeLists.txt @@ -1,4 +1,3 @@ install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${TASK_DOCDIR}/i18n - FILES_MATCHING REGEX "strings.*" - REGEX "tips.*" + FILES_MATCHING REGEX "tips.*" PATTERN "CMakeFiles" EXCLUDE) diff --git a/i18n/strings.de-DE b/i18n/strings.de-DE deleted file mode 100644 index 07790b817..000000000 --- a/i18n/strings.de-DE +++ /dev/null @@ -1,157 +0,0 @@ -# This is an example strings.en-US file. -# -# The task program has a built-in set of default strings, which are UTF8 encoded -# for the en-US locale. A file such as this is used to override those defaults. -# This means that a strings file is merely a delta applied to the built-in -# strings, so an empty string file means you get en-US. -# -# To use another string file, add the following entry to your .taskrc file: -# -# locale=sv-SE # Swedish string set - -# 1xx task shell -100 Unbekannter Fehler #Unknown Error. -101 Konnte nicht Datenverzeichnis HOME aus passwd Datei lesen #Could not read home directory from the passwd file. -102 (j/n) #(y/n) -103 Ungültige ID in Sequenz #Invalid ID in sequence -104 Ungültige ID in Bereich #Invalid ID in range -105 Invertierter Sequenzbereich hoch-niedrig #Inverted sequence range high-low -106 ID Bereich zu gross #ID Range too large -107 Keine Sequenz #Not a sequence. -108 Task interaktiv nur möglich mit vorhandenem ncurses #Interactive task is only available when built with ncurses support. -109 Leerer Eintrag in der Eingabe #Empty record in input -110 Unbekanntes Zeichen am Zeilenende #Unrecognized characters at end of line -111 Datensatz nicht als Format 4 erkannt #Record not recognized as format 4 -112 Kann leere Zeichenkette nicht ersetzen #Cannot substitute an empty string -113 Nicht erkanntes Zeichen am Ende der Ersetzung #Unrecognized character(s) at end of substitution -114 Fehlformulierte Ersetzung #Malformed substitution -115 Etiketten dürfen keine Kommas enthalten #Tags are not permitted to contain commas - -# 2xx Commands - must be sequential -200 aktiv #active -201 hinzufen #add -202 beizufügen #append -203 anmerkung #annotate -204 kalender #calendar -205 farben #colors -206 fertiggestellt #completed -207 löschen #delete -208 erledigt #done -209 duplizieren #duplicate -210 editieren #edit -211 export #export -212 hilfe #help -213 geschichte #history -214 ggeschichte #ghistory -215 import #import -216 info #info - -218 überfällig #overdue -219 projekte #projects -220 start #start -221 statistik #stats -222 stop #stop -223 zusammenfassung #summary -224 etikett #tags -225 zeitdatenblatt#timesheet - -227 rücksetzen #undo -228 version #version - -# 3xx Attributes - must be sequential -300 projekt #project -301 priorität #priority -302 vordergrund #fg -303 hintergrund #bg -304 fällig #due -305 eintrag #entry -306 start #start -307 stop #end -308 wiederkehrend #recur -309 bis #until -310 mask #mask -311 imask #imask - -# 35x Attribute modifiers - must be sequential -350 davor #before -351 danach #after -352 nict #not -353 kein #none -354 beliebig #any -355 synth #synth -356 unter #under -357 über #over -358 erstes #first -359 letztes #last -360 dieses #this -361 nächste #next -362 ist #is -363 istnicht #isnt -364 hat #has -365 hatnicht #hasnt -366 beginntmit #startswith -367 endetmit #endswith - -# 4xx Columns - -# 5xx Colors -500 fett #bold -501 unterstrichen #underline -502 fett_unterstrichen #bold_underline -503 schwarz #black -504 rot #red -505 grün #green -506 gelb #yellow -507 blau #blue -508 magenta #magenta -509 cyan #cyan -510 weiss #white -511 fett_schwarz #bold_black -512 fett_rot #bold_red -513 fett_grün #bold_green -514 fett_gelb #bold_yellow -515 fett_blau #bold_blue -516 fett_magenta #bold_magenta -517 fett_cyan #bold_cyan -518 fett_weiss #bold_white -519 unterstrichen_schwarz #underline_black -520 unterstrichen_rot #underline_red -521 unterstrichen_grün #underline_green -522 unterstrichen_gelb #underline_yellow -523 unterstrichen_blau #underline_blue -524 unterstrichen_magenta #underline_magenta -525 unterstrichen_cyan #underline_cyan -526 unterstrichen_weiss #underline_white -527 fett_unterstrichen_schwarz #bold_underline_black -528 fett_unterstrichen_rot #bold_underline_red -529 fett_unterstrichen_grün #bold_underline_green -530 fett_unterstrichen_gelb #bold_underline_yellow -531 fett_unterstrichen_blau #bold_underline_blue -532 fett_unterstrichen_magenta #bold_underline_magenta -533 fett_unterstrichen_cyan #bold_underline_cyan -534 fett_unterstrichen_weiss #bold_underline_white -535 auf_schwarz #on_black -536 auf_rot #on_red -537 auf_grün #on_green -538 auf_gelb #on_yellow -539 auf_blau #on_blue -540 auf_magenta #on_magenta -541 auf_cyan #on_cyan -542 auf_weiss #on_white -543 auf_signal_schwarz #on_bright_black -544 auf_signal_rot #on_bright_red -545 auf_signal_grün #on_bright_green -546 auf_signal_gelb #on_bright_yellow -547 auf_signal_blau #on_bright_blue -548 auf_signal_magenta #on_bright_magenta -549 auf_signal_cyan #on_bright_cyan -550 auf_signal_weiss #on_bright_white -551 aus #off -552 Unbekannte Farbe #Unknown color name - -# 6xx Config - -# 7xx TDB - -# 8xx Reports - diff --git a/i18n/strings.en-US b/i18n/strings.en-US deleted file mode 100644 index 78ed6f05b..000000000 --- a/i18n/strings.en-US +++ /dev/null @@ -1,125 +0,0 @@ -# This is an example strings.en-US file. -# -# The taskwarrior program has a built-in set of default strings, which are UTF8 -# encoded for the en-US locale. A file such as this is used to override those -# defaults. This means that a strings file is merely a delta applied to the -# built-in strings, so an empty string file means you get en-US. -# -# To use another string file, add the following entry to your .taskrc file: -# -# locale=sv-SE # Swedish string set - -# 1xx task shell -100 Unknown Error. -101 Could not read home directory from the passwd file. -102 (y/n) -103 Invalid ID in sequence -104 Invalid ID in range -105 Inverted sequence range high-low -106 ID Range too large -107 Not a sequence. - -109 Empty record in input -110 Unrecognized characters at end of line -111 Record not recognized as format 4 -112 Cannot substitute an empty string -113 Unrecognized character(s) at end of substitution -114 Malformed substitution -115 Tags are not permitted to contain commas -116 You must specify a command, or a task ID to modify - -# 2xx Commands - must be sequential -200 active -201 add -202 append -203 annotate -204 calendar -205 colors -206 completed -207 delete -208 done -209 duplicate -210 edit - -212 help - -215 import -216 info -217 prepend -218 overdue -219 projects -220 start -221 stats -222 stop -223 summary -224 tags -225 timesheet -226 log -227 undo -228 version -229 shell -230 config -231 show - -235 diagnostics - -# 3xx Attributes - must be sequential -300 project -301 priority -302 fg -303 bg -304 due -305 entry -306 start -307 end -308 recur -309 until -310 mask -311 imask - -# 35x Attribute modifiers - must be sequential -350 before -351 after -352 not -353 none -354 any -355 synth -356 under -357 over -358 first -359 last -360 this -361 next -362 is -363 isnt -364 has -365 hasnt -366 startswith -367 endswith - -# 4xx Columns - -# 5xx Colors -500 bold -501 underline -502 on -503 bright - -504 black -505 red -506 green -507 yellow -508 blue -509 magenta -510 cyan -511 white - -520 off -521 Unknown color name - -# 6xx Config - -# 7xx TDB - -# 8xx Reports - diff --git a/i18n/strings.es-ES b/i18n/strings.es-ES deleted file mode 100644 index f9cf3ff99..000000000 --- a/i18n/strings.es-ES +++ /dev/null @@ -1,11 +0,0 @@ -# 1xx task shell -100 Error desconocido. - -# 2xx Commands -# 3xx Attributes -# 4xx Columns -# 5xx Colors -# 6xx Config -# 7xx TDB -# 8xx Reports - diff --git a/i18n/strings.fr-FR b/i18n/strings.fr-FR deleted file mode 100644 index 7c06146e5..000000000 --- a/i18n/strings.fr-FR +++ /dev/null @@ -1,11 +0,0 @@ -# 1xx task shell -100 Erreur inconnue. - -# 2xx Commands -# 3xx Attributes -# 4xx Columns -# 5xx Colors -# 6xx Config -# 7xx TDB -# 8xx Reports - diff --git a/i18n/strings.nl-NL b/i18n/strings.nl-NL deleted file mode 100644 index bc561d5b4..000000000 --- a/i18n/strings.nl-NL +++ /dev/null @@ -1,11 +0,0 @@ -# 1xx task shell -100 Onbekende fout. - -# 2xx Commands -# 3xx Attributes -# 4xx Columns -# 5xx Colors -# 6xx Config -# 7xx TDB -# 8xx Reports - diff --git a/i18n/strings.sv-SE b/i18n/strings.sv-SE deleted file mode 100644 index 7aae2c88c..000000000 --- a/i18n/strings.sv-SE +++ /dev/null @@ -1,157 +0,0 @@ -# This is an example strings.en-US file. -# -# The taskwarrior program has a built-in set of default strings, which are UTF8 -# encoded for the en-US locale. A file such as this is used to override those -# default. This means that a strings file is merely a delta applied to the -# built-in strings, so an empty string file means you get en-US. -# -# To use another string file, add the following entry to your .taskrc file: -# -# locale=sv-SE # Swedish string set - -# 1xx task shell -100 Okänt fel. #Unknown Error. -101 Kunde inte läsa hemkatalogen från passwd filen. #Could not read home directory from the passwd file. -102 (j/n) #(y/n) -103 Ogiltig ID i sekvens #Invalid ID in sequence -104 Ogiltig ID i spännvidd #Invalid ID in range -105 Inverterad sekvens spännvidd hög-låg #Inverted sequence range high-low -106 ID spännvidd för stor #ID Range too large -107 Ingen sekvens. #Not a sequence. -108 Interaktiv task är bara tillgänglig när den kompilerades med support för ncurses. #Interactive task is only available when built with ncurses support. -109 Tom post i ingångsdata #Empty record in input -110 Okänt tecknen på slutet av raden. #Unrecognized characters at end of line -111 Post inte indentifierad som format 4 #Record not recognized as format 4 -112 Substitution av tom teckensträng är inte möjligt #Cannot substitute an empty string -113 Pkänt tecken vid slutet av substitution #Unrecognized character(s) at end of substitution -114 Ogiltig substitution #Malformed substitution -115 Taggar får inte innehåller komman #Tags are not permitted to contain commas - -# 2xx Commands - must be sequential -200 aktivt #active -201 tillägg #add -202 bifoga #append -203 kommentera #annotate -204 kalender #calendar -205 färger #colors -206 avslutad #completed -207 stryk #delete -208 färdig #done -209 kopiera #duplicate -210 redigera #edit -211 exportera #export -212 hjälp #help -213 historia #history -214 ghistoria #ghistory -215 importera #import -216 info #info - -218 försenad #overdue -219 projekten #projects -220 start #start -221 statistik #stats -222 stop #stop -223 sammanfattning #summary -224 taggar #tags -225 tidsrapport #timesheet - -227 ångra #undo -228 version #version - -# 3xx Attributes - must be sequential -300 projekt #project -301 prioritet #priority -302 förgrund #fg -303 bakgrund #bg -304 väntad #due -305 post #entry -306 start #start -307 slut #end -308 periodirskt #recur -309 innan #until -310 mask #mask -311 imask #imask - -# 35x Attribute modifiers - must be sequential -350 före #before -351 efter #after -352 inte #not -353 ingen #none -354 några #any -355 synth #synth -356 under #under -357 över #over -358 första #first -359 sista #last -360 detta #this -361 nästa #next -362 är #is -363 ärinte #isnt -364 har #has -365 harinte #hasnt -366 börjarmed #startswith -367 slutarmed #endswith - -# 4xx Columns - -# 5xx Colors -500 fet #bold -501 understrykt #underline -502 fet_understrykt #bold_underline -503 svart #black -504 röd #red -505 grön #green -506 gul #yellow -507 blå #blue -508 magenta #magenta -509 cyan #cyan -510 vit #white -511 fet_svart #bold_black -512 fet_röd #bold_red -513 fet_grön #bold_green -514 fet_gul #bold_yellow -515 fet_blå #bold_blue -516 fet_magenta #bold_magenta -517 fet_cyan #bold_cyan -518 fet_vit #bold_white -519 understrykt_svart #underline_black -520 understrykt_röd #underline_red -521 understrykt_grön #underline_green -522 understrykt_gul #underline_yellow -523 understrykt_blå #underline_blue -524 understrykt_magenta #underline_magenta -525 understrykt_cyan #underline_cyan -526 understrykt_vit #underline_white -527 fet_understrykt_svart #bold_underline_black -528 fet_understrykt_röd #bold_underline_red -529 fet_understrykt_grön #bold_underline_green -530 fet_understrykt_gul #bold_underline_yellow -531 fet_understrykt_blå #bold_underline_blue -532 fet_understrykt_magenta #bold_underline_magenta -533 fet_understrykt_cyan #bold_underline_cyan -534 fet_understrykt_vit #bold_underline_white -535 på_svart #on_black -536 på_röd #on_red -537 på_grön #on_green -538 på_gul #on_yellow -539 på_blå #on_blue -540 på_magenta #on_magenta -541 på_cyan #on_cyan -542 på_vit #on_white -543 på_ljust_svart #on_bright_black -544 på_ljust_röd #on_bright_red -545 på_ljust_grön #on_bright_green -546 på_ljust_gul #on_bright_yellow -547 på_ljust_blå #on_bright_blue -548 på_ljust_magenta #on_bright_magenta -549 på_ljust_cyan #on_bright_cyan -550 på_ljust_vit #on_bright_white -551 av #off -552 Okänt färg namn #Unknown color name - -# 6xx Config - -# 7xx TDB - -# 8xx Reports - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1c27cb4df..4dd1c46a3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,16 +8,15 @@ set (task_SRCS API.cpp API.h Att.cpp Att.h Cmd.cpp Cmd.h Color.cpp Color.h JSON.cpp JSON.h Keymap.cpp Keymap.h Lisp.cpp Lisp.h Location.cpp Location.h Nibbler.cpp Nibbler.h Path.cpp Path.h Permission.cpp Permission.h Record.cpp Record.h Rectangle.cpp Rectangle.h - Sensor.cpp Sensor.h Sequence.cpp Sequence.h StringTable.cpp - StringTable.h Subst.cpp Subst.h TDB.cpp TDB.h Table.cpp Table.h - Task.cpp Task.h Taskmod.cpp Taskmod.h Thread.cpp Thread.h - Timer.cpp Timer.h Transport.cpp Transport.h TransportSSH.cpp - TransportSSH.h TransportRSYNC.cpp TransportRSYNC.h - TransportCurl.cpp TransportCurl.h Tree.cpp Tree.h burndown.cpp - command.cpp custom.cpp dependency.cpp diag.cpp edit.cpp - export.cpp history.cpp i18n.h import.cpp interactive.cpp - recur.cpp report.cpp rules.cpp rx.cpp rx.h text.cpp text.h - utf8.cpp utf8.h util.cpp util.h Uri.cpp Uri.h) + Sensor.cpp Sensor.h Sequence.cpp Sequence.h Subst.cpp Subst.h + TDB.cpp TDB.h Table.cpp Table.h Task.cpp Task.h Taskmod.cpp + Taskmod.h Thread.cpp Thread.h Timer.cpp Timer.h Transport.cpp + Transport.h TransportSSH.cpp TransportSSH.h TransportRSYNC.cpp + TransportRSYNC.h TransportCurl.cpp TransportCurl.h Tree.cpp + Tree.h burndown.cpp command.cpp custom.cpp dependency.cpp + diag.cpp edit.cpp export.cpp history.cpp i18n.h import.cpp + interactive.cpp recur.cpp report.cpp rules.cpp rx.cpp rx.h + text.cpp text.h utf8.cpp utf8.h util.cpp util.h Uri.cpp Uri.h) add_library (task STATIC ${task_SRCS}) add_executable (task_executable main.cpp) diff --git a/src/Cmd.cpp b/src/Cmd.cpp index cc4d232a4..5de65fae0 100644 --- a/src/Cmd.cpp +++ b/src/Cmd.cpp @@ -127,7 +127,6 @@ void Cmd::load () { if (commands.size () == 0) { - // Commands whose names are not localized. commands.push_back ("_projects"); commands.push_back ("_tags"); commands.push_back ("_commands"); @@ -150,41 +149,39 @@ void Cmd::load () commands.push_back ("burndown.monthly"); commands.push_back ("count"); commands.push_back ("ids"); - - // Commands whose names are localized. - commands.push_back (context.stringtable.get (CMD_ADD, "add")); - commands.push_back (context.stringtable.get (CMD_APPEND, "append")); - commands.push_back (context.stringtable.get (CMD_ANNOTATE, "annotate")); - commands.push_back (context.stringtable.get (CMD_DENOTATE, "denotate")); - commands.push_back (context.stringtable.get (CMD_CALENDAR, "calendar")); - commands.push_back (context.stringtable.get (CMD_COLORS, "colors")); - commands.push_back (context.stringtable.get (CMD_CONFIG, "config")); - commands.push_back (context.stringtable.get (CMD_SHOW, "show")); - commands.push_back (context.stringtable.get (CMD_DELETE, "delete")); - commands.push_back (context.stringtable.get (CMD_DIAGNOSTICS, "diagnostics")); - commands.push_back (context.stringtable.get (CMD_DONE, "done")); - commands.push_back (context.stringtable.get (CMD_DUPLICATE, "duplicate")); - commands.push_back (context.stringtable.get (CMD_EDIT, "edit")); - commands.push_back (context.stringtable.get (CMD_HELP, "help")); - commands.push_back (context.stringtable.get (CMD_IMPORT, "import")); - commands.push_back (context.stringtable.get (CMD_INFO, "info")); - commands.push_back (context.stringtable.get (CMD_LOG, "log")); - commands.push_back (context.stringtable.get (CMD_PREPEND, "prepend")); - commands.push_back (context.stringtable.get (CMD_PROJECTS, "projects")); + commands.push_back ("add"); + commands.push_back ("append"); + commands.push_back ("annotate"); + commands.push_back ("denotate"); + commands.push_back ("calendar"); + commands.push_back ("colors"); + commands.push_back ("config"); + commands.push_back ("show"); + commands.push_back ("delete"); + commands.push_back ("diagnostics"); + commands.push_back ("done"); + commands.push_back ("duplicate"); + commands.push_back ("edit"); + commands.push_back ("help"); + commands.push_back ("import"); + commands.push_back ("info"); + commands.push_back ("log"); + commands.push_back ("prepend"); + commands.push_back ("projects"); #ifdef FEATURE_SHELL - commands.push_back (context.stringtable.get (CMD_SHELL, "shell")); + commands.push_back ("shell"); #endif - commands.push_back (context.stringtable.get (CMD_START, "start")); - commands.push_back (context.stringtable.get (CMD_STATS, "stats")); - commands.push_back (context.stringtable.get (CMD_STOP, "stop")); - commands.push_back (context.stringtable.get (CMD_SUMMARY, "summary")); - commands.push_back (context.stringtable.get (CMD_TAGS, "tags")); - commands.push_back (context.stringtable.get (CMD_TIMESHEET, "timesheet")); - commands.push_back (context.stringtable.get (CMD_UNDO, "undo")); - commands.push_back (context.stringtable.get (CMD_VERSION, "version")); - commands.push_back (context.stringtable.get (CMD_MERGE, "merge")); - commands.push_back (context.stringtable.get (CMD_PUSH, "push")); - commands.push_back (context.stringtable.get (CMD_PULL, "pull")); + commands.push_back ("start"); + commands.push_back ("stats"); + commands.push_back ("stop"); + commands.push_back ("summary"); + commands.push_back ("tags"); + commands.push_back ("timesheet"); + commands.push_back ("undo"); + commands.push_back ("version"); + commands.push_back ("merge"); + commands.push_back ("push"); + commands.push_back ("pull"); // Now load the custom reports. std::vector all; @@ -260,21 +257,21 @@ bool Cmd::isReadOnlyCommand () command == "burndown.monthly" || command == "count" || command == "ids" || - command == context.stringtable.get (CMD_CALENDAR, "calendar") || - command == context.stringtable.get (CMD_COLORS, "colors") || - command == context.stringtable.get (CMD_DIAGNOSTICS, "diagnostics") || - command == context.stringtable.get (CMD_CONFIG, "config") || - command == context.stringtable.get (CMD_SHOW, "show") || - command == context.stringtable.get (CMD_HELP, "help") || - command == context.stringtable.get (CMD_INFO, "info") || - command == context.stringtable.get (CMD_PROJECTS, "projects") || - command == context.stringtable.get (CMD_PUSH, "push") || - command == context.stringtable.get (CMD_SHELL, "shell") || - command == context.stringtable.get (CMD_STATS, "stats") || - command == context.stringtable.get (CMD_SUMMARY, "summary") || - command == context.stringtable.get (CMD_TAGS, "tags") || - command == context.stringtable.get (CMD_TIMESHEET, "timesheet") || - command == context.stringtable.get (CMD_VERSION, "version") || + command == "calendar" || + command == "colors" || + command == "diagnostics" || + command == "config" || + command == "show" || + command == "help" || + command == "info" || + command == "projects" || + command == "push" || + command == "shell" || + command == "stats" || + command == "summary" || + command == "tags" || + command == "timesheet" || + command == "version" || validCustom (command)) return true; @@ -285,22 +282,22 @@ bool Cmd::isReadOnlyCommand () // Commands that directly modify the data files. bool Cmd::isWriteCommand () { - if (command == context.stringtable.get (CMD_MERGE, "merge") || - command == context.stringtable.get (CMD_ADD, "add") || - command == context.stringtable.get (CMD_APPEND, "append") || - command == context.stringtable.get (CMD_ANNOTATE, "annotate") || - command == context.stringtable.get (CMD_DENOTATE, "denotate") || - command == context.stringtable.get (CMD_DELETE, "delete") || - command == context.stringtable.get (CMD_DONE, "done") || - command == context.stringtable.get (CMD_DUPLICATE, "duplicate") || - command == context.stringtable.get (CMD_EDIT, "edit") || - command == context.stringtable.get (CMD_IMPORT, "import") || - command == context.stringtable.get (CMD_LOG, "log") || - command == context.stringtable.get (CMD_PREPEND, "prepend") || - command == context.stringtable.get (CMD_PULL, "pull") || - command == context.stringtable.get (CMD_START, "start") || - command == context.stringtable.get (CMD_STOP, "stop") || - command == context.stringtable.get (CMD_UNDO, "undo")) + if (command == "merge" || + command == "add" || + command == "append" || + command == "annotate" || + command == "denotate" || + command == "delete" || + command == "done" || + command == "duplicate" || + command == "edit" || + command == "import" || + command == "log" || + command == "prepend" || + command == "pull" || + command == "start" || + command == "stop" || + command == "undo") return true; return false; diff --git a/src/Context.cpp b/src/Context.cpp index 121bdf1c4..6fa19d11a 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -51,7 +51,6 @@ Context::Context () , subst () , task () , tdb () -, stringtable () , program ("") , file_override ("") , var_overrides ("") @@ -135,8 +134,6 @@ void Context::initialize () if (config.getBoolean ("color")) initializeColorRules (); - // Load appropriate stringtable as soon after the config file as possible, to - // allow all subsequent messages to be localizable. Directory location (config.get ("data.location")); std::string locale = config.get ("locale"); @@ -145,9 +142,6 @@ void Context::initialize () if (period != std::string::npos) locale = locale.substr (0, period); - if (locale != "") - stringtable.load (location.data + "/strings." + locale); - // init TDB. tdb.clear (); std::vector all; @@ -175,7 +169,7 @@ int Context::run () catch (...) { - footnote (stringtable.get (100, "Unknown error.")); + footnote ("Unknown error."); rc = 3; } @@ -465,10 +459,7 @@ void Context::loadCorrectConfigFile () // Set up default locations. struct passwd* pw = getpwuid (getuid ()); if (!pw) - throw std::string ( - stringtable.get ( - SHELL_READ_PASSWD, - "Could not read home directory from the passwd file.")); + throw std::string ("Could not read home directory from the passwd file."); std::string home = pw->pw_dir; File rc (home + "/.taskrc"); @@ -621,8 +612,7 @@ void Context::parse ( foundNonSequence = true; if (arg->find (',') != std::string::npos) - throw stringtable.get (TAGS_NO_COMMA, - "Tags are not permitted to contain commas."); + throw std::string ("Tags are not permitted to contain commas."); tagAdditions.push_back (arg->substr (1)); parseTask.addTag (arg->substr (1)); @@ -640,8 +630,7 @@ void Context::parse ( foundNonSequence = true; if (arg->find (',') != std::string::npos) - throw stringtable.get (TAGS_NO_COMMA, - "Tags are not permitted to contain commas."); + throw std::string ("Tags are not permitted to contain commas."); tagRemovals.push_back (arg->substr (1)); } @@ -801,9 +790,7 @@ void Context::parse ( parse (args, cmd, task, sequence, subst, filter); } else - throw stringtable.get ( - CMD_MISSING, - "You must specify a command, or a task ID to modify."); + throw std::string ("You must specify a command, or a task ID to modify."); } // If the command "task 123" is entered, but with no modifier arguments, @@ -831,7 +818,6 @@ void Context::clear () // task.clear (); task = Task (); tdb.clear (); -// stringtable.clear (); program = ""; args.clear (); file_override = ""; diff --git a/src/Context.h b/src/Context.h index fad7fba91..175e5ce58 100644 --- a/src/Context.h +++ b/src/Context.h @@ -35,7 +35,6 @@ #include "Cmd.h" #include "Task.h" #include "TDB.h" -#include "StringTable.h" #include "Hooks.h" class Context @@ -84,7 +83,6 @@ public: Subst subst; Task task; TDB tdb; - StringTable stringtable; std::string program; std::vector args; std::string file_override; diff --git a/src/Record.cpp b/src/Record.cpp index 173c99617..1fceef55d 100644 --- a/src/Record.cpp +++ b/src/Record.cpp @@ -94,8 +94,7 @@ void Record::parse (const std::string& input) n.depleted ()) { if (line.length () == 0) - throw context.stringtable.get (RECORD_EMPTY, - "Empty record in input."); + throw std::string ("Empty record in input."); Nibbler nl (line); Att a; @@ -109,12 +108,10 @@ void Record::parse (const std::string& input) std::string remainder; nl.getUntilEOS (remainder); if (remainder.length ()) - throw context.stringtable.get (RECORD_EXTRA, - "Unrecognized characters at end of line."); + throw std::string ("Unrecognized characters at end of line."); } else - throw context.stringtable.get (RECORD_NOT_FF4, - "Record not recognized as format 4."); + throw std::string ("Record not recognized as format 4."); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Sequence.cpp b/src/Sequence.cpp index bca81d2b2..e6aa63742 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -96,7 +96,7 @@ void Sequence::parse (const std::string& input) case 1: { if (! validId (range[0])) - throw context.stringtable.get (SEQUENCE_BAD_SEQ, "Invalid ID in sequence."); + throw std::string ("Invalid ID in sequence."); int id = atoi (range[0].c_str ()); this->push_back (id); @@ -107,15 +107,15 @@ void Sequence::parse (const std::string& input) { if (! validId (range[0]) || ! validId (range[1])) - throw context.stringtable.get (SEQUENCE_BAD_SEQ, "Invalid ID in range."); + throw std::string ("Invalid ID in range."); int low = atoi (range[0].c_str ()); int high = atoi (range[1].c_str ()); if (low > high) - throw context.stringtable.get (SEQUENCE_INVERTED, "Inverted sequence range high-low."); + throw std::string ("Inverted sequence range high-low."); if (high - low >= SEQUENCE_MAX) - throw context.stringtable.get (SEQUENCE_RANGE_MAX, "ID Range too large."); + throw std::string ("ID Range too large."); for (int i = low; i <= high; ++i) this->push_back (i); @@ -123,7 +123,7 @@ void Sequence::parse (const std::string& input) break; default: - throw context.stringtable.get (SEQUENCE_NOT_A_SEQUENCE, "Not a sequence."); + throw std::string ("Not a sequence."); break; } } diff --git a/src/StringTable.cpp b/src/StringTable.cpp deleted file mode 100644 index a0f4357bf..000000000 --- a/src/StringTable.cpp +++ /dev/null @@ -1,98 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// 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 -// -//////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include -#include "StringTable.h" - -//////////////////////////////////////////////////////////////////////////////// -StringTable::StringTable () -{ -} - -//////////////////////////////////////////////////////////////////////////////// -StringTable::~StringTable () -{ -} - -//////////////////////////////////////////////////////////////////////////////// -// UTF-8 encoding -// -// 123 This is the string -// 124 This is another string -// ... -void StringTable::load (const std::string& file) -{ - this->clear (); // Allows dynamic reload. - - std::ifstream in; - in.open (file.c_str (), std::ifstream::in); - if (in.good ()) - { - std::string line; - while (getline (in, line)) - { - // Remove comments. - std::string::size_type pound = line.find ("#"); // no i18n - if (pound != std::string::npos) - line = line.substr (0, pound); - - line = trim (line, " \t"); // no i18n - - // Skip empty lines. - if (line.length () > 0) - { - std::string::size_type equal = line.find (" "); // no i18n - if (equal != std::string::npos) - { - int key = atoi (trim (line.substr (0, equal), " \t").c_str ()); // no i18n - std::string value = trim (line.substr (equal+1, line.length () - equal), " \t"); // no i18n - (*this)[key] = value; - } - } - } - - in.close (); - } - else - throw std::string ("Could not read string file '") + file + "'"; // TODO i18n -} - -//////////////////////////////////////////////////////////////////////////////// -std::string StringTable::get (int id, const std::string& alternate) -{ - // Return the right string. - if (this->find (id) != this->end ()) - return (*this)[id]; - - return alternate; -} - -//////////////////////////////////////////////////////////////////////////////// diff --git a/src/StringTable.h b/src/StringTable.h deleted file mode 100644 index 45378c62e..000000000 --- a/src/StringTable.h +++ /dev/null @@ -1,47 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// 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 -// -//////////////////////////////////////////////////////////////////////////////// -#ifndef INCLUDED_STRINGTABLE -#define INCLUDED_STRINGTABLE - -#include -#include - -class StringTable : public std::map -{ -public: - StringTable (); // Default constructor - ~StringTable (); // Destructor - - StringTable (const StringTable&); - StringTable& operator= (const StringTable&); - - void load (const std::string&); - std::string get (int, const std::string&); -}; - -#endif -//////////////////////////////////////////////////////////////////////////////// diff --git a/src/Subst.cpp b/src/Subst.cpp index c30567f54..3d9612ac4 100644 --- a/src/Subst.cpp +++ b/src/Subst.cpp @@ -111,16 +111,13 @@ void Subst::parse (const std::string& input) mGlobal = n.skip ('g'); if (mFrom == "") - throw context.stringtable.get (SUBST_EMPTY, - "Cannot substitute an empty string."); + throw std::string ("Cannot substitute an empty string."); if (!n.depleted ()) - throw context.stringtable.get (SUBST_BAD_CHARS, - "Unrecognized character(s) at end of substitution."); + throw std::string ("Unrecognized character(s) at end of substitution."); } else - throw context.stringtable.get (SUBST_MALFORMED, - "Malformed substitution."); + throw std::string ("Malformed substitution."); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/command.cpp b/src/command.cpp index fb9b5f4ca..46073c23b 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -2497,7 +2497,7 @@ void handleShell () catch (...) { - std::cerr << context.stringtable.get (100, "Unknown error.") << "\n"; + std::cerr << "Unknown error." << "\n"; } } } diff --git a/src/main.cpp b/src/main.cpp index 80ae4771a..2e11d34cd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -96,7 +96,7 @@ int main (int argc, char** argv) catch (...) { - std::cerr << context.stringtable.get (100, "Unknown error.") << "\n"; + std::cerr << "Unknown error." << "\n"; return -2; } diff --git a/src/ui/interactive.cpp b/src/ui/interactive.cpp index 26513ee88..f2440a837 100644 --- a/src/ui/interactive.cpp +++ b/src/ui/interactive.cpp @@ -77,9 +77,8 @@ int Context::handleInteractive () #else - throw stringtable.get (INTERACTIVE_NO_NCURSES, - "Interactive task is only available when built with ncurses " - "support."); + throw std::string ("Interactive task is only available when built with " + "ncurses support."); #endif diff --git a/src/util.cpp b/src/util.cpp index d4ba3e9a9..afa71ce97 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -59,9 +59,7 @@ bool confirm (const std::string& question) do { std::cout << question - << " " - << context.stringtable.get (CONFIRM_YES_NO, "(y/n)") - << " "; + << " (y/n) "; std::getline (std::cin, answer); answer = std::cin.eof() ? "no" : lowerCase (trim (answer)); diff --git a/test/.gitignore b/test/.gitignore index cf2be5fb2..6bf916fc0 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -22,7 +22,6 @@ rectangle.t rx.t sensor.t seq.t -stringtable.t subst.t t.benchmark.t t.t diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7c2beb2e4..a57155bd0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,10 +3,11 @@ include_directories (${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/test ${TASK_INCLUDE_DIRS}) -set (test_SRCS date.t t.t tdb.t duration.t t.benchmark.t text.t autocomplete.t seq.t - record.t att.t stringtable.t subst.t nibbler.t filt.t cmd.t config.t - util.t color.t list.t path.t file.t grid.t directory.t rx.t taskmod.t - lisp.t rectangle.t sensor.t tree.t tree2.t uri.t json.t) +set (test_SRCS date.t t.t tdb.t duration.t t.benchmark.t text.t autocomplete.t + seq.t record.t att.t subst.t nibbler.t filt.t cmd.t config.t + util.t color.t list.t path.t file.t grid.t directory.t rx.t + taskmod.t lisp.t rectangle.t sensor.t tree.t tree2.t uri.t + json.t) add_custom_target (test ./run_all DEPENDS ${test_SRCS} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test) diff --git a/test/limit.t b/test/limit.t index d7669cde7..789f7d928 100755 --- a/test/limit.t +++ b/test/limit.t @@ -80,7 +80,7 @@ $output = qx{../src/task rc:limit.rc ls limit:3}; like ($output, qr/^30 tasks, 3 shown$/ms, 'limited to 3'); $output = qx{../src/task rc:limit.rc ls limit:page}; -like ($output, qr/^30 tasks, truncated to 17 lines$/ms, 'limited to page'); +like ($output, qr/^30 tasks, truncated to 18 lines$/ms, 'limited to page'); # Cleanup. unlink 'pending.data'; diff --git a/test/stringtable.t.cpp b/test/stringtable.t.cpp deleted file mode 100644 index c4d5595d7..000000000 --- a/test/stringtable.t.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// 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 -// -//////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include - -Context context; - -//////////////////////////////////////////////////////////////////////////////// -int main (int argc, char** argv) -{ - UnitTest t (4); - - // Create a string file. - std::string file = "./strings.xx-XX"; - File::write (file, "# comment\n1 found"); - t.is (access (file.c_str (), F_OK), 0, "strings.xx-XX created."); - - // Load the string file. - StringTable st; - st.load (file); - - // Test the object. - t.is (st.get (1, "nope"), "found", "string 1 'found' found"); - t.is (st.get (2, "nope"), "nope", "string 2 'nope' defaulted"); - - // Clean up. - unlink (file.c_str ()); - t.is (access (file.c_str (), F_OK), -1, "strings.xx-XX removed."); - - return 0; -} - -////////////////////////////////////////////////////////////////////////////////