Marked all strings needing internationalization

These strings are now collected automagically in the file po/ledger.pot.
If you'd like to produce a translation, just run this command after
building Ledger:

    msginit -l LOCALE -o LANG.po -i po/ledger.pot

Where LOCALE is a string like de or en_GB, and LANG is a short
descriptive word for your language.

Then send me this .po file so I can commit it to the Ledger sources
(alternatively, you could maintain the file in a fork on GitHub), and
setup the build script to format and install your new message catalog
during a "make install".
This commit is contained in:
John Wiegley 2009-02-25 03:51:42 -04:00
parent f745767fa6
commit 238bd7f8a5
40 changed files with 380 additions and 381 deletions

View file

@ -229,18 +229,18 @@ int amount_t::compare(const amount_t& amt) const
if (! quantity || ! amt.quantity) { if (! quantity || ! amt.quantity) {
if (quantity) if (quantity)
throw_(amount_error, "Cannot compare an amount to an uninitialized amount"); throw_(amount_error, _("Cannot compare an amount to an uninitialized amount"));
else if (amt.quantity) else if (amt.quantity)
throw_(amount_error, "Cannot compare an uninitialized amount to an amount"); throw_(amount_error, _("Cannot compare an uninitialized amount to an amount"));
else else
throw_(amount_error, "Cannot compare two uninitialized amounts"); throw_(amount_error, _("Cannot compare two uninitialized amounts"));
} }
if (has_commodity() && amt.has_commodity() && if (has_commodity() && amt.has_commodity() &&
commodity() != amt.commodity()) commodity() != amt.commodity())
throw_(amount_error, throw_(amount_error,
"Cannot compare amounts with different commodities: " << _("Cannot compare amounts with different commodities: %1 and %2")
commodity().symbol() << " and " << amt.commodity().symbol()); << commodity().symbol() << amt.commodity().symbol());
return mpq_cmp(MP(quantity), MP(amt.quantity)); return mpq_cmp(MP(quantity), MP(amt.quantity));
} }
@ -264,19 +264,18 @@ amount_t& amount_t::operator+=(const amount_t& amt)
if (! quantity || ! amt.quantity) { if (! quantity || ! amt.quantity) {
if (quantity) if (quantity)
throw_(amount_error, "Cannot add an uninitialized amount to an amount"); throw_(amount_error, _("Cannot add an uninitialized amount to an amount"));
else if (amt.quantity) else if (amt.quantity)
throw_(amount_error, "Cannot add an amount to an uninitialized amount"); throw_(amount_error, _("Cannot add an amount to an uninitialized amount"));
else else
throw_(amount_error, "Cannot add two uninitialized amounts"); throw_(amount_error, _("Cannot add two uninitialized amounts"));
} }
if (commodity() != amt.commodity()) if (commodity() != amt.commodity())
throw_(amount_error, throw_(amount_error,
"Adding amounts with different commodities: " << _("Adding amounts with different commodities: %1 != %2")
(has_commodity() ? commodity().symbol() : "NONE") << << (has_commodity() ? commodity().symbol() : _("NONE"))
" != " << << (amt.has_commodity() ? amt.commodity().symbol() : _("NONE")));
(amt.has_commodity() ? amt.commodity().symbol() : "NONE"));
_dup(); _dup();
@ -294,19 +293,18 @@ amount_t& amount_t::operator-=(const amount_t& amt)
if (! quantity || ! amt.quantity) { if (! quantity || ! amt.quantity) {
if (quantity) if (quantity)
throw_(amount_error, "Cannot subtract an amount from an uninitialized amount"); throw_(amount_error, _("Cannot subtract an amount from an uninitialized amount"));
else if (amt.quantity) else if (amt.quantity)
throw_(amount_error, "Cannot subtract an uninitialized amount from an amount"); throw_(amount_error, _("Cannot subtract an uninitialized amount from an amount"));
else else
throw_(amount_error, "Cannot subtract two uninitialized amounts"); throw_(amount_error, _("Cannot subtract two uninitialized amounts"));
} }
if (commodity() != amt.commodity()) if (commodity() != amt.commodity())
throw_(amount_error, throw_(amount_error,
"Subtracting amounts with different commodities: " << _("Subtracting amounts with different commodities: %1 != %2")
(has_commodity() ? commodity().symbol() : "NONE") << << (has_commodity() ? commodity().symbol() : _("NONE"))
" != " << << (amt.has_commodity() ? amt.commodity().symbol() : _("NONE")));
(amt.has_commodity() ? amt.commodity().symbol() : "NONE"));
_dup(); _dup();
@ -324,11 +322,11 @@ amount_t& amount_t::operator*=(const amount_t& amt)
if (! quantity || ! amt.quantity) { if (! quantity || ! amt.quantity) {
if (quantity) if (quantity)
throw_(amount_error, "Cannot multiply an amount by an uninitialized amount"); throw_(amount_error, _("Cannot multiply an amount by an uninitialized amount"));
else if (amt.quantity) else if (amt.quantity)
throw_(amount_error, "Cannot multiply an uninitialized amount by an amount"); throw_(amount_error, _("Cannot multiply an uninitialized amount by an amount"));
else else
throw_(amount_error, "Cannot multiply two uninitialized amounts"); throw_(amount_error, _("Cannot multiply two uninitialized amounts"));
} }
_dup(); _dup();
@ -354,15 +352,15 @@ amount_t& amount_t::operator/=(const amount_t& amt)
if (! quantity || ! amt.quantity) { if (! quantity || ! amt.quantity) {
if (quantity) if (quantity)
throw_(amount_error, "Cannot divide an amount by an uninitialized amount"); throw_(amount_error, _("Cannot divide an amount by an uninitialized amount"));
else if (amt.quantity) else if (amt.quantity)
throw_(amount_error, "Cannot divide an uninitialized amount by an amount"); throw_(amount_error, _("Cannot divide an uninitialized amount by an amount"));
else else
throw_(amount_error, "Cannot divide two uninitialized amounts"); throw_(amount_error, _("Cannot divide two uninitialized amounts"));
} }
if (! amt) if (! amt)
throw_(amount_error, "Divide by zero"); throw_(amount_error, _("Divide by zero"));
_dup(); _dup();
@ -393,7 +391,7 @@ amount_t::precision_t amount_t::precision() const
{ {
if (! quantity) if (! quantity)
throw_(amount_error, throw_(amount_error,
"Cannot determine precision of an uninitialized amount"); _("Cannot determine precision of an uninitialized amount"));
return quantity->prec; return quantity->prec;
} }
@ -402,7 +400,7 @@ bool amount_t::keep_precision() const
{ {
if (! quantity) if (! quantity)
throw_(amount_error, throw_(amount_error,
"Cannot determine if precision of an uninitialized amount is kept"); _("Cannot determine if precision of an uninitialized amount is kept"));
return quantity->has_flags(BIGINT_KEEP_PREC); return quantity->has_flags(BIGINT_KEEP_PREC);
} }
@ -411,7 +409,7 @@ void amount_t::set_keep_precision(const bool keep) const
{ {
if (! quantity) if (! quantity)
throw_(amount_error, throw_(amount_error,
"Cannot set whether to keep the precision of an uninitialized amount"); _("Cannot set whether to keep the precision of an uninitialized amount"));
if (keep) if (keep)
quantity->add_flags(BIGINT_KEEP_PREC); quantity->add_flags(BIGINT_KEEP_PREC);
@ -423,7 +421,7 @@ amount_t::precision_t amount_t::display_precision() const
{ {
if (! quantity) if (! quantity)
throw_(amount_error, throw_(amount_error,
"Cannot determine display precision of an uninitialized amount"); _("Cannot determine display precision of an uninitialized amount"));
commodity_t& comm(commodity()); commodity_t& comm(commodity());
@ -441,14 +439,14 @@ void amount_t::in_place_negate()
_dup(); _dup();
mpq_neg(MP(quantity), MP(quantity)); mpq_neg(MP(quantity), MP(quantity));
} else { } else {
throw_(amount_error, "Cannot negate an uninitialized amount"); throw_(amount_error, _("Cannot negate an uninitialized amount"));
} }
} }
amount_t amount_t::inverted() const amount_t amount_t::inverted() const
{ {
if (! quantity) if (! quantity)
throw_(amount_error, "Cannot invert an uninitialized amount"); throw_(amount_error, _("Cannot invert an uninitialized amount"));
amount_t t(*this); amount_t t(*this);
t._dup(); t._dup();
@ -460,7 +458,7 @@ amount_t amount_t::inverted() const
amount_t amount_t::rounded() const amount_t amount_t::rounded() const
{ {
if (! quantity) if (! quantity)
throw_(amount_error, "Cannot set rounding for an uninitialized amount"); throw_(amount_error, _("Cannot set rounding for an uninitialized amount"));
else if (! keep_precision()) else if (! keep_precision())
return *this; return *this;
@ -474,7 +472,7 @@ amount_t amount_t::rounded() const
amount_t amount_t::unrounded() const amount_t amount_t::unrounded() const
{ {
if (! quantity) if (! quantity)
throw_(amount_error, "Cannot unround an uninitialized amount"); throw_(amount_error, _("Cannot unround an uninitialized amount"));
else if (keep_precision()) else if (keep_precision())
return *this; return *this;
@ -488,7 +486,7 @@ amount_t amount_t::unrounded() const
void amount_t::in_place_reduce() void amount_t::in_place_reduce()
{ {
if (! quantity) if (! quantity)
throw_(amount_error, "Cannot reduce an uninitialized amount"); throw_(amount_error, _("Cannot reduce an uninitialized amount"));
while (commodity_ && commodity().smaller()) { while (commodity_ && commodity().smaller()) {
*this *= commodity().smaller()->number(); *this *= commodity().smaller()->number();
@ -499,7 +497,7 @@ void amount_t::in_place_reduce()
void amount_t::in_place_unreduce() void amount_t::in_place_unreduce()
{ {
if (! quantity) if (! quantity)
throw_(amount_error, "Cannot unreduce an uninitialized amount"); throw_(amount_error, _("Cannot unreduce an uninitialized amount"));
amount_t temp = *this; amount_t temp = *this;
commodity_t * comm = commodity_; commodity_t * comm = commodity_;
@ -546,7 +544,7 @@ amount_t::value(const bool primary_only,
} }
} }
} else { } else {
throw_(amount_error, "Cannot determine value of an uninitialized amount"); throw_(amount_error, _("Cannot determine value of an uninitialized amount"));
} }
return none; return none;
} }
@ -555,7 +553,7 @@ amount_t::value(const bool primary_only,
int amount_t::sign() const int amount_t::sign() const
{ {
if (! quantity) if (! quantity)
throw_(amount_error, "Cannot determine sign of an uninitialized amount"); throw_(amount_error, _("Cannot determine sign of an uninitialized amount"));
return mpq_sgn(MP(quantity)); return mpq_sgn(MP(quantity));
} }
@ -654,7 +652,7 @@ namespace {
bool amount_t::is_zero() const bool amount_t::is_zero() const
{ {
if (! quantity) if (! quantity)
throw_(amount_error, "Cannot determine if an uninitialized amount is zero"); throw_(amount_error, _("Cannot determine if an uninitialized amount is zero"));
if (has_commodity()) { if (has_commodity()) {
if (keep_precision() || quantity->prec <= commodity().precision()) { if (keep_precision() || quantity->prec <= commodity().precision()) {
@ -687,7 +685,7 @@ bool amount_t::is_zero() const
double amount_t::to_double() const double amount_t::to_double() const
{ {
if (! quantity) if (! quantity)
throw_(amount_error, "Cannot convert an uninitialized amount to a double"); throw_(amount_error, _("Cannot convert an uninitialized amount to a double"));
mpfr_set_q(tempf, MP(quantity), GMP_RNDN); mpfr_set_q(tempf, MP(quantity), GMP_RNDN);
return mpfr_get_d(tempf, GMP_RNDN); return mpfr_get_d(tempf, GMP_RNDN);
@ -696,7 +694,7 @@ double amount_t::to_double() const
long amount_t::to_long() const long amount_t::to_long() const
{ {
if (! quantity) if (! quantity)
throw_(amount_error, "Cannot convert an uninitialized amount to a long"); throw_(amount_error, _("Cannot convert an uninitialized amount to a long"));
mpfr_set_q(tempf, MP(quantity), GMP_RNDN); mpfr_set_q(tempf, MP(quantity), GMP_RNDN);
return mpfr_get_si(tempf, GMP_RNDN); return mpfr_get_si(tempf, GMP_RNDN);
@ -724,9 +722,9 @@ void amount_t::annotate(const annotation_t& details)
annotated_commodity_t * this_ann = NULL; annotated_commodity_t * this_ann = NULL;
if (! quantity) if (! quantity)
throw_(amount_error, "Cannot annotate the commodity of an uninitialized amount"); throw_(amount_error, _("Cannot annotate the commodity of an uninitialized amount"));
else if (! has_commodity()) else if (! has_commodity())
throw_(amount_error, "Cannot annotate an amount with no commodity"); throw_(amount_error, _("Cannot annotate an amount with no commodity"));
if (commodity().annotated) { if (commodity().annotated) {
this_ann = &as_annotated_commodity(commodity()); this_ann = &as_annotated_commodity(commodity());
@ -754,7 +752,7 @@ bool amount_t::is_annotated() const
{ {
if (! quantity) if (! quantity)
throw_(amount_error, throw_(amount_error,
"Cannot determine if an uninitialized amount's commodity is annotated"); _("Cannot determine if an uninitialized amount's commodity is annotated"));
assert(! commodity().annotated || as_annotated_commodity(commodity()).details); assert(! commodity().annotated || as_annotated_commodity(commodity()).details);
return commodity().annotated; return commodity().annotated;
@ -764,11 +762,11 @@ annotation_t& amount_t::annotation()
{ {
if (! quantity) if (! quantity)
throw_(amount_error, throw_(amount_error,
"Cannot return commodity annotation details of an uninitialized amount"); _("Cannot return commodity annotation details of an uninitialized amount"));
if (! commodity().is_annotated()) if (! commodity().is_annotated())
throw_(amount_error, throw_(amount_error,
"Request for annotation details from an unannotated amount"); _("Request for annotation details from an unannotated amount"));
annotated_commodity_t& ann_comm(as_annotated_commodity(commodity())); annotated_commodity_t& ann_comm(as_annotated_commodity(commodity()));
return ann_comm.details; return ann_comm.details;
@ -778,7 +776,7 @@ amount_t amount_t::strip_annotations(const keep_details_t& what_to_keep) const
{ {
if (! quantity) if (! quantity)
throw_(amount_error, throw_(amount_error,
"Cannot strip commodity annotations from an uninitialized amount"); _("Cannot strip commodity annotations from an uninitialized amount"));
if (! what_to_keep.keep_all(commodity())) { if (! what_to_keep.keep_all(commodity())) {
amount_t t(*this); amount_t t(*this);
@ -862,7 +860,7 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags)
if (flags.has_flags(PARSE_SOFT_FAIL)) if (flags.has_flags(PARSE_SOFT_FAIL))
return false; return false;
else else
throw_(amount_error, "No quantity specified for amount"); throw_(amount_error, _("No quantity specified for amount"));
} }
// Allocate memory for the amount's quantity value. We have to // Allocate memory for the amount's quantity value. We have to

View file

@ -45,7 +45,7 @@ balance_t& balance_t::operator+=(const amount_t& amt)
{ {
if (amt.is_null()) if (amt.is_null())
throw_(balance_error, throw_(balance_error,
"Cannot add an uninitialized amount to a balance"); _("Cannot add an uninitialized amount to a balance"));
if (amt.is_realzero()) if (amt.is_realzero())
return *this; return *this;
@ -70,7 +70,7 @@ balance_t& balance_t::operator-=(const amount_t& amt)
{ {
if (amt.is_null()) if (amt.is_null())
throw_(balance_error, throw_(balance_error,
"Cannot subtract an uninitialized amount from a balance"); _("Cannot subtract an uninitialized amount from a balance"));
if (amt.is_realzero()) if (amt.is_realzero())
return *this; return *this;
@ -90,7 +90,7 @@ balance_t& balance_t::operator*=(const amount_t& amt)
{ {
if (amt.is_null()) if (amt.is_null())
throw_(balance_error, throw_(balance_error,
"Cannot multiply a balance by an uninitialized amount"); _("Cannot multiply a balance by an uninitialized amount"));
if (is_realzero()) { if (is_realzero()) {
; ;
@ -112,12 +112,12 @@ balance_t& balance_t::operator*=(const amount_t& amt)
amounts.begin()->second *= amt; amounts.begin()->second *= amt;
else else
throw_(balance_error, throw_(balance_error,
"Cannot multiply a balance with annotated commodities by a commoditized amount"); _("Cannot multiply a balance with annotated commodities by a commoditized amount"));
} }
else { else {
assert(amounts.size() > 1); assert(amounts.size() > 1);
throw_(balance_error, throw_(balance_error,
"Cannot multiply a multi-commodity balance by a commoditized amount"); _("Cannot multiply a multi-commodity balance by a commoditized amount"));
} }
return *this; return *this;
} }
@ -126,13 +126,13 @@ balance_t& balance_t::operator/=(const amount_t& amt)
{ {
if (amt.is_null()) if (amt.is_null())
throw_(balance_error, throw_(balance_error,
"Cannot divide a balance by an uninitialized amount"); _("Cannot divide a balance by an uninitialized amount"));
if (is_realzero()) { if (is_realzero()) {
; ;
} }
else if (amt.is_realzero()) { else if (amt.is_realzero()) {
throw_(balance_error, "Divide by zero"); throw_(balance_error, _("Divide by zero"));
} }
else if (! amt.commodity()) { else if (! amt.commodity()) {
// Dividing by an amount with no commodity causes all the // Dividing by an amount with no commodity causes all the
@ -148,12 +148,12 @@ balance_t& balance_t::operator/=(const amount_t& amt)
amounts.begin()->second /= amt; amounts.begin()->second /= amt;
else else
throw_(balance_error, throw_(balance_error,
"Cannot divide a balance with annotated commodities by a commoditized amount"); _("Cannot divide a balance with annotated commodities by a commoditized amount"));
} }
else { else {
assert(amounts.size() > 1); assert(amounts.size() > 1);
throw_(balance_error, throw_(balance_error,
"Cannot divide a multi-commodity balance by a commoditized amount"); _("Cannot divide a multi-commodity balance by a commoditized amount"));
} }
return *this; return *this;
} }
@ -193,7 +193,7 @@ balance_t::commodity_amount(const optional<const commodity_t&>& commodity) const
return temp.commodity_amount(commodity); return temp.commodity_amount(commodity);
throw_(amount_error, throw_(amount_error,
"Requested amount of a balance with multiple commodities: " << temp); _("Requested amount of a balance with multiple commodities: %1") << temp);
} }
#endif #endif
} }

View file

@ -111,7 +111,7 @@ public:
TRACE_CTOR(balance_t, "const amount_t&"); TRACE_CTOR(balance_t, "const amount_t&");
if (amt.is_null()) if (amt.is_null())
throw_(balance_error, throw_(balance_error,
"Cannot initialize a balance from an uninitialized amount"); _("Cannot initialize a balance from an uninitialized amount"));
if (! amt.is_realzero()) if (! amt.is_realzero())
amounts.insert(amounts_map::value_type(&amt.commodity(), amt)); amounts.insert(amounts_map::value_type(&amt.commodity(), amt));
} }
@ -165,7 +165,7 @@ public:
balance_t& operator=(const amount_t& amt) { balance_t& operator=(const amount_t& amt) {
if (amt.is_null()) if (amt.is_null())
throw_(balance_error, throw_(balance_error,
"Cannot assign an uninitialized amount to a balance"); _("Cannot assign an uninitialized amount to a balance"));
amounts.clear(); amounts.clear();
if (! amt.is_realzero()) if (! amt.is_realzero())
@ -209,7 +209,7 @@ public:
bool operator==(const amount_t& amt) const { bool operator==(const amount_t& amt) const {
if (amt.is_null()) if (amt.is_null())
throw_(balance_error, throw_(balance_error,
"Cannot compare a balance to an uninitialized amount"); _("Cannot compare a balance to an uninitialized amount"));
if (amt.is_realzero()) if (amt.is_realzero())
return amounts.empty(); return amounts.empty();
@ -413,12 +413,12 @@ public:
*/ */
amount_t to_amount() const { amount_t to_amount() const {
if (is_empty()) if (is_empty())
throw_(balance_error, "Cannot convert an empty balance to an amount"); throw_(balance_error, _("Cannot convert an empty balance to an amount"));
else if (amounts.size() == 1) else if (amounts.size() == 1)
return amounts.begin()->second; return amounts.begin()->second;
else else
throw_(balance_error, throw_(balance_error,
"Cannot convert a balance with multiple commodities to an amount"); _("Cannot convert a balance with multiple commodities to an amount"));
} }
/** /**

View file

@ -365,7 +365,7 @@ optional<commodity_t::base_t::history_t&>
#if 0 #if 0
// jww (2008-09-20): Document which option switch to use here // jww (2008-09-20): Document which option switch to use here
throw_(commodity_error, throw_(commodity_error,
"Cannot determine price history: prices known for multiple commodities (use -?)"); _("Cannot determine price history: prices known for multiple commodities (use -x)"));
#endif #endif
comm = (*histories.begin()).first; comm = (*histories.begin()).first;
} else { } else {
@ -515,7 +515,7 @@ void commodity_t::parse_symbol(std::istream& in, string& symbol)
if (c == '"') if (c == '"')
in.get(c); in.get(c);
else else
throw_(amount_error, "Quoted commodity symbol lacks closing quote"); throw_(amount_error, _("Quoted commodity symbol lacks closing quote"));
} else { } else {
char * _p = buf; char * _p = buf;
c = in.peek(); c = in.peek();
@ -582,7 +582,7 @@ void commodity_t::parse_symbol(char *& p, string& symbol)
if (*p == '"') { if (*p == '"') {
char * q = std::strchr(p + 1, '"'); char * q = std::strchr(p + 1, '"');
if (! q) if (! q)
throw_(amount_error, "Quoted commodity symbol lacks closing quote"); throw_(amount_error, _("Quoted commodity symbol lacks closing quote"));
symbol = string(p + 1, 0, q - p - 1); symbol = string(p + 1, 0, q - p - 1);
p = q + 2; p = q + 2;
} else { } else {
@ -594,7 +594,7 @@ void commodity_t::parse_symbol(char *& p, string& symbol)
p += symbol.length(); p += symbol.length();
} }
if (symbol.empty()) if (symbol.empty())
throw_(amount_error, "Failed to parse commodity"); throw_(amount_error, _("Failed to parse commodity"));
} }
bool commodity_t::valid() const bool commodity_t::valid() const
@ -627,14 +627,14 @@ void annotation_t::parse(std::istream& in)
char c = peek_next_nonws(in); char c = peek_next_nonws(in);
if (c == '{') { if (c == '{') {
if (price) if (price)
throw_(amount_error, "Commodity specifies more than one price"); throw_(amount_error, _("Commodity specifies more than one price"));
in.get(c); in.get(c);
READ_INTO(in, buf, 255, c, c != '}'); READ_INTO(in, buf, 255, c, c != '}');
if (c == '}') if (c == '}')
in.get(c); in.get(c);
else else
throw_(amount_error, "Commodity price lacks closing brace"); throw_(amount_error, _("Commodity price lacks closing brace"));
amount_t temp; amount_t temp;
temp.parse(buf, amount_t::PARSE_NO_MIGRATE); temp.parse(buf, amount_t::PARSE_NO_MIGRATE);
@ -653,27 +653,27 @@ void annotation_t::parse(std::istream& in)
} }
else if (c == '[') { else if (c == '[') {
if (date) if (date)
throw_(amount_error, "Commodity specifies more than one date"); throw_(amount_error, _("Commodity specifies more than one date"));
in.get(c); in.get(c);
READ_INTO(in, buf, 255, c, c != ']'); READ_INTO(in, buf, 255, c, c != ']');
if (c == ']') if (c == ']')
in.get(c); in.get(c);
else else
throw_(amount_error, "Commodity date lacks closing bracket"); throw_(amount_error, _("Commodity date lacks closing bracket"));
date = parse_date(buf); date = parse_date(buf);
} }
else if (c == '(') { else if (c == '(') {
if (tag) if (tag)
throw_(amount_error, "Commodity specifies more than one tag"); throw_(amount_error, _("Commodity specifies more than one tag"));
in.get(c); in.get(c);
READ_INTO(in, buf, 255, c, c != ')'); READ_INTO(in, buf, 255, c, c != ')');
if (c == ')') if (c == ')')
in.get(c); in.get(c);
else else
throw_(amount_error, "Commodity tag lacks closing parenthesis"); throw_(amount_error, _("Commodity tag lacks closing parenthesis"));
tag = buf; tag = buf;
} }
@ -895,7 +895,7 @@ namespace {
assert(details); assert(details);
if (details.price && details.price->sign() < 0) if (details.price && details.price->sign() < 0)
throw_(amount_error, "A commodity's price may not be negative"); throw_(amount_error, _("A commodity's price may not be negative"));
std::ostringstream name; std::ostringstream name;
comm.print(name); comm.print(name);

View file

@ -57,7 +57,7 @@ namespace {
if (sort_values.back().value.is_null()) if (sort_values.back().value.is_null())
throw_(calc_error, throw_(calc_error,
"Could not determine sorting value based an expression"); _("Could not determine sorting value based an expression"));
} }
} }
} }

View file

@ -58,27 +58,27 @@ namespace {
void dump(std::ostream& out) const void dump(std::ostream& out) const
{ {
if (date) if (date)
out << "Date: " << *date << std::endl; out << _("Date: ") << *date << std::endl;
else else
out << "Date: <today>" << std::endl; out << _("Date: <today>") << std::endl;
if (eff_date) if (eff_date)
out << "Effective: " << *eff_date << std::endl; out << _("Effective: ") << *eff_date << std::endl;
if (code) if (code)
out << "Code: " << *code << std::endl; out << _("Code: ") << *code << std::endl;
if (note) if (note)
out << "Note: " << *note << std::endl; out << _("Note: ") << *note << std::endl;
if (payee_mask.empty()) if (payee_mask.empty())
out << "Payee mask: INVALID (template expression will cause an error)" out << _("Payee mask: INVALID (template expression will cause an error)")
<< std::endl; << std::endl;
else else
out << "Payee mask: " << payee_mask << std::endl; out << _("Payee mask: ") << payee_mask << std::endl;
if (posts.empty()) { if (posts.empty()) {
out << std::endl out << std::endl
<< "<Posting copied from last related transaction>" << _("<Posting copied from last related transaction>")
<< std::endl; << std::endl;
} else { } else {
bool has_only_from = true; bool has_only_from = true;
@ -92,19 +92,21 @@ namespace {
} }
foreach (const post_template_t& post, posts) { foreach (const post_template_t& post, posts) {
straccstream accum;
out << std::endl out << std::endl
<< "[Posting \"" << (post.from ? "from" : "to") << ACCUM(accum << _("[Posting \"%1\"]_")
<< "\"]" << std::endl; << (post.from ? _("from") : _("to")))
<< std::endl;
if (post.account_mask) if (post.account_mask)
out << " Account mask: " << *post.account_mask << std::endl; out << _(" Account mask: ") << *post.account_mask << std::endl;
else if (post.from) else if (post.from)
out << " Account mask: <use last of last related accounts>" << std::endl; out << _(" Account mask: <use last of last related accounts>") << std::endl;
else else
out << " Account mask: <use first of last related accounts>" << std::endl; out << _(" Account mask: <use first of last related accounts>") << std::endl;
if (post.amount) if (post.amount)
out << " Amount: " << *post.amount << std::endl; out << _(" Amount: ") << *post.amount << std::endl;
} }
} }
} }
@ -114,8 +116,8 @@ namespace {
args_to_xact_template(value_t::sequence_t::const_iterator begin, args_to_xact_template(value_t::sequence_t::const_iterator begin,
value_t::sequence_t::const_iterator end) value_t::sequence_t::const_iterator end)
{ {
regex date_mask("([0-9]+(?:[-/.][0-9]+)?(?:[-/.][0-9]+))?(?:=.*)?"); regex date_mask(_("([0-9]+(?:[-/.][0-9]+)?(?:[-/.][0-9]+))?(?:=.*)?"));
regex dow_mask("(sun|mon|tue|wed|thu|fri|sat)"); regex dow_mask(_("(sun|mon|tue|wed|thu|fri|sat)"));
smatch what; smatch what;
xact_template_t tmpl; xact_template_t tmpl;
@ -236,7 +238,7 @@ namespace {
report_t& report) report_t& report)
{ {
if (tmpl.payee_mask.empty()) if (tmpl.payee_mask.empty())
throw std::runtime_error("'xact' command requires at least a payee"); throw std::runtime_error(_("'xact' command requires at least a payee"));
xact_t * matching = NULL; xact_t * matching = NULL;
journal_t& journal(*report.session.journal.get()); journal_t& journal(*report.session.journal.get());
@ -281,8 +283,8 @@ namespace {
added->add_post(new post_t(*post)); added->add_post(new post_t(*post));
} else { } else {
throw_(std::runtime_error, throw_(std::runtime_error,
"No accounts, and no past transaction matching '" _("No accounts, and no past transaction matching '%1'")
<< tmpl.payee_mask <<"'"); << tmpl.payee_mask);
} }
} else { } else {
bool any_post_has_amount = false; bool any_post_has_amount = false;
@ -346,9 +348,9 @@ namespace {
} else { } else {
if (post.from) if (post.from)
new_post->account = journal.find_account("Liabilities:Unknown"); new_post->account = journal.find_account(_("Liabilities:Unknown"));
else else
new_post->account = journal.find_account("Expenses:Unknown"); new_post->account = journal.find_account(_("Expenses:Unknown"));
} }
} }
@ -382,7 +384,7 @@ namespace {
! added->finalize() || ! added->finalize() ||
! journal.xact_finalize_hooks.run_hooks(*added.get(), true)) ! journal.xact_finalize_hooks.run_hooks(*added.get(), true))
throw_(std::runtime_error, throw_(std::runtime_error,
"Failed to finalize derived transaction (check commodities)"); _("Failed to finalize derived transaction (check commodities)"));
return added.release(); return added.release();
} }
@ -396,13 +398,13 @@ value_t template_command(call_scope_t& args)
value_t::sequence_t::const_iterator begin = args.value().begin(); value_t::sequence_t::const_iterator begin = args.value().begin();
value_t::sequence_t::const_iterator end = args.value().end(); value_t::sequence_t::const_iterator end = args.value().end();
out << "--- Input arguments ---" << std::endl; out << _("--- Input arguments ---") << std::endl;
args.value().dump(out); args.value().dump(out);
out << std::endl << std::endl; out << std::endl << std::endl;
xact_template_t tmpl = args_to_xact_template(begin, end); xact_template_t tmpl = args_to_xact_template(begin, end);
out << "--- Transaction template ---" << std::endl; out << _("--- Transaction template ---") << std::endl;
tmpl.dump(out); tmpl.dump(out);
return true; return true;

View file

@ -145,7 +145,7 @@ value_t expr_t::calc(scope_t& scope)
} }
catch (const std::exception& err) { catch (const std::exception& err) {
if (locus) { if (locus) {
add_error_context("While evaluating value expression:"); add_error_context(_("While evaluating value expression:"));
add_error_context(op_context(ptr, locus)); add_error_context(op_context(ptr, locus));
} }
throw; throw;
@ -207,7 +207,7 @@ std::ostream& operator<<(std::ostream& out, const expr_t& expr) {
string expr_context(const expr_t& expr) string expr_context(const expr_t& expr)
{ {
return expr ? op_context(expr.ptr) : "<empty expression>"; return expr ? op_context(expr.ptr) : _("<empty expression>");
} }
} // namespace ledger } // namespace ledger

View file

@ -48,7 +48,7 @@ pass_down_posts::pass_down_posts(post_handler_ptr handler,
item_handler<post_t>::operator()(*post); item_handler<post_t>::operator()(*post);
} }
catch (const std::exception& err) { catch (const std::exception& err) {
add_error_context(item_context(*post, "While handling posting")); add_error_context(item_context(*post, _("While handling posting")));
throw; throw;
} }
} }
@ -401,7 +401,7 @@ void changed_value_posts::output_diff(post_t * post, const date_t& date)
xact_temps.push_back(xact_t()); xact_temps.push_back(xact_t());
xact_t& xact = xact_temps.back(); xact_t& xact = xact_temps.back();
xact.payee = "Commodities revalued"; xact.payee = _("Commodities revalued");
xact._date = is_valid(date) ? date : post->date(); xact._date = is_valid(date) ? date : post->date();
handle_value(diff, &revalued_account, &xact, POST_EXT_NO_TOTAL, handle_value(diff, &revalued_account, &xact, POST_EXT_NO_TOTAL,
@ -576,7 +576,7 @@ void posts_as_equity::report_subtotal()
xact_temps.push_back(xact_t()); xact_temps.push_back(xact_t());
xact_t& xact = xact_temps.back(); xact_t& xact = xact_temps.back();
xact.payee = "Opening Balances"; xact.payee = _("Opening Balances");
xact._date = finish; xact._date = finish;
value_t total = 0L; value_t total = 0L;
@ -714,7 +714,7 @@ void budget_posts::report_budget_items(const date_t& date)
xact_temps.push_back(xact_t()); xact_temps.push_back(xact_t());
xact_t& xact = xact_temps.back(); xact_t& xact = xact_temps.back();
xact.payee = "Budget transaction"; xact.payee = _("Budget transaction");
xact._date = begin; xact._date = begin;
post_temps.push_back(post); post_temps.push_back(post);
@ -802,7 +802,7 @@ void forecast_posts::flush()
xact_temps.push_back(xact_t()); xact_temps.push_back(xact_t());
xact_t& xact = xact_temps.back(); xact_t& xact = xact_temps.back();
xact.payee = "Forecast transaction"; xact.payee = _("Forecast transaction");
xact._date = begin; xact._date = begin;
post_temps.push_back(post); post_temps.push_back(post);

View file

@ -389,7 +389,7 @@ public:
display_predicate(_display_predicate), display_predicate(_display_predicate),
only_predicate(_only_predicate), count(0), only_predicate(_only_predicate), count(0),
last_xact(NULL), last_post(NULL), last_xact(NULL), last_post(NULL),
totals_account(NULL, "<Total>"), totals_account(NULL, _("<Total>")),
only_collapse_if_zero(_only_collapse_if_zero) { only_collapse_if_zero(_only_collapse_if_zero) {
TRACE_CTOR(collapse_posts, "post_handler_ptr"); TRACE_CTOR(collapse_posts, "post_handler_ptr");
} }
@ -468,7 +468,7 @@ public:
bool _changed_values_only) bool _changed_values_only)
: item_handler<post_t>(handler), total_expr(_total_expr), : item_handler<post_t>(handler), total_expr(_total_expr),
report(_report), changed_values_only(_changed_values_only), report(_report), changed_values_only(_changed_values_only),
last_post(NULL), revalued_account(NULL, "<Revalued>") { last_post(NULL), revalued_account(NULL, _("<Revalued>")) {
TRACE_CTOR(changed_value_posts, TRACE_CTOR(changed_value_posts,
"post_handler_ptr, const expr_t&, report_t&, bool"); "post_handler_ptr, const expr_t&, report_t&, bool");
} }
@ -583,7 +583,7 @@ public:
bool _exact_periods = false, bool _exact_periods = false,
bool _generate_empty_posts = false) bool _generate_empty_posts = false)
: subtotal_posts(_handler, amount_expr), interval(_interval), : subtotal_posts(_handler, amount_expr), interval(_interval),
last_post(NULL), empty_account(NULL, "<None>"), last_post(NULL), empty_account(NULL, _("<None>")),
exact_periods(_exact_periods), exact_periods(_exact_periods),
generate_empty_posts(_generate_empty_posts) { generate_empty_posts(_generate_empty_posts) {
TRACE_CTOR(interval_posts, TRACE_CTOR(interval_posts,
@ -615,9 +615,9 @@ class posts_as_equity : public subtotal_posts
public: public:
posts_as_equity(post_handler_ptr _handler, expr_t& amount_expr) posts_as_equity(post_handler_ptr _handler, expr_t& amount_expr)
: subtotal_posts(_handler, amount_expr), : subtotal_posts(_handler, amount_expr),
equity_account(NULL, "Equity") { equity_account(NULL, _("Equity")) {
TRACE_CTOR(posts_as_equity, "post_handler_ptr, expr_t&"); TRACE_CTOR(posts_as_equity, "post_handler_ptr, expr_t&");
balance_account = equity_account.find_account("Opening Balances"); balance_account = equity_account.find_account(_("Opening Balances"));
} }
virtual ~posts_as_equity() throw() { virtual ~posts_as_equity() throw() {
TRACE_DTOR(posts_as_equity); TRACE_DTOR(posts_as_equity);

View file

@ -251,7 +251,7 @@ void format_t::format(std::ostream& out_str, scope_t& scope)
value.print(out, elem->min_width); value.print(out, elem->min_width);
} }
catch (const calc_error&) { catch (const calc_error&) {
add_error_context("While calculating format expression:"); add_error_context(_("While calculating format expression:"));
add_error_context(expr_context(elem->expr)); add_error_context(expr_context(elem->expr));
throw; throw;
} }

View file

@ -102,8 +102,8 @@ void global_scope_t::read_init()
if (session().read_journal(init_file) > 0 || if (session().read_journal(init_file) > 0 ||
session().journal->auto_xacts.size() > 0 || session().journal->auto_xacts.size() > 0 ||
session().journal->period_xacts.size() > 0) { session().journal->period_xacts.size() > 0) {
throw_(parse_error, "Transactions found in initialization file '" throw_(parse_error, _("Transactions found in initialization file '%1'")
<< init_file << "'"); << init_file);
} }
TRACE_FINISH(init, 1); TRACE_FINISH(init, 1);
@ -132,7 +132,7 @@ void global_scope_t::report_error(const std::exception& err)
if (! context.empty()) if (! context.empty())
std::cerr << context << std::endl; std::cerr << context << std::endl;
std::cerr << "Error: " << err.what() << std::endl; std::cerr << _("Error: ") << err.what() << std::endl;
} else { } else {
caught_signal = NONE_CAUGHT; caught_signal = NONE_CAUGHT;
} }
@ -173,7 +173,7 @@ void global_scope_t::execute_command(strings_list args, bool at_repl)
if (bool(command = look_for_precommand(bound_scope, verb))) if (bool(command = look_for_precommand(bound_scope, verb)))
is_precommand = true; is_precommand = true;
else if (! bool(command = look_for_command(bound_scope, verb))) else if (! bool(command = look_for_command(bound_scope, verb)))
throw_(std::logic_error, "Unrecognized command '" << verb << "'"); throw_(std::logic_error, _("Unrecognized command '%1'") << verb);
// If it is not a pre-command, then parse the user's ledger data at this // If it is not a pre-command, then parse the user's ledger data at this
// time if not done alreday (i.e., if not at a REPL). Then patch up the // time if not done alreday (i.e., if not at a REPL). Then patch up the
@ -471,7 +471,7 @@ void global_scope_t::visit_man_page() const
{ {
int pid = fork(); int pid = fork();
if (pid < 0) { if (pid < 0) {
throw std::logic_error("Failed to fork child process"); throw std::logic_error(_("Failed to fork child process"));
} }
else if (pid == 0) { // child else if (pid == 0) { // child
execlp("man", "man", "1", "ledger", (char *)0); execlp("man", "man", "1", "ledger", (char *)0);
@ -516,7 +516,7 @@ void handle_debug_options(int argc, char * argv[])
_trace_level = boost::lexical_cast<int>(argv[i + 1]); _trace_level = boost::lexical_cast<int>(argv[i + 1]);
} }
catch (const boost::bad_lexical_cast& e) { catch (const boost::bad_lexical_cast& e) {
throw std::logic_error("Argument to --trace must be an integer"); throw std::logic_error(_("Argument to --trace must be an integer"));
} }
i++; i++;
#endif #endif

View file

@ -100,11 +100,11 @@ public:
void show_version_info(std::ostream& out) { void show_version_info(std::ostream& out) {
out << out <<
"Ledger " << ledger::version << ", the command-line accounting tool"; "Ledger " << ledger::version << _(", the command-line accounting tool");
out << out <<
"\n\nCopyright (c) 2003-2009, John Wiegley. All rights reserved.\n\n\ _("\n\nCopyright (c) 2003-2009, John Wiegley. All rights reserved.\n\n\
This program is made available under the terms of the BSD Public License.\n\ This program is made available under the terms of the BSD Public License.\n\
See LICENSE file included with the distribution for details and disclaimer."; See LICENSE file included with the distribution for details and disclaimer.");
out << std::endl; out << std::endl;
} }

View file

@ -38,7 +38,7 @@ void interactive_t::verify_arguments() const
value_t::sequence_t::const_iterator i; value_t::sequence_t::const_iterator i;
const char * p = spec.c_str(); const char * p = spec.c_str();
const char * label = "unknown"; const char * label = _("unknown");
bool wrong_arg = false; bool wrong_arg = false;
bool dont_skip = false; bool dont_skip = false;
bool optional = *p == '&'; bool optional = *p == '&';
@ -62,22 +62,22 @@ void interactive_t::verify_arguments() const
"Want " << *p << " got: " << next_arg->label()); "Want " << *p << " got: " << next_arg->label());
switch (*p) { switch (*p) {
case 'a': case 'a':
label = "an amount"; label = _("an amount");
wrong_arg = (! next_arg->is_long() && wrong_arg = (! next_arg->is_long() &&
! next_arg->is_amount() && ! next_arg->is_amount() &&
! next_arg->is_balance()); ! next_arg->is_balance());
break; break;
case 'b': case 'b':
label = "a boolean"; label = _("a boolean");
wrong_arg = false; // booleans are converted wrong_arg = false; // booleans are converted
break; break;
case 'd': case 'd':
label = "a date"; label = _("a date");
wrong_arg = ! next_arg->is_date(); wrong_arg = ! next_arg->is_date();
break; break;
case 'i': case 'i':
case 'l': case 'l':
label = "an integer"; label = _("an integer");
if (next_arg->is_long() || if (next_arg->is_long() ||
(next_arg->is_amount() && (next_arg->is_amount() &&
! next_arg->as_amount().has_commodity())) { ! next_arg->as_amount().has_commodity())) {
@ -97,28 +97,28 @@ void interactive_t::verify_arguments() const
} }
break; break;
case 'm': case 'm':
label = "a regex"; label = _("a regex");
wrong_arg = ! next_arg->is_mask(); wrong_arg = ! next_arg->is_mask();
break; break;
case 's': case 's':
label = "a string"; label = _("a string");
wrong_arg = ! next_arg->is_string(); wrong_arg = ! next_arg->is_string();
break; break;
case 't': case 't':
label = "a date or time"; label = _("a date or time");
wrong_arg = (! next_arg->is_date() && wrong_arg = (! next_arg->is_date() &&
! next_arg->is_datetime()); ! next_arg->is_datetime());
break; break;
case 'v': case 'v':
label = "any value"; label = _("any value");
wrong_arg = false; wrong_arg = false;
break; break;
case 'P': case 'P':
label = "a pointer"; label = _("a pointer");
wrong_arg = ! next_arg->is_pointer(); wrong_arg = ! next_arg->is_pointer();
break; break;
case 'S': case 'S':
label = "a sequence"; label = _("a sequence");
wrong_arg = false; wrong_arg = false;
break; break;
case '&': case '&':
@ -157,14 +157,14 @@ void interactive_t::verify_arguments() const
if (wrong_arg) { if (wrong_arg) {
throw_(std::logic_error, throw_(std::logic_error,
"Expected " << label << " for argument " << offset _("Expected %1 for argument %2, but received %3")
<< ", but received " << vlabel); << label << offset << vlabel);
} }
else if (*p && ! optional && ! next_arg) { else if (*p && ! optional && ! next_arg) {
throw_(std::logic_error, "Too few arguments to function"); throw_(std::logic_error, _("Too few arguments to function"));
} }
else if (! *p && next_arg) { else if (! *p && next_arg) {
throw_(std::logic_error, "Too many arguments to function"); throw_(std::logic_error, _("Too many arguments to function"));
} }
} }

View file

@ -397,7 +397,7 @@ string item_context(const item_t& item, const string& desc)
{ {
std::size_t len = item.end_pos - item.beg_pos; std::size_t len = item.end_pos - item.beg_pos;
if (! len) if (! len)
return "<no item context>"; return _("<no item context>");
assert(len > 0); assert(len > 0);
assert(len < 2048); assert(len < 2048);
@ -405,17 +405,17 @@ string item_context(const item_t& item, const string& desc)
std::ostringstream out; std::ostringstream out;
if (item.pathname == path("/dev/stdin")) { if (item.pathname == path("/dev/stdin")) {
out << desc << " from standard input:"; out << desc << _(" from standard input:");
return out.str(); return out.str();
} }
out << desc << " from \"" << item.pathname.string() << "\""; out << desc << _(" from \"") << item.pathname.string() << "\"";
if (item.beg_line != item.end_line) if (item.beg_line != item.end_line)
out << ", lines " << item.beg_line << "-" out << _(", lines ") << item.beg_line << "-"
<< item.end_line << ":\n"; << item.end_line << ":\n";
else else
out << ", line " << item.beg_line << ":\n"; out << _(", line ") << item.beg_line << ":\n";
print_item(out, item, "> "); print_item(out, item, "> ");

View file

@ -144,7 +144,7 @@ int main(int argc, char * argv[], char * envp[])
std::free(expansion); std::free(expansion);
std::free(p); std::free(p);
throw_(std::logic_error, throw_(std::logic_error,
"Failed to expand history reference '" << p << "'"); _("Failed to expand history reference '%1'") << p);
} }
else if (expansion) { else if (expansion) {
add_history(expansion); add_history(expansion);

View file

@ -67,10 +67,10 @@ expr_t::ptr_op_t expr_t::op_t::compile(scope_t& scope)
if (left()->left()->is_ident()) if (left()->left()->is_ident())
scope.define(left()->left()->as_ident(), this); scope.define(left()->left()->as_ident(), this);
else else
throw_(compile_error, "Invalid function definition"); throw_(compile_error, _("Invalid function definition"));
break; break;
default: default:
throw_(compile_error, "Invalid function definition"); throw_(compile_error, _("Invalid function definition"));
} }
return wrap_value(value_t()); return wrap_value(value_t());
} }
@ -106,7 +106,7 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus)
case IDENT: { case IDENT: {
if (! left()) if (! left())
throw_(calc_error, "Unknown identifier '" << as_ident() << "'"); throw_(calc_error, _("Unknown identifier '%1'") << as_ident());
// Evaluating an identifier is the same as calling its definition // Evaluating an identifier is the same as calling its definition
// directly, so we create an empty call_scope_t to reflect the scope for // directly, so we create an empty call_scope_t to reflect the scope for
@ -141,7 +141,7 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus)
varname = sym->left(); varname = sym->left();
if (! varname->is_ident()) if (! varname->is_ident())
throw_(calc_error, "Invalid function definition"); throw_(calc_error, _("Invalid function definition"));
else if (args_index == args_count) else if (args_index == args_count)
local_scope.define(varname->as_ident(), wrap_value(false)); local_scope.define(varname->as_ident(), wrap_value(false));
else else
@ -151,7 +151,7 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus)
if (args_index < args_count) if (args_index < args_count)
throw_(calc_error, throw_(calc_error,
"Too many arguments in function call (saw " << args_count << ")"); _("Too many arguments in function call (saw %1)") << args_count);
result = right()->compile(local_scope)->calc(local_scope, locus); result = right()->compile(local_scope)->calc(local_scope, locus);
break; break;
@ -173,10 +173,10 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus)
} }
if (right()->kind != IDENT) if (right()->kind != IDENT)
throw_(calc_error, throw_(calc_error,
"Right operand of . operator must be an identifier"); _("Right operand of . operator must be an identifier"));
else else
throw_(calc_error, throw_(calc_error,
"Failed to lookup member '" << right()->as_ident() << "'"); _("Failed to lookup member '%1'") << right()->as_ident());
break; break;
case O_CALL: { case O_CALL: {
@ -190,7 +190,7 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus)
func = func->left(); func = func->left();
if (! func) if (! func)
throw_(calc_error, "Calling unknown function '" << name << "'"); throw_(calc_error, _("Calling unknown function '%1'") << name);
if (func->is_function()) if (func->is_function())
result = func->as_function()(call_args); result = func->as_function()(call_args);

View file

@ -86,11 +86,10 @@ namespace {
} }
catch (const std::exception& err) { catch (const std::exception& err) {
if (name[0] == '-') if (name[0] == '-')
add_error_context("While parsing option '" << name << "':"); add_error_context(_("While parsing option '%1'") << name);
else else
add_error_context("While parsing environent variable '" add_error_context(_("While parsing environent variable '%1'") << name);
<< name << "':");
throw; throw;
} }
} }
@ -131,8 +130,8 @@ void process_environment(const char ** envp, const string& tag,
process_option(string(buf), scope, q + 1, value); process_option(string(buf), scope, q + 1, value);
} }
catch (const std::exception& err) { catch (const std::exception& err) {
add_error_context("While parsing environment variable option '" add_error_context(_("While parsing environment variable option '%1':")
<< *p << "':"); << *p);
throw; throw;
} }
} }
@ -192,19 +191,19 @@ strings_list process_arguments(strings_list args, scope_t& scope)
op_bool_tuple opt(find_option(scope, opt_name)); op_bool_tuple opt(find_option(scope, opt_name));
if (! opt.first) if (! opt.first)
throw_(option_error, "Illegal option --" << name); throw_(option_error, _("Illegal option --%1") << name);
if (opt.second && ! value && ++i != args.end() && value == NULL) { if (opt.second && ! value && ++i != args.end() && value == NULL) {
value = (*i).c_str(); value = (*i).c_str();
DEBUG("option.args", " read option value from arg: " << value); DEBUG("option.args", " read option value from arg: " << value);
if (value == NULL) if (value == NULL)
throw_(option_error, "Missing option argument for --" << name); throw_(option_error, _("Missing option argument for --%1") << name);
} }
process_option(opt.first->as_function(), scope, value, process_option(opt.first->as_function(), scope, value,
string("--") + name); string("--") + name);
} }
else if ((*i)[1] == '\0') { else if ((*i)[1] == '\0') {
throw_(option_error, "illegal option -"); throw_(option_error, _("illegal option -%1") << (*i)[0]);
} }
else { else {
DEBUG("option.args", " single-char option"); DEBUG("option.args", " single-char option");
@ -215,7 +214,7 @@ strings_list process_arguments(strings_list args, scope_t& scope)
for (char c = (*i)[x]; c != '\0'; x++, c = (*i)[x]) { for (char c = (*i)[x]; c != '\0'; x++, c = (*i)[x]) {
op_bool_tuple opt(find_option(scope, c)); op_bool_tuple opt(find_option(scope, c));
if (! opt.first) if (! opt.first)
throw_(option_error, "Illegal option -" << c); throw_(option_error, _("Illegal option -%1") << c);
option_queue.push_back(op_bool_char_tuple(opt.first, opt.second, c)); option_queue.push_back(op_bool_char_tuple(opt.first, opt.second, c));
} }
@ -227,7 +226,7 @@ strings_list process_arguments(strings_list args, scope_t& scope)
DEBUG("option.args", " read option value from arg: " << value); DEBUG("option.args", " read option value from arg: " << value);
if (value == NULL) if (value == NULL)
throw_(option_error, throw_(option_error,
"Missing option argument for -" << o.ch); _("Missing option argument for -%1") << o.ch);
} }
process_option(o.op->as_function(), scope, value, string("-") + o.ch); process_option(o.op->as_function(), scope, value, string("-") + o.ch);
} }

View file

@ -104,10 +104,6 @@ public:
return out.str(); return out.str();
} }
virtual void help(std::ostream& out) {
out << "No help for " << desc() << "\n";
}
operator bool() const { operator bool() const {
return handled; return handled;
} }
@ -115,7 +111,7 @@ public:
string& str() { string& str() {
assert(handled); assert(handled);
if (! value) if (! value)
throw_(std::runtime_error, "No argument provided for " << desc()); throw_(std::runtime_error, _("No argument provided for %1") << desc());
return value.as_string_lval(); return value.as_string_lval();
} }
@ -140,7 +136,7 @@ public:
virtual void handler(call_scope_t& args) { virtual void handler(call_scope_t& args) {
if (wants_arg) { if (wants_arg) {
if (args.empty()) if (args.empty())
throw_(std::runtime_error, "No argument provided for " << desc()); throw_(std::runtime_error, _("No argument provided for %1") << desc());
on_with(args[0]); on_with(args[0]);
} else { } else {
on_only(); on_only();
@ -179,7 +175,6 @@ public:
vartype var ; \ vartype var ; \
name ## _option_t() : option_t<type>(#name), var(value) name ## _option_t() : option_t<type>(#name), var(value)
#define HELP(var) virtual void help(std::ostream& var)
#define DO() virtual void handler_thunk(call_scope_t&) #define DO() virtual void handler_thunk(call_scope_t&)
#define DO_(var) virtual void handler_thunk(call_scope_t& var) #define DO_(var) virtual void handler_thunk(call_scope_t& var)

View file

@ -105,53 +105,56 @@ void gather_statistics::flush()
{ {
std::ostream& out(report.output_stream); std::ostream& out(report.output_stream);
out << "Time period: " << statistics.earliest_post << " to " {
<< statistics.latest_post << std::endl << std::endl; straccstream accum;
out << ACCUM(accum << "Time period: %1 to %2" << statistics.earliest_post
<< statistics.latest_post) << std::endl << std::endl;
}
out << " Files these postings came from:" << std::endl; out << _(" Files these postings came from:") << std::endl;
foreach (const path& pathname, statistics.filenames) foreach (const path& pathname, statistics.filenames)
if (! pathname.empty()) if (! pathname.empty())
out << " " << pathname.string() << std::endl; out << " " << pathname.string() << std::endl;
out << std::endl; out << std::endl;
out << " Unique payees: "; out << _(" Unique payees: ");
out.width(8); out.width(8);
out << std::right << statistics.payees_referenced.size() << std::endl; out << std::right << statistics.payees_referenced.size() << std::endl;
out << " Unique accounts: "; out << _(" Unique accounts: ");
out.width(8); out.width(8);
out << std::right << statistics.accounts_referenced.size() << std::endl; out << std::right << statistics.accounts_referenced.size() << std::endl;
out << " Number of transactions: " ; out << _(" Number of transactions: ") ;
out.width(8); out.width(8);
out << std::right << statistics.total_xacts << std::endl; out << std::right << statistics.total_xacts << std::endl;
out << " Number of postings: "; out << _(" Number of postings: ");
out.width(8); out.width(8);
out << std::right << statistics.total_posts; out << std::right << statistics.total_posts;
out << " ("; out << " (";
out.precision(2); out.precision(2);
out << (double((statistics.latest_post - statistics.earliest_post).days()) / out << (double((statistics.latest_post - statistics.earliest_post).days()) /
double(statistics.total_posts)) << " per day)" << std::endl; double(statistics.total_posts)) << _(" per day)") << std::endl;
out << " Days since last post: "; out << _(" Days since last post: ");
out.width(8); out.width(8);
out << std::right << (CURRENT_DATE() - statistics.latest_post).days() out << std::right << (CURRENT_DATE() - statistics.latest_post).days()
<< std::endl; << std::endl;
out << " Posts in last 7 days: "; out << _(" Posts in last 7 days: ");
out.width(8); out.width(8);
out << std::right << statistics.total_last_7_days << std::endl; out << std::right << statistics.total_last_7_days << std::endl;
out << " Posts in last 30 days: "; out << _(" Posts in last 30 days: ");
out.width(8); out.width(8);
out << std::right << statistics.total_last_30_days << std::endl; out << std::right << statistics.total_last_30_days << std::endl;
out << " Posts seen this month: "; out << _(" Posts seen this month: ");
out.width(8); out.width(8);
out << std::right << statistics.total_this_month << std::endl; out << std::right << statistics.total_this_month << std::endl;
out << " Uncleared postings: "; out << _(" Uncleared postings: ");
out.width(8); out.width(8);
out << std::right << statistics.total_uncleared_posts << std::endl; out << std::right << statistics.total_uncleared_posts << std::endl;

View file

@ -100,7 +100,7 @@ expr_t::parser_t::parse_dot_expr(std::istream& in,
node->set_right(parse_value_term(in, tflags)); node->set_right(parse_value_term(in, tflags));
if (! node->right()) if (! node->right())
throw_(parse_error, throw_(parse_error,
tok.symbol << " operator not followed by argument"); _("%1 operator not followed by argument") << tok.symbol);
} else { } else {
push_token(tok); push_token(tok);
break; break;
@ -124,7 +124,7 @@ expr_t::parser_t::parse_unary_expr(std::istream& in,
ptr_op_t term(parse_dot_expr(in, tflags)); ptr_op_t term(parse_dot_expr(in, tflags));
if (! term) if (! term)
throw_(parse_error, throw_(parse_error,
tok.symbol << " operator not followed by argument"); _("%1 operator not followed by argument") << tok.symbol);
// A very quick optimization // A very quick optimization
if (term->kind == op_t::VALUE) { if (term->kind == op_t::VALUE) {
@ -141,7 +141,7 @@ expr_t::parser_t::parse_unary_expr(std::istream& in,
ptr_op_t term(parse_dot_expr(in, tflags)); ptr_op_t term(parse_dot_expr(in, tflags));
if (! term) if (! term)
throw_(parse_error, throw_(parse_error,
tok.symbol << " operator not followed by argument"); _("%1 operator not followed by argument") << tok.symbol);
// A very quick optimization // A very quick optimization
if (term->kind == op_t::VALUE) { if (term->kind == op_t::VALUE) {
@ -182,7 +182,7 @@ expr_t::parser_t::parse_mul_expr(std::istream& in,
node->set_right(parse_unary_expr(in, tflags)); node->set_right(parse_unary_expr(in, tflags));
if (! node->right()) if (! node->right())
throw_(parse_error, throw_(parse_error,
tok.symbol << " operator not followed by argument"); _("%1 operator not followed by argument") << tok.symbol);
} else { } else {
push_token(tok); push_token(tok);
break; break;
@ -212,7 +212,7 @@ expr_t::parser_t::parse_add_expr(std::istream& in,
node->set_right(parse_mul_expr(in, tflags)); node->set_right(parse_mul_expr(in, tflags));
if (! node->right()) if (! node->right())
throw_(parse_error, throw_(parse_error,
tok.symbol << " operator not followed by argument"); _("%1 operator not followed by argument") << tok.symbol);
} else { } else {
push_token(tok); push_token(tok);
break; break;
@ -282,7 +282,7 @@ expr_t::parser_t::parse_logic_expr(std::istream& in,
if (! node->right()) if (! node->right())
throw_(parse_error, throw_(parse_error,
tok.symbol << " operator not followed by argument"); _("%1 operator not followed by argument") << tok.symbol);
if (negate) { if (negate) {
prev = node; prev = node;
@ -314,7 +314,7 @@ expr_t::parser_t::parse_and_expr(std::istream& in,
node->set_right(parse_logic_expr(in, tflags)); node->set_right(parse_logic_expr(in, tflags));
if (! node->right()) if (! node->right())
throw_(parse_error, throw_(parse_error,
tok.symbol << " operator not followed by argument"); _("%1 operator not followed by argument") << tok.symbol);
} else { } else {
push_token(tok); push_token(tok);
break; break;
@ -341,7 +341,7 @@ expr_t::parser_t::parse_or_expr(std::istream& in,
node->set_right(parse_and_expr(in, tflags)); node->set_right(parse_and_expr(in, tflags));
if (! node->right()) if (! node->right())
throw_(parse_error, throw_(parse_error,
tok.symbol << " operator not followed by argument"); _("%1 operator not followed by argument") << tok.symbol);
} else { } else {
push_token(tok); push_token(tok);
break; break;
@ -367,7 +367,7 @@ expr_t::parser_t::parse_querycolon_expr(std::istream& in,
node->set_right(parse_or_expr(in, tflags)); node->set_right(parse_or_expr(in, tflags));
if (! node->right()) if (! node->right())
throw_(parse_error, throw_(parse_error,
tok.symbol << " operator not followed by argument"); _("%1 operator not followed by argument") << tok.symbol);
token_t& next_tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT)); token_t& next_tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT));
if (next_tok.kind != token_t::COLON) if (next_tok.kind != token_t::COLON)
@ -379,7 +379,7 @@ expr_t::parser_t::parse_querycolon_expr(std::istream& in,
subnode->set_right(parse_or_expr(in, tflags)); subnode->set_right(parse_or_expr(in, tflags));
if (! subnode->right()) if (! subnode->right())
throw_(parse_error, throw_(parse_error,
tok.symbol << " operator not followed by argument"); _("%1 operator not followed by argument") << tok.symbol);
node->set_right(subnode); node->set_right(subnode);
} else { } else {
@ -405,7 +405,7 @@ expr_t::parser_t::parse_value_expr(std::istream& in,
node->set_right(parse_value_expr(in, tflags)); node->set_right(parse_value_expr(in, tflags));
if (! node->right()) if (! node->right())
throw_(parse_error, throw_(parse_error,
tok.symbol << " operator not followed by argument"); _("%1 operator not followed by argument") << tok.symbol);
tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT)); tok = next_token(in, tflags.plus_flags(PARSE_OP_CONTEXT));
} }
@ -418,7 +418,7 @@ expr_t::parser_t::parse_value_expr(std::istream& in,
} }
else if (! tflags.has_flags(PARSE_PARTIAL) && else if (! tflags.has_flags(PARSE_PARTIAL) &&
! tflags.has_flags(PARSE_SINGLE)) { ! tflags.has_flags(PARSE_SINGLE)) {
throw_(parse_error, "Failed to parse value expression"); throw_(parse_error, _("Failed to parse value expression"));
} }
return node; return node;
@ -441,7 +441,7 @@ expr_t::parser_t::parse(std::istream& in, const parse_flags_t& flags,
} }
catch (const std::exception& err) { catch (const std::exception& err) {
if (original_string) { if (original_string) {
add_error_context("While parsing value expression:"); add_error_context(_("While parsing value expression:"));
istream_pos_type end_pos = in.tellg(); istream_pos_type end_pos = in.tellg();
istream_pos_type pos = end_pos; istream_pos_type pos = end_pos;

View file

@ -52,7 +52,7 @@ namespace {
std::ostream& out(report.output_stream); std::ostream& out(report.output_stream);
out << "--- Context is first posting of the following transaction ---" out << _("--- Context is first posting of the following transaction ---")
<< std::endl << str << std::endl; << std::endl << str << std::endl;
{ {
std::istringstream in(str); std::istringstream in(str);
@ -69,7 +69,7 @@ value_t parse_command(call_scope_t& args)
{ {
string arg = join_args(args); string arg = join_args(args);
if (arg.empty()) { if (arg.empty()) {
throw std::logic_error("Usage: parse TEXT"); throw std::logic_error(_("Usage: parse TEXT"));
return 1L; return 1L;
} }
@ -78,23 +78,23 @@ value_t parse_command(call_scope_t& args)
post_t * post = get_sample_post(report); post_t * post = get_sample_post(report);
out << "--- Input expression ---" << std::endl; out << _("--- Input expression ---") << std::endl;
out << arg << std::endl; out << arg << std::endl;
out << std::endl << "--- Text as parsed ---" << std::endl; out << std::endl << _("--- Text as parsed ---") << std::endl;
expr_t expr(arg); expr_t expr(arg);
expr.print(out); expr.print(out);
out << std::endl; out << std::endl;
out << std::endl << "--- Expression tree ---" << std::endl; out << std::endl << _("--- Expression tree ---") << std::endl;
expr.dump(out); expr.dump(out);
bind_scope_t bound_scope(args, *post); bind_scope_t bound_scope(args, *post);
expr.compile(bound_scope); expr.compile(bound_scope);
out << std::endl << "--- Compiled tree ---" << std::endl; out << std::endl << _("--- Compiled tree ---") << std::endl;
expr.dump(out); expr.dump(out);
out << std::endl << "--- Calculated value ---" << std::endl; out << std::endl << _("--- Calculated value ---") << std::endl;
value_t result(expr.calc()); value_t result(expr.calc());
result.strip_annotations(report.what_to_keep()).dump(out); result.strip_annotations(report.what_to_keep()).dump(out);
out << std::endl; out << std::endl;
@ -118,7 +118,7 @@ value_t format_command(call_scope_t& args)
{ {
string arg = join_args(args); string arg = join_args(args);
if (arg.empty()) { if (arg.empty()) {
throw std::logic_error("Usage: format TEXT"); throw std::logic_error(_("Usage: format TEXT"));
return 1L; return 1L;
} }
@ -127,14 +127,14 @@ value_t format_command(call_scope_t& args)
post_t * post = get_sample_post(report); post_t * post = get_sample_post(report);
out << "--- Input format string ---" << std::endl; out << _("--- Input format string ---") << std::endl;
out << arg << std::endl << std::endl; out << arg << std::endl << std::endl;
out << "--- Format elements ---" << std::endl; out << _("--- Format elements ---") << std::endl;
format_t fmt(arg); format_t fmt(arg);
fmt.dump(out); fmt.dump(out);
out << std::endl << "--- Formatted string ---" << std::endl; out << std::endl << _("--- Formatted string ---") << std::endl;
bind_scope_t bound_scope(args, *post); bind_scope_t bound_scope(args, *post);
out << '"'; out << '"';
fmt.format(out, bound_scope); fmt.format(out, bound_scope);
@ -147,7 +147,7 @@ value_t period_command(call_scope_t& args)
{ {
string arg = join_args(args); string arg = join_args(args);
if (arg.empty()) { if (arg.empty()) {
throw std::logic_error("Usage: period TEXT"); throw std::logic_error(_("Usage: period TEXT"));
return 1L; return 1L;
} }
@ -157,10 +157,10 @@ value_t period_command(call_scope_t& args)
interval_t interval(arg); interval_t interval(arg);
if (! is_valid(interval.begin)) { if (! is_valid(interval.begin)) {
out << "Time period has no beginning." << std::endl; out << _("Time period has no beginning.") << std::endl;
} else { } else {
out << "begin: " << format_date(interval.begin) << std::endl; out << _("begin: ") << format_date(interval.begin) << std::endl;
out << " end: " << format_date(interval.end) << std::endl; out << _(" end: ") << format_date(interval.end) << std::endl;
out << std::endl; out << std::endl;
date_t date = interval.first(); date_t date = interval.first();
@ -169,7 +169,7 @@ value_t period_command(call_scope_t& args)
out << std::right; out << std::right;
out.width(2); out.width(2);
out << i << ": " << format_date(date) << std::endl; out << i << "): " << format_date(date) << std::endl;
date = interval.increment(date); date = interval.increment(date);
if (is_valid(interval.end) && date >= interval.end) if (is_valid(interval.end) && date >= interval.end)
@ -187,7 +187,7 @@ value_t args_command(call_scope_t& args)
value_t::sequence_t::const_iterator begin = args.value().begin(); value_t::sequence_t::const_iterator begin = args.value().begin();
value_t::sequence_t::const_iterator end = args.value().end(); value_t::sequence_t::const_iterator end = args.value().end();
out << "--- Input arguments ---" << std::endl; out << _("--- Input arguments ---") << std::endl;
args.value().dump(out); args.value().dump(out);
out << std::endl << std::endl; out << std::endl << std::endl;

View file

@ -66,7 +66,7 @@ void py_parse_2(amount_t& amount, object in, unsigned char flags) {
amount.parse(instr, flags); amount.parse(instr, flags);
} else { } else {
PyErr_SetString(PyExc_IOError, PyErr_SetString(PyExc_IOError,
"Argument to amount.parse(file) is not a file object"); _("Argument to amount.parse(file) is not a file object"));
} }
} }
void py_parse_1(amount_t& amount, object in) { void py_parse_1(amount_t& amount, object in) {
@ -87,7 +87,7 @@ void py_print(amount_t& amount, object out)
amount.print(outstr); amount.print(outstr);
} else { } else {
PyErr_SetString(PyExc_IOError, PyErr_SetString(PyExc_IOError,
"Argument to amount.print_(file) is not a file object"); _("Argument to amount.print_(file) is not a file object"));
} }
} }
@ -125,8 +125,8 @@ void export_amount()
.def(init<std::string>()) .def(init<std::string>())
.def("exact", &amount_t::exact, args("value"), .def("exact", &amount_t::exact, args("value"),
"Construct an amount object whose display precision is always equal to its\n\ _("Construct an amount object whose display precision is always equal to its\n\
internal precision.") internal precision."))
.staticmethod("exact") .staticmethod("exact")
.def(init<amount_t>()) .def(init<amount_t>())

View file

@ -78,7 +78,7 @@ amount_t balance_getitem(balance_t& bal, int i)
std::size_t len = bal.amounts.size(); std::size_t len = bal.amounts.size();
if (abs(i) >= len) { if (abs(i) >= len) {
PyErr_SetString(PyExc_IndexError, "Index out of range"); PyErr_SetString(PyExc_IndexError, _("Index out of range"));
throw_error_already_set(); throw_error_already_set();
} }

View file

@ -83,7 +83,7 @@ post_t& posts_getitem(xact_base_t& xact, int i)
std::size_t len = xact.posts.size(); std::size_t len = xact.posts.size();
if (abs(i) >= len) { if (abs(i) >= len) {
PyErr_SetString(PyExc_IndexError, "Index out of range"); PyErr_SetString(PyExc_IndexError, _("Index out of range"));
throw_error_already_set(); throw_error_already_set();
} }
@ -117,7 +117,7 @@ xact_t& xacts_getitem(journal_t& journal, int i)
std::size_t len = journal.xacts.size(); std::size_t len = journal.xacts.size();
if (abs(i) >= len) { if (abs(i) >= len) {
PyErr_SetString(PyExc_IndexError, "Index out of range"); PyErr_SetString(PyExc_IndexError, _("Index out of range"));
throw_error_already_set(); throw_error_already_set();
} }
@ -151,7 +151,7 @@ account_t& accounts_getitem(account_t& account, int i)
std::size_t len = account.accounts.size(); std::size_t len = account.accounts.size();
if (abs(i) >= len) { if (abs(i) >= len) {
PyErr_SetString(PyExc_IndexError, "Index out of range"); PyErr_SetString(PyExc_IndexError, _("Index out of range"));
throw_error_already_set(); throw_error_already_set();
} }

View file

@ -46,7 +46,7 @@ namespace {
if (scope_t * scope = value.as_pointer<scope_t>()) if (scope_t * scope = value.as_pointer<scope_t>())
return expr_t(scope->lookup(name), scope); return expr_t(scope->lookup(name), scope);
} }
throw_(value_error, "Cannot lookup attributes in " << value.label()); throw_(value_error, _("Cannot lookup attributes in %1") << value.label());
return expr_t(); return expr_t();
} }

View file

@ -109,12 +109,12 @@ void python_interpreter_t::initialize()
object main_module = python::import("__main__"); object main_module = python::import("__main__");
if (! main_module) if (! main_module)
throw_(std::logic_error, throw_(std::logic_error,
"Python failed to initialize (couldn't find __main__)"); _("Python failed to initialize (couldn't find __main__)"));
main_nspace = extract<dict>(main_module.attr("__dict__")); main_nspace = extract<dict>(main_module.attr("__dict__"));
if (! main_nspace) if (! main_nspace)
throw_(std::logic_error, throw_(std::logic_error,
"Python failed to initialize (couldn't find __dict__)"); _("Python failed to initialize (couldn't find __dict__)"));
python::detail::init_module("ledger", &initialize_for_python); python::detail::init_module("ledger", &initialize_for_python);
@ -145,7 +145,7 @@ void python_interpreter_t::initialize()
ledger_dict["__path__"] = temp_list; ledger_dict["__path__"] = temp_list;
} else { } else {
throw_(std::logic_error, throw_(std::logic_error,
"Python failed to initialize (couldn't find ledger)"); _("Python failed to initialize (couldn't find ledger)"));
} }
path_initialized = true; path_initialized = true;
break; break;
@ -153,12 +153,12 @@ void python_interpreter_t::initialize()
} }
if (! path_initialized) if (! path_initialized)
std::cerr std::cerr
<< "Warning: Ledger failed to find 'ledger/__init__.py' on the PYTHONPATH" << _("Warning: Ledger failed to find 'ledger/__init__.py' on the PYTHONPATH")
<< std::endl; << std::endl;
} }
catch (const error_already_set&) { catch (const error_already_set&) {
PyErr_Print(); PyErr_Print();
throw_(std::logic_error, "Python failed to initialize"); throw_(std::logic_error, _("Python failed to initialize"));
} }
TRACE_FINISH(python_init, 1); TRACE_FINISH(python_init, 1);
@ -172,7 +172,7 @@ object python_interpreter_t::import(const string& str)
try { try {
object mod = python::import(str.c_str()); object mod = python::import(str.c_str());
if (! mod) if (! mod)
throw_(std::logic_error, "Failed to import Python module " << str); throw_(std::logic_error, _("Failed to import Python module %1") << str);
// Import all top-level entries directly into the main namespace // Import all top-level entries directly into the main namespace
main_nspace.update(mod.attr("__dict__")); main_nspace.update(mod.attr("__dict__"));
@ -218,7 +218,7 @@ object python_interpreter_t::eval(std::istream& in, py_eval_mode_t mode)
} }
catch (const error_already_set&) { catch (const error_already_set&) {
PyErr_Print(); PyErr_Print();
throw_(std::logic_error, "Failed to evaluate Python code"); throw_(std::logic_error, _("Failed to evaluate Python code"));
} }
return object(); return object();
} }
@ -240,7 +240,7 @@ object python_interpreter_t::eval(const string& str, py_eval_mode_t mode)
} }
catch (const error_already_set&) { catch (const error_already_set&) {
PyErr_Print(); PyErr_Print();
throw_(std::logic_error, "Failed to evaluate Python code"); throw_(std::logic_error, _("Failed to evaluate Python code"));
} }
return object(); return object();
} }
@ -297,7 +297,7 @@ value_t python_interpreter_t::functor_t::operator()(call_scope_t& args)
return NULL_VALUE; return NULL_VALUE;
#else #else
throw_(calc_error, throw_(calc_error,
"Could not evaluate Python variable '" << name << "'"); _("Could not evaluate Python variable '%1'") << name);
#endif #endif
} else { } else {
if (args.size() > 0) { if (args.size() > 0) {
@ -318,14 +318,14 @@ value_t python_interpreter_t::functor_t::operator()(call_scope_t& args)
} else { } else {
Py_DECREF(val); Py_DECREF(val);
throw_(calc_error, throw_(calc_error,
"Could not evaluate Python variable '" << name << "'"); _("Could not evaluate Python variable '%1'") << name);
} }
std::signal(SIGINT, sigint_handler); std::signal(SIGINT, sigint_handler);
return result; return result;
} }
else if (PyErr_Occurred()) { else if (PyErr_Occurred()) {
PyErr_Print(); PyErr_Print();
throw_(calc_error, "Failed call to Python function '" << name << "'"); throw_(calc_error, _("Failed call to Python function '%1'") << name);
} else { } else {
assert(false); assert(false);
} }
@ -338,8 +338,7 @@ value_t python_interpreter_t::functor_t::operator()(call_scope_t& args)
catch (const error_already_set&) { catch (const error_already_set&) {
std::signal(SIGINT, sigint_handler); std::signal(SIGINT, sigint_handler);
PyErr_Print(); PyErr_Print();
throw_(calc_error, throw_(calc_error, _("Failed call to Python function '%1'") << name);
"Failed call to Python function '" << name << "'");
} }
catch (...) { catch (...) {
std::signal(SIGINT, sigint_handler); std::signal(SIGINT, sigint_handler);

View file

@ -99,8 +99,8 @@ void quotes_by_script::operator()(commodity_base_t& commodity,
} }
} else { } else {
throw_(std::runtime_error, throw_(std::runtime_error,
"Failed to download price for '" << commodity.symbol _("Failed to download price for '%1' (command: \"getquote %1\")")
<< "' (command: \"getquote " << commodity.symbol << "\")"); << commodity.symbol);
} }
} }
#endif #endif

View file

@ -253,8 +253,8 @@ public:
interval_t interval(args[0].to_string()); interval_t interval(args[0].to_string());
if (! is_valid(interval.begin)) if (! is_valid(interval.begin))
throw_(std::invalid_argument, throw_(std::invalid_argument,
"Could not determine beginning of period '" _("Could not determine beginning of period '%1'")
<< args[0].to_string() << "'"); << args[0].to_string());
string predicate = string predicate =
"date>=[" + to_iso_extended_string(interval.begin) + "]"; "date>=[" + to_iso_extended_string(interval.begin) + "]";
@ -369,8 +369,8 @@ public:
interval_t interval(args[0].to_string()); interval_t interval(args[0].to_string());
if (! is_valid(interval.begin)) if (! is_valid(interval.begin))
throw_(std::invalid_argument, throw_(std::invalid_argument,
"Could not determine end of period '" _("Could not determine end of period '%1'")
<< args[0].to_string() << "'"); << args[0].to_string());
string predicate = string predicate =
"date<[" + to_iso_extended_string(interval.begin) + "]"; "date<[" + to_iso_extended_string(interval.begin) + "]";

View file

@ -47,7 +47,7 @@ void symbol_scope_t::define(const string& name, expr_t::ptr_op_t def)
std::pair<symbol_map::iterator, bool> result2 std::pair<symbol_map::iterator, bool> result2
= symbols.insert(symbol_map::value_type(name, def)); = symbols.insert(symbol_map::value_type(name, def));
if (! result2.second) if (! result2.second)
throw_(compile_error, "Redefinition of '" << name << "' in same scope"); throw_(compile_error, _("Redefinition of '%1' in same scope") << name);
} }
} }

View file

@ -246,7 +246,7 @@ inline T& find_scope(child_scope_t& scope, bool skip_this = true)
if (T * sought = search_scope<T>(skip_this ? scope.parent : &scope)) if (T * sought = search_scope<T>(skip_this ? scope.parent : &scope))
return *sought; return *sought;
throw_(std::runtime_error, "Could not find scope"); throw_(std::runtime_error, _("Could not find scope"));
return reinterpret_cast<T&>(scope); // never executed return reinterpret_cast<T&>(scope); // never executed
} }

View file

@ -94,7 +94,7 @@ std::size_t session_t::read_journal(const path& pathname,
account_t * master) account_t * master)
{ {
if (! exists(pathname)) if (! exists(pathname))
throw_(std::logic_error, "Cannot read file" << pathname); throw_(std::logic_error, _("Cannot read file '%1'") << pathname);
ifstream stream(pathname); ifstream stream(pathname);
return read_journal(stream, pathname, master); return read_journal(stream, pathname, master);
@ -114,7 +114,7 @@ std::size_t session_t::read_data(const string& master_account)
if (HANDLED(price_db_)) { if (HANDLED(price_db_)) {
path price_db_path = resolve_path(HANDLER(price_db_).str()); path price_db_path = resolve_path(HANDLER(price_db_).str());
if (exists(price_db_path) && read_journal(price_db_path) > 0) if (exists(price_db_path) && read_journal(price_db_path) > 0)
throw_(parse_error, "Transactions not allowed in price history file"); throw_(parse_error, _("Transactions not allowed in price history file"));
} }
foreach (const path& pathname, HANDLER(file_).data_files) { foreach (const path& pathname, HANDLER(file_).data_files) {
@ -141,7 +141,7 @@ std::size_t session_t::read_data(const string& master_account)
xact_count += read_journal(filename, acct); xact_count += read_journal(filename, acct);
} }
else { else {
throw_(parse_error, "Could not read journal file '" << filename << "'"); throw_(parse_error, _("Could not read journal file '%1'") << filename);
} }
} }
@ -160,8 +160,8 @@ void session_t::read_journal_files()
std::size_t count = read_data(master_account); std::size_t count = read_data(master_account);
if (count == 0) if (count == 0)
throw_(parse_error, "Failed to locate any transactions; " throw_(parse_error,
"did you specify a valid file with -f?"); _("Failed to locate any transactions; did you specify a valid file with -f?"));
INFO_FINISH(journal); INFO_FINISH(journal);

View file

@ -65,11 +65,11 @@ namespace {
int status = pipe(pfd); int status = pipe(pfd);
if (status == -1) if (status == -1)
throw std::logic_error("Failed to create pipe"); throw std::logic_error(_("Failed to create pipe"));
status = fork(); status = fork();
if (status < 0) { if (status < 0) {
throw std::logic_error("Failed to fork child process"); throw std::logic_error(_("Failed to fork child process"));
} }
else if (status == 0) { // child else if (status == 0) { // child
// Duplicate pipe's reading end into stdin // Duplicate pipe's reading end into stdin
@ -130,7 +130,7 @@ void output_stream_t::close()
int status; int status;
wait(&status); wait(&status);
if (! WIFEXITED(status) || WEXITSTATUS(status) != 0) if (! WIFEXITED(status) || WEXITSTATUS(status) != 0)
throw std::logic_error("Error in the pager"); throw std::logic_error(_("Error in the pager"));
} }
} }

View file

@ -154,7 +154,7 @@ namespace {
value_t result(expr.calc(bound_scope)); value_t result(expr.calc(bound_scope));
if (! result.is_amount()) if (! result.is_amount())
throw_(parse_error, "Postings may only specify simple amounts"); throw_(parse_error, _("Postings may only specify simple amounts"));
amount = result.as_amount(); amount = result.as_amount();
DEBUG("textual.parse", "The posting amount is " << amount); DEBUG("textual.parse", "The posting amount is " << amount);
@ -234,11 +234,11 @@ void instance_t::parse()
instances.push_front(instance); instances.push_front(instance);
foreach (instance_t * instance, instances) foreach (instance_t * instance, instances)
add_error_context("In file included from " add_error_context(_("In file included from %1")
<< file_context(instance->pathname, << file_context(instance->pathname,
instance->linenum)); instance->linenum));
} }
add_error_context("While parsing file " add_error_context(_("While parsing file %1")
<< file_context(pathname, linenum)); << file_context(pathname, linenum));
if (caught_signal != NONE_CAUGHT) if (caught_signal != NONE_CAUGHT)
@ -251,7 +251,7 @@ void instance_t::parse()
if (! current_context.empty()) if (! current_context.empty())
std::cerr << current_context << std::endl; std::cerr << current_context << std::endl;
std::cerr << "Error: " << err.what() << std::endl; std::cerr << _("Error: ") << err.what() << std::endl;
errors++; errors++;
} }
} }
@ -308,7 +308,7 @@ void instance_t::read_next_directive()
#if 0 #if 0
char * p = skip_ws(line); char * p = skip_ws(line);
if (*p) if (*p)
throw parse_error("Line begins with whitespace"); throw parse_error(_("Line begins with whitespace"));
#endif #endif
break; break;
} }
@ -446,7 +446,7 @@ namespace {
if (*p == '"') { if (*p == '"') {
char * q = std::strchr(p + 1, '"'); char * q = std::strchr(p + 1, '"');
if (! q) if (! q)
throw parse_error("Quoted commodity symbol lacks closing quote"); throw parse_error(_("Quoted commodity symbol lacks closing quote"));
symbol = string(p + 1, 0, q - p - 1); symbol = string(p + 1, 0, q - p - 1);
p = q + 2; p = q + 2;
} else { } else {
@ -458,7 +458,7 @@ namespace {
p += symbol.length(); p += symbol.length();
} }
if (symbol.empty()) if (symbol.empty())
throw parse_error("Failed to parse commodity"); throw parse_error(_("Failed to parse commodity"));
} }
} }
@ -554,7 +554,7 @@ void instance_t::period_xact_directive(char * line)
{ {
std::auto_ptr<period_xact_t> pe(new period_xact_t(skip_ws(line + 1))); std::auto_ptr<period_xact_t> pe(new period_xact_t(skip_ws(line + 1)));
if (! pe->period) if (! pe->period)
throw_(parse_error, "Parsing time period '" << line << "'"); throw_(parse_error, _("Parsing time period '%1'") << line);
istream_pos_type pos = curr_pos; istream_pos_type pos = curr_pos;
std::size_t lnum = linenum; std::size_t lnum = linenum;
@ -573,7 +573,7 @@ void instance_t::period_xact_directive(char * line)
pe.release(); pe.release();
} else { } else {
throw parse_error("Period transaction failed to balance"); throw parse_error(_("Period transaction failed to balance"));
} }
} }
} }
@ -593,7 +593,7 @@ void instance_t::xact_directive(char * line, std::streamsize len)
// do if the xact has no substantive effect (for example, a checking // do if the xact has no substantive effect (for example, a checking
// xact, all of whose postings have null amounts). // xact, all of whose postings have null amounts).
} else { } else {
throw parse_error("Failed to parse transaction"); throw parse_error(_("Failed to parse transaction"));
} }
TRACE_STOP(xacts, 1); TRACE_STOP(xacts, 1);
@ -779,7 +779,7 @@ post_t * instance_t::parse_post(char * line,
// Parse the account name // Parse the account name
if (! *p) if (! *p)
throw parse_error("Posting has no account"); throw parse_error(_("Posting has no account"));
char * next = next_element(p, true); char * next = next_element(p, true);
char * e = p + std::strlen(p); char * e = p + std::strlen(p);
@ -810,10 +810,13 @@ post_t * instance_t::parse_post(char * line,
post->account = account->find_account(name); post->account = account->find_account(name);
if (honor_strict && strict && ! post->account->known) { if (honor_strict && strict && ! post->account->known) {
if (post->_state == item_t::UNCLEARED) if (post->_state == item_t::UNCLEARED) {
std::cerr << "Warning: \"" << pathname << "\", line " << linenum straccstream accum;
<< ": Unknown account '" << post->account->fullname() std::cerr
<< "'" << std::endl; << ACCUM(accum << _("Warning: \"%1\", line %2: Unknown account '%3'")
<< pathname << linenum << post->account->fullname())
<< std::endl;
}
post->account->known = true; post->account->known = true;
} }
@ -837,10 +840,13 @@ post_t * instance_t::parse_post(char * line,
if (! post->amount.is_null() && honor_strict && strict && if (! post->amount.is_null() && honor_strict && strict &&
post->amount.has_commodity() && post->amount.has_commodity() &&
! post->amount.commodity().has_flags(COMMODITY_KNOWN)) { ! post->amount.commodity().has_flags(COMMODITY_KNOWN)) {
if (post->_state == item_t::UNCLEARED) if (post->_state == item_t::UNCLEARED) {
std::cerr << "Warning: \"" << pathname << "\", line " << linenum straccstream accum;
<< ": Unknown commodity '" << post->amount.commodity() std::cerr
<< "'" << std::endl; << ACCUM(accum << _("Warning: \"%1\", line %2: Unknown commodity '%3'")
<< pathname << linenum << post->amount.commodity())
<< std::endl;
}
post->amount.commodity().add_flags(COMMODITY_KNOWN); post->amount.commodity().add_flags(COMMODITY_KNOWN);
} }
@ -883,7 +889,7 @@ post_t * instance_t::parse_post(char * line,
static_cast<uint_least8_t>(expr_t::PARSE_NO_ASSIGN)); static_cast<uint_least8_t>(expr_t::PARSE_NO_ASSIGN));
if (post->cost->sign() < 0) if (post->cost->sign() < 0)
throw parse_error("A posting's cost may not be negative"); throw parse_error(_("A posting's cost may not be negative"));
if (per_unit) if (per_unit)
*post->cost *= post->amount; *post->cost *= post->amount;
@ -898,7 +904,7 @@ post_t * instance_t::parse_post(char * line,
else else
next = skip_ws(p + cstream.tellg()); next = skip_ws(p + cstream.tellg());
} else { } else {
throw parse_error("Expected a cost amount"); throw parse_error(_("Expected a cost amount"));
} }
} }
} }
@ -926,7 +932,7 @@ post_t * instance_t::parse_post(char * line,
static_cast<uint_least8_t>(expr_t::PARSE_NO_MIGRATE)); static_cast<uint_least8_t>(expr_t::PARSE_NO_MIGRATE));
if (post->assigned_amount->is_null()) if (post->assigned_amount->is_null())
throw parse_error("An assigned balance must evaluate to a constant value"); throw parse_error(_("An assigned balance must evaluate to a constant value"));
DEBUG("textual.parse", "line " << linenum << ": " DEBUG("textual.parse", "line " << linenum << ": "
<< "POST assign: parsed amt = " << *post->assigned_amount); << "POST assign: parsed amt = " << *post->assigned_amount);
@ -987,7 +993,7 @@ post_t * instance_t::parse_post(char * line,
else else
next = skip_ws(p + stream.tellg()); next = skip_ws(p + stream.tellg());
} else { } else {
throw parse_error("Expected an assigned balance amount"); throw parse_error(_("Expected an assigned balance amount"));
} }
} }
@ -1003,8 +1009,9 @@ post_t * instance_t::parse_post(char * line,
// There should be nothing more to read // There should be nothing more to read
if (next && *next) if (next && *next)
throw_(parse_error, "Unexpected char '" << *next throw_(parse_error,
<< "' (Note: inline math requires parentheses)"); _("Unexpected char '%1' (Note: inline math requires parentheses)")
<< *next);
post->end_pos = curr_pos; post->end_pos = curr_pos;
post->end_line = linenum; post->end_line = linenum;
@ -1015,7 +1022,7 @@ post_t * instance_t::parse_post(char * line,
} }
catch (const std::exception& err) { catch (const std::exception& err) {
add_error_context("While parsing posting:"); add_error_context(_("While parsing posting:"));
add_error_context(line_context(buf, beg, len)); add_error_context(line_context(buf, beg, len));
throw; throw;
} }
@ -1097,7 +1104,7 @@ xact_t * instance_t::parse_xact(char * line,
curr->payee = next; curr->payee = next;
next = next_element(next, true); next = next_element(next, true);
} else { } else {
curr->payee = "<Unspecified payee>"; curr->payee = _("<Unspecified payee>");
} }
// Parse the xact note // Parse the xact note

View file

@ -47,11 +47,11 @@ namespace {
time_xacts.clear(); time_xacts.clear();
} }
else if (time_xacts.empty()) { else if (time_xacts.empty()) {
throw parse_error("Timelog check-out event without a check-in"); throw parse_error(_("Timelog check-out event without a check-in"));
} }
else if (! account) { else if (! account) {
throw parse_error throw parse_error
("When multiple check-ins are active, checking out requires an account"); (_("When multiple check-ins are active, checking out requires an account"));
} }
else { else {
bool found = false; bool found = false;
@ -68,7 +68,7 @@ namespace {
if (! found) if (! found)
throw parse_error throw parse_error
("Timelog check-out event does not match any current check-ins"); (_("Timelog check-out event does not match any current check-ins"));
} }
if (desc && event.desc.empty()) { if (desc && event.desc.empty()) {
@ -83,7 +83,7 @@ namespace {
if (when < event.checkin) if (when < event.checkin)
throw parse_error throw parse_error
("Timelog check-out date less than corresponding check-in"); (_("Timelog check-out date less than corresponding check-in"));
char buf[32]; char buf[32];
std::sprintf(buf, "%lds", long((when - event.checkin).total_seconds())); std::sprintf(buf, "%lds", long((when - event.checkin).total_seconds()));
@ -96,7 +96,7 @@ namespace {
curr->add_post(post); curr->add_post(post);
if (! journal.add_xact(curr.get())) if (! journal.add_xact(curr.get()))
throw parse_error("Failed to record 'out' timelog transaction"); throw parse_error(_("Failed to record 'out' timelog transaction"));
else else
curr.release(); curr.release();
} }
@ -129,7 +129,7 @@ void time_log_t::clock_in(const datetime_t& checkin,
if (! time_xacts.empty()) { if (! time_xacts.empty()) {
foreach (time_xact_t& time_xact, time_xacts) { foreach (time_xact_t& time_xact, time_xacts) {
if (event.account == time_xact.account) if (event.account == time_xact.account)
throw parse_error("Cannot double check-in to the same account"); throw parse_error(_("Cannot double check-in to the same account"));
} }
} }
@ -141,7 +141,7 @@ void time_log_t::clock_out(const datetime_t& checkin,
const string& desc) const string& desc)
{ {
if (time_xacts.empty()) if (time_xacts.empty())
throw std::logic_error("Timelog check-out event without a check-in"); throw std::logic_error(_("Timelog check-out event without a check-in"));
clock_out_from_timelog(time_xacts, checkin, account, desc.c_str(), clock_out_from_timelog(time_xacts, checkin, account, desc.c_str(),
journal); journal);

View file

@ -107,19 +107,19 @@ namespace {
int string_to_day_of_week(const std::string& str) int string_to_day_of_week(const std::string& str)
{ {
if (str == "sun" || str == "sunday" || str == "0") if (str == _("sun") || str == _("sunday") || str == "0")
return 0; return 0;
else if (str == "mon" || str == "monday" || str == "1") else if (str == _("mon") || str == _("monday") || str == "1")
return 1; return 1;
else if (str == "tue" || str == "tuesday" || str == "2") else if (str == _("tue") || str == _("tuesday") || str == "2")
return 2; return 2;
else if (str == "wed" || str == "wednesday" || str == "3") else if (str == _("wed") || str == _("wednesday") || str == "3")
return 3; return 3;
else if (str == "thu" || str == "thursday" || str == "4") else if (str == _("thu") || str == _("thursday") || str == "4")
return 4; return 4;
else if (str == "fri" || str == "friday" || str == "5") else if (str == _("fri") || str == _("friday") || str == "5")
return 5; return 5;
else if (str == "sat" || str == "saturday" || str == "6") else if (str == _("sat") || str == _("saturday") || str == "6")
return 6; return 6;
assert(false); assert(false);
@ -197,7 +197,7 @@ namespace {
struct std::tm when; struct std::tm when;
if (! parse_date_mask(word.c_str(), when)) if (! parse_date_mask(word.c_str(), when))
throw_(date_error, "Could not parse date mask: " << word); throw_(date_error, _("Could not parse date mask: %1") << word);
when.tm_hour = 0; when.tm_hour = 0;
when.tm_min = 0; when.tm_min = 0;
@ -251,23 +251,23 @@ namespace {
bool mon_spec = false; bool mon_spec = false;
char buf[32]; char buf[32];
if (word == "this" || word == "last" || word == "next") { if (word == _("this") || word == _("last") || word == _("next")) {
type = word; type = word;
if (! in.eof()) if (! in.eof())
read_lower_word(in, word); read_lower_word(in, word);
else else
word = "month"; word = _("month");
} else { } else {
type = "this"; type = _("this");
} }
if (word == "month") { if (word == _("month")) {
time_t now = to_time_t(CURRENT_TIME()); time_t now = to_time_t(CURRENT_TIME());
std::strftime(buf, 31, "%B", localtime(&now)); std::strftime(buf, 31, "%B", localtime(&now));
word = buf; word = buf;
mon_spec = true; mon_spec = true;
} }
else if (word == "year") { else if (word == _("year")) {
int year = CURRENT_DATE().year(); int year = CURRENT_DATE().year();
std::sprintf(buf, "%04d", year); std::sprintf(buf, "%04d", year);
word = buf; word = buf;
@ -275,7 +275,7 @@ namespace {
parse_inclusion_specifier(word, begin, end); parse_inclusion_specifier(word, begin, end);
if (type == "last") { if (type == _("last")) {
if (mon_spec) { if (mon_spec) {
if (begin) if (begin)
*begin = interval_t(0, -1, 0).increment(*begin); *begin = interval_t(0, -1, 0).increment(*begin);
@ -288,7 +288,7 @@ namespace {
*end = interval_t(0, 0, -1).increment(*end); *end = interval_t(0, 0, -1).increment(*end);
} }
} }
else if (type == "next") { else if (type == _("next")) {
if (mon_spec) { if (mon_spec) {
if (begin) if (begin)
*begin = interval_t(0, 1, 0).increment(*begin); *begin = interval_t(0, 1, 0).increment(*begin);
@ -310,65 +310,65 @@ void interval_t::parse(std::istream& in)
while (! in.eof()) { while (! in.eof()) {
read_lower_word(in, word); read_lower_word(in, word);
if (word == "every") { if (word == _("every")) {
read_lower_word(in, word); read_lower_word(in, word);
if (std::isdigit(word[0])) { if (std::isdigit(word[0])) {
int quantity = lexical_cast<int>(word); int quantity = lexical_cast<int>(word);
read_lower_word(in, word); read_lower_word(in, word);
if (word == "days") if (word == _("days"))
days = quantity; days = quantity;
else if (word == "weeks") { else if (word == _("weeks")) {
days = 7 * quantity; days = 7 * quantity;
weekly = true; weekly = true;
} }
else if (word == "months") else if (word == _("months"))
months = quantity; months = quantity;
else if (word == "quarters") else if (word == _("quarters"))
months = 3 * quantity; months = 3 * quantity;
else if (word == "years") else if (word == _("years"))
years = quantity; years = quantity;
} }
else if (word == "day") else if (word == _("day"))
days = 1; days = 1;
else if (word == "week") { else if (word == _("week")) {
days = 7; days = 7;
weekly = true; weekly = true;
} }
else if (word == "month") else if (word == _("month"))
months = 1; months = 1;
else if (word == "quarter") else if (word == _("quarter"))
months = 3; months = 3;
else if (word == "year") else if (word == _("year"))
years = 1; years = 1;
} }
else if (word == "daily") else if (word == _("daily"))
days = 1; days = 1;
else if (word == "weekly") { else if (word == _("weekly")) {
days = 7; days = 7;
weekly = true; weekly = true;
} }
else if (word == "biweekly") else if (word == _("biweekly"))
days = 14; days = 14;
else if (word == "monthly") else if (word == _("monthly"))
months = 1; months = 1;
else if (word == "bimonthly") else if (word == _("bimonthly"))
months = 2; months = 2;
else if (word == "quarterly") else if (word == _("quarterly"))
months = 3; months = 3;
else if (word == "yearly") else if (word == _("yearly"))
years = 1; years = 1;
else if (word == "this" || word == "last" || word == "next") { else if (word == _("this") || word == _("last") || word == _("next")) {
parse_date_words(in, word, &begin, &end); parse_date_words(in, word, &begin, &end);
} }
else if (word == "in") { else if (word == _("in")) {
read_lower_word(in, word); read_lower_word(in, word);
parse_date_words(in, word, &begin, &end); parse_date_words(in, word, &begin, &end);
} }
else if (word == "from" || word == "since") { else if (word == _("from") || word == _("since")) {
read_lower_word(in, word); read_lower_word(in, word);
parse_date_words(in, word, &begin, NULL); parse_date_words(in, word, &begin, NULL);
} }
else if (word == "to" || word == "until") { else if (word == _("to") || word == _("until")) {
read_lower_word(in, word); read_lower_word(in, word);
parse_date_words(in, word, NULL, &end); parse_date_words(in, word, NULL, &end);
} }

View file

@ -122,7 +122,7 @@ void expr_t::token_t::next(std::istream& in, const uint_least8_t pflags)
return; return;
} }
if (! in.good()) if (! in.good())
throw_(parse_error, "Input stream no longer valid"); throw_(parse_error, _("Input stream no longer valid"));
char c = peek_next_nonws(in); char c = peek_next_nonws(in);
@ -131,7 +131,7 @@ void expr_t::token_t::next(std::istream& in, const uint_least8_t pflags)
return; return;
} }
if (! in.good()) if (! in.good())
throw_(parse_error, "Input stream no longer valid"); throw_(parse_error, _("Input stream no longer valid"));
symbol[0] = c; symbol[0] = c;
symbol[1] = '\0'; symbol[1] = '\0';
@ -362,7 +362,7 @@ void expr_t::token_t::next(std::istream& in, const uint_least8_t pflags)
in.clear(); in.clear();
in.seekg(pos, std::ios::beg); in.seekg(pos, std::ios::beg);
if (in.fail()) if (in.fail())
throw_(parse_error, "Failed to reset input stream"); throw_(parse_error, _("Failed to reset input stream"));
} }
// When in relaxed parsing mode, we want to migrate commodity flags // When in relaxed parsing mode, we want to migrate commodity flags
@ -385,7 +385,7 @@ void expr_t::token_t::next(std::istream& in, const uint_least8_t pflags)
in.clear(); in.clear();
in.seekg(pos, std::ios::beg); in.seekg(pos, std::ios::beg);
if (in.fail()) if (in.fail())
throw_(parse_error, "Failed to reset input stream"); throw_(parse_error, _("Failed to reset input stream"));
c = in.peek(); c = in.peek();
if (std::isdigit(c) || c == '.') if (std::isdigit(c) || c == '.')
@ -412,7 +412,7 @@ void expr_t::token_t::rewind(std::istream& in)
{ {
in.seekg(- length, std::ios::cur); in.seekg(- length, std::ios::cur);
if (in.fail()) if (in.fail())
throw_(parse_error, "Failed to rewind input stream"); throw_(parse_error, _("Failed to rewind input stream"));
} }
@ -424,13 +424,13 @@ void expr_t::token_t::unexpected()
switch (prev_kind) { switch (prev_kind) {
case TOK_EOF: case TOK_EOF:
throw_(parse_error, "Unexpected end of expression"); throw_(parse_error, _("Unexpected end of expression"));
case IDENT: case IDENT:
throw_(parse_error, "Unexpected symbol '" << value << "'"); throw_(parse_error, _("Unexpected symbol '%1'") << value);
case VALUE: case VALUE:
throw_(parse_error, "Unexpected value '" << value << "'"); throw_(parse_error, _("Unexpected value '%1'") << value);
default: default:
throw_(parse_error, "Unexpected operator '" << symbol << "'"); throw_(parse_error, _("Unexpected operator '%1'") << symbol);
} }
} }
@ -440,15 +440,14 @@ void expr_t::token_t::expected(char wanted, char c)
if (c == '\0' || c == -1) { if (c == '\0' || c == -1) {
if (wanted == '\0' || wanted == -1) if (wanted == '\0' || wanted == -1)
throw_(parse_error, "Unexpected end"); throw_(parse_error, _("Unexpected end"));
else else
throw_(parse_error, "Missing '" << wanted << "'"); throw_(parse_error, _("Missing '%1'") << wanted);
} else { } else {
if (wanted == '\0' || wanted == -1) if (wanted == '\0' || wanted == -1)
throw_(parse_error, "Invalid char '" << c << "'"); throw_(parse_error, _("Invalid char '%1'") << c);
else else
throw_(parse_error, "Invalid char '" << c throw_(parse_error, _("Invalid char '%1' (wanted '%2')") << c << wanted);
<< "' (wanted '" << wanted << "')");
} }
} }

View file

@ -485,9 +485,9 @@ inline void check_for_signal() {
case NONE_CAUGHT: case NONE_CAUGHT:
break; break;
case INTERRUPTED: case INTERRUPTED:
throw std::runtime_error("Interrupted by user (use Control-D to quit)"); throw std::runtime_error(_("Interrupted by user (use Control-D to quit)"));
case PIPE_CLOSED: case PIPE_CLOSED:
throw std::runtime_error("Pipe terminated"); throw std::runtime_error(_("Pipe terminated"));
} }
} }

View file

@ -107,7 +107,7 @@ value_t::operator bool() const
break; break;
} }
throw_(value_error, "Cannot determine truth of " << label()); throw_(value_error, _("Cannot determine truth of %1") << label());
return false; return false;
} }
@ -277,7 +277,7 @@ value_t& value_t::operator+=(const value_t& val)
for (; i != end(); i++, j++) for (; i != end(); i++, j++)
*i += *j; *i += *j;
} else { } else {
throw_(value_error, "Cannot add sequences of different lengths"); throw_(value_error, _("Cannot add sequences of different lengths"));
} }
} else { } else {
as_sequence_lval().push_back(val); as_sequence_lval().push_back(val);
@ -386,7 +386,7 @@ value_t& value_t::operator+=(const value_t& val)
break; break;
} }
throw_(value_error, "Cannot add " << val.label() << " to " << label()); throw_(value_error, _("Cannot add %1 to %2") << val.label() << label());
return *this; return *this;
} }
@ -403,7 +403,7 @@ value_t& value_t::operator-=(const value_t& val)
for (; i != end(); i++, j++) for (; i != end(); i++, j++)
*i -= *j; *i -= *j;
} else { } else {
throw_(value_error, "Cannot subtract sequences of different lengths"); throw_(value_error, _("Cannot subtract sequences of different lengths"));
} }
} else { } else {
sequence_t::iterator i = std::find(seq.begin(), seq.end(), val); sequence_t::iterator i = std::find(seq.begin(), seq.end(), val);
@ -522,7 +522,7 @@ value_t& value_t::operator-=(const value_t& val)
break; break;
} }
throw_(value_error, "Cannot subtract " << val.label() << " from " << label()); throw_(value_error, _("Cannot subtract %1 from %2") << val.label() << label());
return *this; return *this;
} }
@ -596,7 +596,7 @@ value_t& value_t::operator*=(const value_t& val)
break; break;
} }
throw_(value_error, "Cannot multiply " << label() << " with " << val.label()); throw_(value_error, _("Cannot multiply %1 with %2") << label() << val.label());
return *this; return *this;
} }
@ -651,7 +651,7 @@ value_t& value_t::operator/=(const value_t& val)
break; break;
} }
throw_(value_error, "Cannot divide " << label() << " by " << val.label()); throw_(value_error, _("Cannot divide %1 by %2") << label() << val.label());
return *this; return *this;
} }
@ -736,7 +736,7 @@ bool value_t::is_equal_to(const value_t& val) const
break; break;
} }
throw_(value_error, "Cannot compare " << label() << " to " << val.label()); throw_(value_error, _("Cannot compare %1 by %2") << label() << val.label());
return *this; return *this;
} }
@ -831,7 +831,7 @@ bool value_t::is_less_than(const value_t& val) const
break; break;
} }
throw_(value_error, "Cannot compare " << label() << " to " << val.label()); throw_(value_error, _("Cannot compare %1 to %2") << label() << val.label());
return *this; return *this;
} }
@ -921,7 +921,7 @@ bool value_t::is_greater_than(const value_t& val) const
break; break;
} }
throw_(value_error, "Cannot compare " << label() << " to " << val.label()); throw_(value_error, _("Cannot compare %1 to %2") << label() << val.label());
return *this; return *this;
} }
@ -1041,8 +1041,8 @@ void value_t::in_place_cast(type_t cast_type)
return; return;
} }
else { else {
throw_(value_error, "Cannot convert " << label() << throw_(value_error, _("Cannot convert %1 with multiple commodities to %2")
" with multiple commodities to " << label(cast_type)); << label() << label(cast_type));
} }
break; break;
} }
@ -1057,9 +1057,6 @@ void value_t::in_place_cast(type_t cast_type)
if (all(as_string(), is_digit())) { if (all(as_string(), is_digit())) {
set_long(lexical_cast<long>(as_string())); set_long(lexical_cast<long>(as_string()));
return; return;
} else {
throw_(value_error,
"Cannot convert string '" << *this << "' to an integer");
} }
break; break;
} }
@ -1079,7 +1076,7 @@ void value_t::in_place_cast(type_t cast_type)
} }
throw_(value_error, throw_(value_error,
"Cannot convert " << label() << " to " << label(cast_type)); _("Cannot convert %1 to %2") << label() << label(cast_type));
} }
void value_t::in_place_negate() void value_t::in_place_negate()
@ -1105,7 +1102,7 @@ void value_t::in_place_negate()
break; break;
} }
throw_(value_error, "Cannot negate " << label()); throw_(value_error, _("Cannot negate %1") << label());
} }
void value_t::in_place_not() void value_t::in_place_not()
@ -1134,7 +1131,7 @@ void value_t::in_place_not()
break; break;
} }
throw_(value_error, "Cannot not " << label()); throw_(value_error, _("Cannot 'not' %1") << label());
} }
bool value_t::is_realzero() const bool value_t::is_realzero() const
@ -1161,7 +1158,7 @@ bool value_t::is_realzero() const
return as_any_pointer().empty(); return as_any_pointer().empty();
default: default:
throw_(value_error, "Cannot determine if " << label() << " is really zero"); throw_(value_error, _("Cannot determine if %1 is really zero") << label());
} }
return false; return false;
} }
@ -1190,7 +1187,7 @@ bool value_t::is_zero() const
return as_any_pointer().empty(); return as_any_pointer().empty();
default: default:
throw_(value_error, "Cannot determine if " << label() << " is zero"); throw_(value_error, _("Cannot determine if %1 is zero") << label());
} }
return false; return false;
} }
@ -1219,7 +1216,7 @@ value_t value_t::value(const bool primary_only,
break; break;
} }
throw_(value_error, "Cannot find the value of " << label()); throw_(value_error, _("Cannot find the value of %1") << label());
return NULL_VALUE; return NULL_VALUE;
} }
@ -1272,7 +1269,7 @@ value_t value_t::abs() const
break; break;
} }
throw_(value_error, "Cannot abs " << label()); throw_(value_error, _("Cannot abs %1") << label());
return NULL_VALUE; return NULL_VALUE;
} }
@ -1289,7 +1286,7 @@ value_t value_t::rounded() const
break; break;
} }
throw_(value_error, "Cannot set rounding for " << label()); throw_(value_error, _("Cannot set rounding for %1") << label());
return NULL_VALUE; return NULL_VALUE;
} }
@ -1306,7 +1303,7 @@ value_t value_t::unrounded() const
break; break;
} }
throw_(value_error, "Cannot unround " << label()); throw_(value_error, _("Cannot unround %1") << label());
return NULL_VALUE; return NULL_VALUE;
} }
@ -1315,7 +1312,7 @@ void value_t::annotate(const annotation_t& details)
if (is_amount()) if (is_amount())
as_amount_lval().annotate(details); as_amount_lval().annotate(details);
else else
throw_(value_error, "Cannot annotate " << label()); throw_(value_error, _("Cannot annotate %1") << label());
} }
bool value_t::is_annotated() const bool value_t::is_annotated() const
@ -1324,7 +1321,7 @@ bool value_t::is_annotated() const
return as_amount().is_annotated(); return as_amount().is_annotated();
else else
throw_(value_error, throw_(value_error,
"Cannot determine whether " << label() << " is annotated"); _("Cannot determine whether %1 is annotated") << label());
return false; return false;
} }
@ -1333,7 +1330,7 @@ annotation_t& value_t::annotation()
if (is_amount()) if (is_amount())
return as_amount_lval().annotation(); return as_amount_lval().annotation();
else { else {
throw_(value_error, "Cannot request annotation of " << label()); throw_(value_error, _("Cannot request annotation of %1") << label());
return as_amount_lval().annotation(); // quiet g++ warning return as_amount_lval().annotation(); // quiet g++ warning
} }
} }
@ -1462,7 +1459,7 @@ void value_t::print(std::ostream& out,
break; break;
default: default:
throw_(value_error, "Cannot print " << label()); throw_(value_error, _("Cannot print %1") << label());
} }
} }

View file

@ -863,33 +863,33 @@ public:
string label(optional<type_t> the_type = none) const { string label(optional<type_t> the_type = none) const {
switch (the_type ? *the_type : type()) { switch (the_type ? *the_type : type()) {
case VOID: case VOID:
return "an uninitialized value"; return _("an uninitialized value");
case BOOLEAN: case BOOLEAN:
return "a boolean"; return _("a boolean");
case DATETIME: case DATETIME:
return "a date/time"; return _("a date/time");
case DATE: case DATE:
return "a date"; return _("a date");
case INTEGER: case INTEGER:
return "an integer"; return _("an integer");
case AMOUNT: case AMOUNT:
return "an amount"; return _("an amount");
case BALANCE: case BALANCE:
return "a balance"; return _("a balance");
case STRING: case STRING:
return "a string"; return _("a string");
case MASK: case MASK:
return "a regexp"; return _("a regexp");
case SEQUENCE: case SEQUENCE:
return "a sequence"; return _("a sequence");
case POINTER: case POINTER:
return "a pointer"; return _("a pointer");
default: default:
assert(false); assert(false);
break; break;
} }
assert(false); assert(false);
return "<invalid>"; return _("<invalid>");
} }
/** /**

View file

@ -170,7 +170,7 @@ bool xact_base_t::finalize()
null_post->add_flags(POST_CALCULATED); null_post->add_flags(POST_CALCULATED);
} }
else if (! balance.is_null() && ! balance.is_realzero()) { else if (! balance.is_null() && ! balance.is_realzero()) {
throw_(balance_error, "Transaction does not balance"); throw_(balance_error, _("Transaction does not balance"));
} }
balance = NULL_VALUE; balance = NULL_VALUE;
@ -271,7 +271,7 @@ bool xact_base_t::finalize()
if (post->amount.commodity() == post->cost->commodity()) if (post->amount.commodity() == post->cost->commodity())
throw_(balance_error, throw_(balance_error,
"A posting's cost must be of a different commodity than its amount"); _("A posting's cost must be of a different commodity than its amount"));
commodity_t::cost_breakdown_t breakdown = commodity_t::cost_breakdown_t breakdown =
commodity_t::exchange(post->amount, *post->cost, false, commodity_t::exchange(post->amount, *post->cost, false,
@ -304,10 +304,10 @@ bool xact_base_t::finalize()
DEBUG("xact.finalize", "final balance = " << balance); DEBUG("xact.finalize", "final balance = " << balance);
if (! balance.is_null() && ! balance.is_zero()) { if (! balance.is_null() && ! balance.is_zero()) {
add_error_context(item_context(*this, "While balancing transaction")); add_error_context(item_context(*this, _("While balancing transaction")));
add_error_context("Unbalanced remainder is:"); add_error_context(_("Unbalanced remainder is:"));
add_error_context(value_context(balance)); add_error_context(value_context(balance));
throw_(balance_error, "Transaction does not balance"); throw_(balance_error, _("Transaction does not balance"));
} }
// Add the final calculated totals each to their related account // Add the final calculated totals each to their related account
@ -334,7 +334,7 @@ bool xact_base_t::finalize()
return false; // ignore this xact completely return false; // ignore this xact completely
else if (some_null) else if (some_null)
throw_(balance_error, throw_(balance_error,
"There cannot be null amounts after balancing a transaction"); _("There cannot be null amounts after balancing a transaction"));
} }
return true; return true;