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:
parent
f745767fa6
commit
238bd7f8a5
40 changed files with 380 additions and 381 deletions
|
|
@ -229,18 +229,18 @@ int amount_t::compare(const amount_t& amt) const
|
|||
|
||||
if (! quantity || ! amt.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)
|
||||
throw_(amount_error, "Cannot compare an uninitialized amount to an amount");
|
||||
throw_(amount_error, _("Cannot compare an uninitialized amount to an amount"));
|
||||
else
|
||||
throw_(amount_error, "Cannot compare two uninitialized amounts");
|
||||
throw_(amount_error, _("Cannot compare two uninitialized amounts"));
|
||||
}
|
||||
|
||||
if (has_commodity() && amt.has_commodity() &&
|
||||
commodity() != amt.commodity())
|
||||
throw_(amount_error,
|
||||
"Cannot compare amounts with different commodities: " <<
|
||||
commodity().symbol() << " and " << amt.commodity().symbol());
|
||||
_("Cannot compare amounts with different commodities: %1 and %2")
|
||||
<< commodity().symbol() << amt.commodity().symbol());
|
||||
|
||||
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)
|
||||
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)
|
||||
throw_(amount_error, "Cannot add an amount to an uninitialized amount");
|
||||
throw_(amount_error, _("Cannot add an amount to an uninitialized amount"));
|
||||
else
|
||||
throw_(amount_error, "Cannot add two uninitialized amounts");
|
||||
throw_(amount_error, _("Cannot add two uninitialized amounts"));
|
||||
}
|
||||
|
||||
if (commodity() != amt.commodity())
|
||||
throw_(amount_error,
|
||||
"Adding amounts with different commodities: " <<
|
||||
(has_commodity() ? commodity().symbol() : "NONE") <<
|
||||
" != " <<
|
||||
(amt.has_commodity() ? amt.commodity().symbol() : "NONE"));
|
||||
_("Adding amounts with different commodities: %1 != %2")
|
||||
<< (has_commodity() ? commodity().symbol() : _("NONE"))
|
||||
<< (amt.has_commodity() ? amt.commodity().symbol() : _("NONE")));
|
||||
|
||||
_dup();
|
||||
|
||||
|
|
@ -294,19 +293,18 @@ amount_t& amount_t::operator-=(const amount_t& amt)
|
|||
|
||||
if (! quantity || ! amt.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)
|
||||
throw_(amount_error, "Cannot subtract an uninitialized amount from an amount");
|
||||
throw_(amount_error, _("Cannot subtract an uninitialized amount from an amount"));
|
||||
else
|
||||
throw_(amount_error, "Cannot subtract two uninitialized amounts");
|
||||
throw_(amount_error, _("Cannot subtract two uninitialized amounts"));
|
||||
}
|
||||
|
||||
if (commodity() != amt.commodity())
|
||||
throw_(amount_error,
|
||||
"Subtracting amounts with different commodities: " <<
|
||||
(has_commodity() ? commodity().symbol() : "NONE") <<
|
||||
" != " <<
|
||||
(amt.has_commodity() ? amt.commodity().symbol() : "NONE"));
|
||||
_("Subtracting amounts with different commodities: %1 != %2")
|
||||
<< (has_commodity() ? commodity().symbol() : _("NONE"))
|
||||
<< (amt.has_commodity() ? amt.commodity().symbol() : _("NONE")));
|
||||
|
||||
_dup();
|
||||
|
||||
|
|
@ -324,11 +322,11 @@ amount_t& amount_t::operator*=(const amount_t& amt)
|
|||
|
||||
if (! quantity || ! amt.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)
|
||||
throw_(amount_error, "Cannot multiply an uninitialized amount by an amount");
|
||||
throw_(amount_error, _("Cannot multiply an uninitialized amount by an amount"));
|
||||
else
|
||||
throw_(amount_error, "Cannot multiply two uninitialized amounts");
|
||||
throw_(amount_error, _("Cannot multiply two uninitialized amounts"));
|
||||
}
|
||||
|
||||
_dup();
|
||||
|
|
@ -354,15 +352,15 @@ amount_t& amount_t::operator/=(const amount_t& amt)
|
|||
|
||||
if (! quantity || ! amt.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)
|
||||
throw_(amount_error, "Cannot divide an uninitialized amount by an amount");
|
||||
throw_(amount_error, _("Cannot divide an uninitialized amount by an amount"));
|
||||
else
|
||||
throw_(amount_error, "Cannot divide two uninitialized amounts");
|
||||
throw_(amount_error, _("Cannot divide two uninitialized amounts"));
|
||||
}
|
||||
|
||||
if (! amt)
|
||||
throw_(amount_error, "Divide by zero");
|
||||
throw_(amount_error, _("Divide by zero"));
|
||||
|
||||
_dup();
|
||||
|
||||
|
|
@ -393,7 +391,7 @@ amount_t::precision_t amount_t::precision() const
|
|||
{
|
||||
if (! quantity)
|
||||
throw_(amount_error,
|
||||
"Cannot determine precision of an uninitialized amount");
|
||||
_("Cannot determine precision of an uninitialized amount"));
|
||||
|
||||
return quantity->prec;
|
||||
}
|
||||
|
|
@ -402,7 +400,7 @@ bool amount_t::keep_precision() const
|
|||
{
|
||||
if (! quantity)
|
||||
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);
|
||||
}
|
||||
|
|
@ -411,7 +409,7 @@ void amount_t::set_keep_precision(const bool keep) const
|
|||
{
|
||||
if (! quantity)
|
||||
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)
|
||||
quantity->add_flags(BIGINT_KEEP_PREC);
|
||||
|
|
@ -423,7 +421,7 @@ amount_t::precision_t amount_t::display_precision() const
|
|||
{
|
||||
if (! quantity)
|
||||
throw_(amount_error,
|
||||
"Cannot determine display precision of an uninitialized amount");
|
||||
_("Cannot determine display precision of an uninitialized amount"));
|
||||
|
||||
commodity_t& comm(commodity());
|
||||
|
||||
|
|
@ -441,14 +439,14 @@ void amount_t::in_place_negate()
|
|||
_dup();
|
||||
mpq_neg(MP(quantity), MP(quantity));
|
||||
} else {
|
||||
throw_(amount_error, "Cannot negate an uninitialized amount");
|
||||
throw_(amount_error, _("Cannot negate an uninitialized amount"));
|
||||
}
|
||||
}
|
||||
|
||||
amount_t amount_t::inverted() const
|
||||
{
|
||||
if (! quantity)
|
||||
throw_(amount_error, "Cannot invert an uninitialized amount");
|
||||
throw_(amount_error, _("Cannot invert an uninitialized amount"));
|
||||
|
||||
amount_t t(*this);
|
||||
t._dup();
|
||||
|
|
@ -460,7 +458,7 @@ amount_t amount_t::inverted() const
|
|||
amount_t amount_t::rounded() const
|
||||
{
|
||||
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())
|
||||
return *this;
|
||||
|
||||
|
|
@ -474,7 +472,7 @@ amount_t amount_t::rounded() const
|
|||
amount_t amount_t::unrounded() const
|
||||
{
|
||||
if (! quantity)
|
||||
throw_(amount_error, "Cannot unround an uninitialized amount");
|
||||
throw_(amount_error, _("Cannot unround an uninitialized amount"));
|
||||
else if (keep_precision())
|
||||
return *this;
|
||||
|
||||
|
|
@ -488,7 +486,7 @@ amount_t amount_t::unrounded() const
|
|||
void amount_t::in_place_reduce()
|
||||
{
|
||||
if (! quantity)
|
||||
throw_(amount_error, "Cannot reduce an uninitialized amount");
|
||||
throw_(amount_error, _("Cannot reduce an uninitialized amount"));
|
||||
|
||||
while (commodity_ && commodity().smaller()) {
|
||||
*this *= commodity().smaller()->number();
|
||||
|
|
@ -499,7 +497,7 @@ void amount_t::in_place_reduce()
|
|||
void amount_t::in_place_unreduce()
|
||||
{
|
||||
if (! quantity)
|
||||
throw_(amount_error, "Cannot unreduce an uninitialized amount");
|
||||
throw_(amount_error, _("Cannot unreduce an uninitialized amount"));
|
||||
|
||||
amount_t temp = *this;
|
||||
commodity_t * comm = commodity_;
|
||||
|
|
@ -546,7 +544,7 @@ amount_t::value(const bool primary_only,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
throw_(amount_error, "Cannot determine value of an uninitialized amount");
|
||||
throw_(amount_error, _("Cannot determine value of an uninitialized amount"));
|
||||
}
|
||||
return none;
|
||||
}
|
||||
|
|
@ -555,7 +553,7 @@ amount_t::value(const bool primary_only,
|
|||
int amount_t::sign() const
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
|
@ -654,7 +652,7 @@ namespace {
|
|||
bool amount_t::is_zero() const
|
||||
{
|
||||
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 (keep_precision() || quantity->prec <= commodity().precision()) {
|
||||
|
|
@ -687,7 +685,7 @@ bool amount_t::is_zero() const
|
|||
double amount_t::to_double() const
|
||||
{
|
||||
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);
|
||||
return mpfr_get_d(tempf, GMP_RNDN);
|
||||
|
|
@ -696,7 +694,7 @@ double amount_t::to_double() const
|
|||
long amount_t::to_long() const
|
||||
{
|
||||
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);
|
||||
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;
|
||||
|
||||
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())
|
||||
throw_(amount_error, "Cannot annotate an amount with no commodity");
|
||||
throw_(amount_error, _("Cannot annotate an amount with no commodity"));
|
||||
|
||||
if (commodity().annotated) {
|
||||
this_ann = &as_annotated_commodity(commodity());
|
||||
|
|
@ -754,7 +752,7 @@ bool amount_t::is_annotated() const
|
|||
{
|
||||
if (! quantity)
|
||||
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);
|
||||
return commodity().annotated;
|
||||
|
|
@ -764,11 +762,11 @@ annotation_t& amount_t::annotation()
|
|||
{
|
||||
if (! quantity)
|
||||
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())
|
||||
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()));
|
||||
return ann_comm.details;
|
||||
|
|
@ -778,7 +776,7 @@ amount_t amount_t::strip_annotations(const keep_details_t& what_to_keep) const
|
|||
{
|
||||
if (! quantity)
|
||||
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())) {
|
||||
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))
|
||||
return false;
|
||||
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
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ balance_t& balance_t::operator+=(const amount_t& amt)
|
|||
{
|
||||
if (amt.is_null())
|
||||
throw_(balance_error,
|
||||
"Cannot add an uninitialized amount to a balance");
|
||||
_("Cannot add an uninitialized amount to a balance"));
|
||||
|
||||
if (amt.is_realzero())
|
||||
return *this;
|
||||
|
|
@ -70,7 +70,7 @@ balance_t& balance_t::operator-=(const amount_t& amt)
|
|||
{
|
||||
if (amt.is_null())
|
||||
throw_(balance_error,
|
||||
"Cannot subtract an uninitialized amount from a balance");
|
||||
_("Cannot subtract an uninitialized amount from a balance"));
|
||||
|
||||
if (amt.is_realzero())
|
||||
return *this;
|
||||
|
|
@ -90,7 +90,7 @@ balance_t& balance_t::operator*=(const amount_t& amt)
|
|||
{
|
||||
if (amt.is_null())
|
||||
throw_(balance_error,
|
||||
"Cannot multiply a balance by an uninitialized amount");
|
||||
_("Cannot multiply a balance by an uninitialized amount"));
|
||||
|
||||
if (is_realzero()) {
|
||||
;
|
||||
|
|
@ -112,12 +112,12 @@ balance_t& balance_t::operator*=(const amount_t& amt)
|
|||
amounts.begin()->second *= amt;
|
||||
else
|
||||
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 {
|
||||
assert(amounts.size() > 1);
|
||||
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;
|
||||
}
|
||||
|
|
@ -126,13 +126,13 @@ balance_t& balance_t::operator/=(const amount_t& amt)
|
|||
{
|
||||
if (amt.is_null())
|
||||
throw_(balance_error,
|
||||
"Cannot divide a balance by an uninitialized amount");
|
||||
_("Cannot divide a balance by an uninitialized amount"));
|
||||
|
||||
if (is_realzero()) {
|
||||
;
|
||||
}
|
||||
else if (amt.is_realzero()) {
|
||||
throw_(balance_error, "Divide by zero");
|
||||
throw_(balance_error, _("Divide by zero"));
|
||||
}
|
||||
else if (! amt.commodity()) {
|
||||
// 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;
|
||||
else
|
||||
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 {
|
||||
assert(amounts.size() > 1);
|
||||
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;
|
||||
}
|
||||
|
|
@ -193,7 +193,7 @@ balance_t::commodity_amount(const optional<const commodity_t&>& commodity) const
|
|||
return temp.commodity_amount(commodity);
|
||||
|
||||
throw_(amount_error,
|
||||
"Requested amount of a balance with multiple commodities: " << temp);
|
||||
_("Requested amount of a balance with multiple commodities: %1") << temp);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ public:
|
|||
TRACE_CTOR(balance_t, "const amount_t&");
|
||||
if (amt.is_null())
|
||||
throw_(balance_error,
|
||||
"Cannot initialize a balance from an uninitialized amount");
|
||||
_("Cannot initialize a balance from an uninitialized amount"));
|
||||
if (! amt.is_realzero())
|
||||
amounts.insert(amounts_map::value_type(&amt.commodity(), amt));
|
||||
}
|
||||
|
|
@ -165,7 +165,7 @@ public:
|
|||
balance_t& operator=(const amount_t& amt) {
|
||||
if (amt.is_null())
|
||||
throw_(balance_error,
|
||||
"Cannot assign an uninitialized amount to a balance");
|
||||
_("Cannot assign an uninitialized amount to a balance"));
|
||||
|
||||
amounts.clear();
|
||||
if (! amt.is_realzero())
|
||||
|
|
@ -209,7 +209,7 @@ public:
|
|||
bool operator==(const amount_t& amt) const {
|
||||
if (amt.is_null())
|
||||
throw_(balance_error,
|
||||
"Cannot compare a balance to an uninitialized amount");
|
||||
_("Cannot compare a balance to an uninitialized amount"));
|
||||
|
||||
if (amt.is_realzero())
|
||||
return amounts.empty();
|
||||
|
|
@ -413,12 +413,12 @@ public:
|
|||
*/
|
||||
amount_t to_amount() const {
|
||||
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)
|
||||
return amounts.begin()->second;
|
||||
else
|
||||
throw_(balance_error,
|
||||
"Cannot convert a balance with multiple commodities to an amount");
|
||||
_("Cannot convert a balance with multiple commodities to an amount"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ optional<commodity_t::base_t::history_t&>
|
|||
#if 0
|
||||
// jww (2008-09-20): Document which option switch to use here
|
||||
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
|
||||
comm = (*histories.begin()).first;
|
||||
} else {
|
||||
|
|
@ -515,7 +515,7 @@ void commodity_t::parse_symbol(std::istream& in, string& symbol)
|
|||
if (c == '"')
|
||||
in.get(c);
|
||||
else
|
||||
throw_(amount_error, "Quoted commodity symbol lacks closing quote");
|
||||
throw_(amount_error, _("Quoted commodity symbol lacks closing quote"));
|
||||
} else {
|
||||
char * _p = buf;
|
||||
c = in.peek();
|
||||
|
|
@ -582,7 +582,7 @@ void commodity_t::parse_symbol(char *& p, string& symbol)
|
|||
if (*p == '"') {
|
||||
char * q = std::strchr(p + 1, '"');
|
||||
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);
|
||||
p = q + 2;
|
||||
} else {
|
||||
|
|
@ -594,7 +594,7 @@ void commodity_t::parse_symbol(char *& p, string& symbol)
|
|||
p += symbol.length();
|
||||
}
|
||||
if (symbol.empty())
|
||||
throw_(amount_error, "Failed to parse commodity");
|
||||
throw_(amount_error, _("Failed to parse commodity"));
|
||||
}
|
||||
|
||||
bool commodity_t::valid() const
|
||||
|
|
@ -627,14 +627,14 @@ void annotation_t::parse(std::istream& in)
|
|||
char c = peek_next_nonws(in);
|
||||
if (c == '{') {
|
||||
if (price)
|
||||
throw_(amount_error, "Commodity specifies more than one price");
|
||||
throw_(amount_error, _("Commodity specifies more than one price"));
|
||||
|
||||
in.get(c);
|
||||
READ_INTO(in, buf, 255, c, c != '}');
|
||||
if (c == '}')
|
||||
in.get(c);
|
||||
else
|
||||
throw_(amount_error, "Commodity price lacks closing brace");
|
||||
throw_(amount_error, _("Commodity price lacks closing brace"));
|
||||
|
||||
amount_t temp;
|
||||
temp.parse(buf, amount_t::PARSE_NO_MIGRATE);
|
||||
|
|
@ -653,27 +653,27 @@ void annotation_t::parse(std::istream& in)
|
|||
}
|
||||
else if (c == '[') {
|
||||
if (date)
|
||||
throw_(amount_error, "Commodity specifies more than one date");
|
||||
throw_(amount_error, _("Commodity specifies more than one date"));
|
||||
|
||||
in.get(c);
|
||||
READ_INTO(in, buf, 255, c, c != ']');
|
||||
if (c == ']')
|
||||
in.get(c);
|
||||
else
|
||||
throw_(amount_error, "Commodity date lacks closing bracket");
|
||||
throw_(amount_error, _("Commodity date lacks closing bracket"));
|
||||
|
||||
date = parse_date(buf);
|
||||
}
|
||||
else if (c == '(') {
|
||||
if (tag)
|
||||
throw_(amount_error, "Commodity specifies more than one tag");
|
||||
throw_(amount_error, _("Commodity specifies more than one tag"));
|
||||
|
||||
in.get(c);
|
||||
READ_INTO(in, buf, 255, c, c != ')');
|
||||
if (c == ')')
|
||||
in.get(c);
|
||||
else
|
||||
throw_(amount_error, "Commodity tag lacks closing parenthesis");
|
||||
throw_(amount_error, _("Commodity tag lacks closing parenthesis"));
|
||||
|
||||
tag = buf;
|
||||
}
|
||||
|
|
@ -895,7 +895,7 @@ namespace {
|
|||
assert(details);
|
||||
|
||||
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;
|
||||
comm.print(name);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace {
|
|||
|
||||
if (sort_values.back().value.is_null())
|
||||
throw_(calc_error,
|
||||
"Could not determine sorting value based an expression");
|
||||
_("Could not determine sorting value based an expression"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,27 +58,27 @@ namespace {
|
|||
void dump(std::ostream& out) const
|
||||
{
|
||||
if (date)
|
||||
out << "Date: " << *date << std::endl;
|
||||
out << _("Date: ") << *date << std::endl;
|
||||
else
|
||||
out << "Date: <today>" << std::endl;
|
||||
out << _("Date: <today>") << std::endl;
|
||||
|
||||
if (eff_date)
|
||||
out << "Effective: " << *eff_date << std::endl;
|
||||
out << _("Effective: ") << *eff_date << std::endl;
|
||||
|
||||
if (code)
|
||||
out << "Code: " << *code << std::endl;
|
||||
out << _("Code: ") << *code << std::endl;
|
||||
if (note)
|
||||
out << "Note: " << *note << std::endl;
|
||||
out << _("Note: ") << *note << std::endl;
|
||||
|
||||
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;
|
||||
else
|
||||
out << "Payee mask: " << payee_mask << std::endl;
|
||||
out << _("Payee mask: ") << payee_mask << std::endl;
|
||||
|
||||
if (posts.empty()) {
|
||||
out << std::endl
|
||||
<< "<Posting copied from last related transaction>"
|
||||
<< _("<Posting copied from last related transaction>")
|
||||
<< std::endl;
|
||||
} else {
|
||||
bool has_only_from = true;
|
||||
|
|
@ -92,19 +92,21 @@ namespace {
|
|||
}
|
||||
|
||||
foreach (const post_template_t& post, posts) {
|
||||
straccstream accum;
|
||||
out << std::endl
|
||||
<< "[Posting \"" << (post.from ? "from" : "to")
|
||||
<< "\"]" << std::endl;
|
||||
<< ACCUM(accum << _("[Posting \"%1\"]_")
|
||||
<< (post.from ? _("from") : _("to")))
|
||||
<< std::endl;
|
||||
|
||||
if (post.account_mask)
|
||||
out << " Account mask: " << *post.account_mask << std::endl;
|
||||
out << _(" Account mask: ") << *post.account_mask << std::endl;
|
||||
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
|
||||
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)
|
||||
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,
|
||||
value_t::sequence_t::const_iterator end)
|
||||
{
|
||||
regex date_mask("([0-9]+(?:[-/.][0-9]+)?(?:[-/.][0-9]+))?(?:=.*)?");
|
||||
regex dow_mask("(sun|mon|tue|wed|thu|fri|sat)");
|
||||
regex date_mask(_("([0-9]+(?:[-/.][0-9]+)?(?:[-/.][0-9]+))?(?:=.*)?"));
|
||||
regex dow_mask(_("(sun|mon|tue|wed|thu|fri|sat)"));
|
||||
smatch what;
|
||||
|
||||
xact_template_t tmpl;
|
||||
|
|
@ -236,7 +238,7 @@ namespace {
|
|||
report_t& report)
|
||||
{
|
||||
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;
|
||||
journal_t& journal(*report.session.journal.get());
|
||||
|
|
@ -281,8 +283,8 @@ namespace {
|
|||
added->add_post(new post_t(*post));
|
||||
} else {
|
||||
throw_(std::runtime_error,
|
||||
"No accounts, and no past transaction matching '"
|
||||
<< tmpl.payee_mask <<"'");
|
||||
_("No accounts, and no past transaction matching '%1'")
|
||||
<< tmpl.payee_mask);
|
||||
}
|
||||
} else {
|
||||
bool any_post_has_amount = false;
|
||||
|
|
@ -346,9 +348,9 @@ namespace {
|
|||
} else {
|
||||
|
||||
if (post.from)
|
||||
new_post->account = journal.find_account("Liabilities:Unknown");
|
||||
new_post->account = journal.find_account(_("Liabilities:Unknown"));
|
||||
else
|
||||
new_post->account = journal.find_account("Expenses:Unknown");
|
||||
new_post->account = journal.find_account(_("Expenses:Unknown"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -382,7 +384,7 @@ namespace {
|
|||
! added->finalize() ||
|
||||
! journal.xact_finalize_hooks.run_hooks(*added.get(), true))
|
||||
throw_(std::runtime_error,
|
||||
"Failed to finalize derived transaction (check commodities)");
|
||||
_("Failed to finalize derived transaction (check commodities)"));
|
||||
|
||||
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 end = args.value().end();
|
||||
|
||||
out << "--- Input arguments ---" << std::endl;
|
||||
out << _("--- Input arguments ---") << std::endl;
|
||||
args.value().dump(out);
|
||||
out << std::endl << std::endl;
|
||||
|
||||
xact_template_t tmpl = args_to_xact_template(begin, end);
|
||||
|
||||
out << "--- Transaction template ---" << std::endl;
|
||||
out << _("--- Transaction template ---") << std::endl;
|
||||
tmpl.dump(out);
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ value_t expr_t::calc(scope_t& scope)
|
|||
}
|
||||
catch (const std::exception& err) {
|
||||
if (locus) {
|
||||
add_error_context("While evaluating value expression:");
|
||||
add_error_context(_("While evaluating value expression:"));
|
||||
add_error_context(op_context(ptr, locus));
|
||||
}
|
||||
throw;
|
||||
|
|
@ -207,7 +207,7 @@ std::ostream& operator<<(std::ostream& out, 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
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ pass_down_posts::pass_down_posts(post_handler_ptr handler,
|
|||
item_handler<post_t>::operator()(*post);
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
add_error_context(item_context(*post, "While handling posting"));
|
||||
add_error_context(item_context(*post, _("While handling posting")));
|
||||
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_t& xact = xact_temps.back();
|
||||
xact.payee = "Commodities revalued";
|
||||
xact.payee = _("Commodities revalued");
|
||||
xact._date = is_valid(date) ? date : post->date();
|
||||
|
||||
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_t& xact = xact_temps.back();
|
||||
xact.payee = "Opening Balances";
|
||||
xact.payee = _("Opening Balances");
|
||||
xact._date = finish;
|
||||
|
||||
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_t& xact = xact_temps.back();
|
||||
xact.payee = "Budget transaction";
|
||||
xact.payee = _("Budget transaction");
|
||||
xact._date = begin;
|
||||
|
||||
post_temps.push_back(post);
|
||||
|
|
@ -802,7 +802,7 @@ void forecast_posts::flush()
|
|||
|
||||
xact_temps.push_back(xact_t());
|
||||
xact_t& xact = xact_temps.back();
|
||||
xact.payee = "Forecast transaction";
|
||||
xact.payee = _("Forecast transaction");
|
||||
xact._date = begin;
|
||||
|
||||
post_temps.push_back(post);
|
||||
|
|
|
|||
|
|
@ -389,7 +389,7 @@ public:
|
|||
display_predicate(_display_predicate),
|
||||
only_predicate(_only_predicate), count(0),
|
||||
last_xact(NULL), last_post(NULL),
|
||||
totals_account(NULL, "<Total>"),
|
||||
totals_account(NULL, _("<Total>")),
|
||||
only_collapse_if_zero(_only_collapse_if_zero) {
|
||||
TRACE_CTOR(collapse_posts, "post_handler_ptr");
|
||||
}
|
||||
|
|
@ -468,7 +468,7 @@ public:
|
|||
bool _changed_values_only)
|
||||
: item_handler<post_t>(handler), total_expr(_total_expr),
|
||||
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,
|
||||
"post_handler_ptr, const expr_t&, report_t&, bool");
|
||||
}
|
||||
|
|
@ -583,7 +583,7 @@ public:
|
|||
bool _exact_periods = false,
|
||||
bool _generate_empty_posts = false)
|
||||
: 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),
|
||||
generate_empty_posts(_generate_empty_posts) {
|
||||
TRACE_CTOR(interval_posts,
|
||||
|
|
@ -615,9 +615,9 @@ class posts_as_equity : public subtotal_posts
|
|||
public:
|
||||
posts_as_equity(post_handler_ptr _handler, expr_t& 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&");
|
||||
balance_account = equity_account.find_account("Opening Balances");
|
||||
balance_account = equity_account.find_account(_("Opening Balances"));
|
||||
}
|
||||
virtual ~posts_as_equity() throw() {
|
||||
TRACE_DTOR(posts_as_equity);
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ void format_t::format(std::ostream& out_str, scope_t& scope)
|
|||
value.print(out, elem->min_width);
|
||||
}
|
||||
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));
|
||||
throw;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,8 +102,8 @@ void global_scope_t::read_init()
|
|||
if (session().read_journal(init_file) > 0 ||
|
||||
session().journal->auto_xacts.size() > 0 ||
|
||||
session().journal->period_xacts.size() > 0) {
|
||||
throw_(parse_error, "Transactions found in initialization file '"
|
||||
<< init_file << "'");
|
||||
throw_(parse_error, _("Transactions found in initialization file '%1'")
|
||||
<< init_file);
|
||||
}
|
||||
|
||||
TRACE_FINISH(init, 1);
|
||||
|
|
@ -132,7 +132,7 @@ void global_scope_t::report_error(const std::exception& err)
|
|||
if (! context.empty())
|
||||
std::cerr << context << std::endl;
|
||||
|
||||
std::cerr << "Error: " << err.what() << std::endl;
|
||||
std::cerr << _("Error: ") << err.what() << std::endl;
|
||||
} else {
|
||||
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)))
|
||||
is_precommand = true;
|
||||
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
|
||||
// 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();
|
||||
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
|
||||
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]);
|
||||
}
|
||||
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++;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -100,11 +100,11 @@ public:
|
|||
|
||||
void show_version_info(std::ostream& out) {
|
||||
out <<
|
||||
"Ledger " << ledger::version << ", the command-line accounting tool";
|
||||
"Ledger " << ledger::version << _(", the command-line accounting tool");
|
||||
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\
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ void interactive_t::verify_arguments() const
|
|||
value_t::sequence_t::const_iterator i;
|
||||
|
||||
const char * p = spec.c_str();
|
||||
const char * label = "unknown";
|
||||
const char * label = _("unknown");
|
||||
bool wrong_arg = false;
|
||||
bool dont_skip = false;
|
||||
bool optional = *p == '&';
|
||||
|
|
@ -62,22 +62,22 @@ void interactive_t::verify_arguments() const
|
|||
"Want " << *p << " got: " << next_arg->label());
|
||||
switch (*p) {
|
||||
case 'a':
|
||||
label = "an amount";
|
||||
label = _("an amount");
|
||||
wrong_arg = (! next_arg->is_long() &&
|
||||
! next_arg->is_amount() &&
|
||||
! next_arg->is_balance());
|
||||
break;
|
||||
case 'b':
|
||||
label = "a boolean";
|
||||
label = _("a boolean");
|
||||
wrong_arg = false; // booleans are converted
|
||||
break;
|
||||
case 'd':
|
||||
label = "a date";
|
||||
label = _("a date");
|
||||
wrong_arg = ! next_arg->is_date();
|
||||
break;
|
||||
case 'i':
|
||||
case 'l':
|
||||
label = "an integer";
|
||||
label = _("an integer");
|
||||
if (next_arg->is_long() ||
|
||||
(next_arg->is_amount() &&
|
||||
! next_arg->as_amount().has_commodity())) {
|
||||
|
|
@ -97,28 +97,28 @@ void interactive_t::verify_arguments() const
|
|||
}
|
||||
break;
|
||||
case 'm':
|
||||
label = "a regex";
|
||||
label = _("a regex");
|
||||
wrong_arg = ! next_arg->is_mask();
|
||||
break;
|
||||
case 's':
|
||||
label = "a string";
|
||||
label = _("a string");
|
||||
wrong_arg = ! next_arg->is_string();
|
||||
break;
|
||||
case 't':
|
||||
label = "a date or time";
|
||||
label = _("a date or time");
|
||||
wrong_arg = (! next_arg->is_date() &&
|
||||
! next_arg->is_datetime());
|
||||
break;
|
||||
case 'v':
|
||||
label = "any value";
|
||||
label = _("any value");
|
||||
wrong_arg = false;
|
||||
break;
|
||||
case 'P':
|
||||
label = "a pointer";
|
||||
label = _("a pointer");
|
||||
wrong_arg = ! next_arg->is_pointer();
|
||||
break;
|
||||
case 'S':
|
||||
label = "a sequence";
|
||||
label = _("a sequence");
|
||||
wrong_arg = false;
|
||||
break;
|
||||
case '&':
|
||||
|
|
@ -157,14 +157,14 @@ void interactive_t::verify_arguments() const
|
|||
|
||||
if (wrong_arg) {
|
||||
throw_(std::logic_error,
|
||||
"Expected " << label << " for argument " << offset
|
||||
<< ", but received " << vlabel);
|
||||
_("Expected %1 for argument %2, but received %3")
|
||||
<< label << offset << vlabel);
|
||||
}
|
||||
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) {
|
||||
throw_(std::logic_error, "Too many arguments to function");
|
||||
throw_(std::logic_error, _("Too many arguments to function"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
10
src/item.cc
10
src/item.cc
|
|
@ -397,7 +397,7 @@ string item_context(const item_t& item, const string& desc)
|
|||
{
|
||||
std::size_t len = item.end_pos - item.beg_pos;
|
||||
if (! len)
|
||||
return "<no item context>";
|
||||
return _("<no item context>");
|
||||
|
||||
assert(len > 0);
|
||||
assert(len < 2048);
|
||||
|
|
@ -405,17 +405,17 @@ string item_context(const item_t& item, const string& desc)
|
|||
std::ostringstream out;
|
||||
|
||||
if (item.pathname == path("/dev/stdin")) {
|
||||
out << desc << " from standard input:";
|
||||
out << desc << _(" from standard input:");
|
||||
return out.str();
|
||||
}
|
||||
|
||||
out << desc << " from \"" << item.pathname.string() << "\"";
|
||||
out << desc << _(" from \"") << item.pathname.string() << "\"";
|
||||
|
||||
if (item.beg_line != item.end_line)
|
||||
out << ", lines " << item.beg_line << "-"
|
||||
out << _(", lines ") << item.beg_line << "-"
|
||||
<< item.end_line << ":\n";
|
||||
else
|
||||
out << ", line " << item.beg_line << ":\n";
|
||||
out << _(", line ") << item.beg_line << ":\n";
|
||||
|
||||
print_item(out, item, "> ");
|
||||
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ int main(int argc, char * argv[], char * envp[])
|
|||
std::free(expansion);
|
||||
std::free(p);
|
||||
throw_(std::logic_error,
|
||||
"Failed to expand history reference '" << p << "'");
|
||||
_("Failed to expand history reference '%1'") << p);
|
||||
}
|
||||
else if (expansion) {
|
||||
add_history(expansion);
|
||||
|
|
|
|||
16
src/op.cc
16
src/op.cc
|
|
@ -67,10 +67,10 @@ expr_t::ptr_op_t expr_t::op_t::compile(scope_t& scope)
|
|||
if (left()->left()->is_ident())
|
||||
scope.define(left()->left()->as_ident(), this);
|
||||
else
|
||||
throw_(compile_error, "Invalid function definition");
|
||||
throw_(compile_error, _("Invalid function definition"));
|
||||
break;
|
||||
default:
|
||||
throw_(compile_error, "Invalid function definition");
|
||||
throw_(compile_error, _("Invalid function definition"));
|
||||
}
|
||||
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: {
|
||||
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
|
||||
// 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();
|
||||
|
||||
if (! varname->is_ident())
|
||||
throw_(calc_error, "Invalid function definition");
|
||||
throw_(calc_error, _("Invalid function definition"));
|
||||
else if (args_index == args_count)
|
||||
local_scope.define(varname->as_ident(), wrap_value(false));
|
||||
else
|
||||
|
|
@ -151,7 +151,7 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus)
|
|||
|
||||
if (args_index < args_count)
|
||||
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);
|
||||
break;
|
||||
|
|
@ -173,10 +173,10 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus)
|
|||
}
|
||||
if (right()->kind != IDENT)
|
||||
throw_(calc_error,
|
||||
"Right operand of . operator must be an identifier");
|
||||
_("Right operand of . operator must be an identifier"));
|
||||
else
|
||||
throw_(calc_error,
|
||||
"Failed to lookup member '" << right()->as_ident() << "'");
|
||||
_("Failed to lookup member '%1'") << right()->as_ident());
|
||||
break;
|
||||
|
||||
case O_CALL: {
|
||||
|
|
@ -190,7 +190,7 @@ value_t expr_t::op_t::calc(scope_t& scope, ptr_op_t * locus)
|
|||
|
||||
func = func->left();
|
||||
if (! func)
|
||||
throw_(calc_error, "Calling unknown function '" << name << "'");
|
||||
throw_(calc_error, _("Calling unknown function '%1'") << name);
|
||||
|
||||
if (func->is_function())
|
||||
result = func->as_function()(call_args);
|
||||
|
|
|
|||
|
|
@ -86,11 +86,10 @@ namespace {
|
|||
}
|
||||
catch (const std::exception& err) {
|
||||
if (name[0] == '-')
|
||||
add_error_context("While parsing option '" << name << "':");
|
||||
add_error_context(_("While parsing option '%1'") << name);
|
||||
|
||||
else
|
||||
add_error_context("While parsing environent variable '"
|
||||
<< name << "':");
|
||||
add_error_context(_("While parsing environent variable '%1'") << name);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
@ -131,8 +130,8 @@ void process_environment(const char ** envp, const string& tag,
|
|||
process_option(string(buf), scope, q + 1, value);
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
add_error_context("While parsing environment variable option '"
|
||||
<< *p << "':");
|
||||
add_error_context(_("While parsing environment variable option '%1':")
|
||||
<< *p);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
@ -192,19 +191,19 @@ strings_list process_arguments(strings_list args, scope_t& scope)
|
|||
|
||||
op_bool_tuple opt(find_option(scope, opt_name));
|
||||
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) {
|
||||
value = (*i).c_str();
|
||||
DEBUG("option.args", " read option value from arg: " << value);
|
||||
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,
|
||||
string("--") + name);
|
||||
}
|
||||
else if ((*i)[1] == '\0') {
|
||||
throw_(option_error, "illegal option -");
|
||||
throw_(option_error, _("illegal option -%1") << (*i)[0]);
|
||||
}
|
||||
else {
|
||||
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]) {
|
||||
op_bool_tuple opt(find_option(scope, c));
|
||||
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));
|
||||
}
|
||||
|
|
@ -227,7 +226,7 @@ strings_list process_arguments(strings_list args, scope_t& scope)
|
|||
DEBUG("option.args", " read option value from arg: " << value);
|
||||
if (value == NULL)
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,10 +104,6 @@ public:
|
|||
return out.str();
|
||||
}
|
||||
|
||||
virtual void help(std::ostream& out) {
|
||||
out << "No help for " << desc() << "\n";
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
return handled;
|
||||
}
|
||||
|
|
@ -115,7 +111,7 @@ public:
|
|||
string& str() {
|
||||
assert(handled);
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
@ -140,7 +136,7 @@ public:
|
|||
virtual void handler(call_scope_t& args) {
|
||||
if (wants_arg) {
|
||||
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]);
|
||||
} else {
|
||||
on_only();
|
||||
|
|
@ -179,7 +175,6 @@ public:
|
|||
vartype var ; \
|
||||
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_(var) virtual void handler_thunk(call_scope_t& var)
|
||||
|
||||
|
|
|
|||
|
|
@ -105,53 +105,56 @@ void gather_statistics::flush()
|
|||
{
|
||||
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)
|
||||
if (! pathname.empty())
|
||||
out << " " << pathname.string() << std::endl;
|
||||
out << std::endl;
|
||||
|
||||
out << " Unique payees: ";
|
||||
out << _(" Unique payees: ");
|
||||
out.width(8);
|
||||
out << std::right << statistics.payees_referenced.size() << std::endl;
|
||||
|
||||
out << " Unique accounts: ";
|
||||
out << _(" Unique accounts: ");
|
||||
out.width(8);
|
||||
out << std::right << statistics.accounts_referenced.size() << std::endl;
|
||||
|
||||
out << " Number of transactions: " ;
|
||||
out << _(" Number of transactions: ") ;
|
||||
out.width(8);
|
||||
out << std::right << statistics.total_xacts << std::endl;
|
||||
|
||||
out << " Number of postings: ";
|
||||
out << _(" Number of postings: ");
|
||||
out.width(8);
|
||||
out << std::right << statistics.total_posts;
|
||||
|
||||
out << " (";
|
||||
out.precision(2);
|
||||
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 << std::right << (CURRENT_DATE() - statistics.latest_post).days()
|
||||
<< std::endl;
|
||||
|
||||
out << " Posts in last 7 days: ";
|
||||
out << _(" Posts in last 7 days: ");
|
||||
out.width(8);
|
||||
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 << std::right << statistics.total_last_30_days << std::endl;
|
||||
out << " Posts seen this month: ";
|
||||
out << _(" Posts seen this month: ");
|
||||
out.width(8);
|
||||
out << std::right << statistics.total_this_month << std::endl;
|
||||
|
||||
out << " Uncleared postings: ";
|
||||
out << _(" Uncleared postings: ");
|
||||
out.width(8);
|
||||
out << std::right << statistics.total_uncleared_posts << std::endl;
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ expr_t::parser_t::parse_dot_expr(std::istream& in,
|
|||
node->set_right(parse_value_term(in, tflags));
|
||||
if (! node->right())
|
||||
throw_(parse_error,
|
||||
tok.symbol << " operator not followed by argument");
|
||||
_("%1 operator not followed by argument") << tok.symbol);
|
||||
} else {
|
||||
push_token(tok);
|
||||
break;
|
||||
|
|
@ -124,7 +124,7 @@ expr_t::parser_t::parse_unary_expr(std::istream& in,
|
|||
ptr_op_t term(parse_dot_expr(in, tflags));
|
||||
if (! term)
|
||||
throw_(parse_error,
|
||||
tok.symbol << " operator not followed by argument");
|
||||
_("%1 operator not followed by argument") << tok.symbol);
|
||||
|
||||
// A very quick optimization
|
||||
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));
|
||||
if (! term)
|
||||
throw_(parse_error,
|
||||
tok.symbol << " operator not followed by argument");
|
||||
_("%1 operator not followed by argument") << tok.symbol);
|
||||
|
||||
// A very quick optimization
|
||||
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));
|
||||
if (! node->right())
|
||||
throw_(parse_error,
|
||||
tok.symbol << " operator not followed by argument");
|
||||
_("%1 operator not followed by argument") << tok.symbol);
|
||||
} else {
|
||||
push_token(tok);
|
||||
break;
|
||||
|
|
@ -212,7 +212,7 @@ expr_t::parser_t::parse_add_expr(std::istream& in,
|
|||
node->set_right(parse_mul_expr(in, tflags));
|
||||
if (! node->right())
|
||||
throw_(parse_error,
|
||||
tok.symbol << " operator not followed by argument");
|
||||
_("%1 operator not followed by argument") << tok.symbol);
|
||||
} else {
|
||||
push_token(tok);
|
||||
break;
|
||||
|
|
@ -282,7 +282,7 @@ expr_t::parser_t::parse_logic_expr(std::istream& in,
|
|||
|
||||
if (! node->right())
|
||||
throw_(parse_error,
|
||||
tok.symbol << " operator not followed by argument");
|
||||
_("%1 operator not followed by argument") << tok.symbol);
|
||||
|
||||
if (negate) {
|
||||
prev = node;
|
||||
|
|
@ -314,7 +314,7 @@ expr_t::parser_t::parse_and_expr(std::istream& in,
|
|||
node->set_right(parse_logic_expr(in, tflags));
|
||||
if (! node->right())
|
||||
throw_(parse_error,
|
||||
tok.symbol << " operator not followed by argument");
|
||||
_("%1 operator not followed by argument") << tok.symbol);
|
||||
} else {
|
||||
push_token(tok);
|
||||
break;
|
||||
|
|
@ -341,7 +341,7 @@ expr_t::parser_t::parse_or_expr(std::istream& in,
|
|||
node->set_right(parse_and_expr(in, tflags));
|
||||
if (! node->right())
|
||||
throw_(parse_error,
|
||||
tok.symbol << " operator not followed by argument");
|
||||
_("%1 operator not followed by argument") << tok.symbol);
|
||||
} else {
|
||||
push_token(tok);
|
||||
break;
|
||||
|
|
@ -367,7 +367,7 @@ expr_t::parser_t::parse_querycolon_expr(std::istream& in,
|
|||
node->set_right(parse_or_expr(in, tflags));
|
||||
if (! node->right())
|
||||
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));
|
||||
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));
|
||||
if (! subnode->right())
|
||||
throw_(parse_error,
|
||||
tok.symbol << " operator not followed by argument");
|
||||
_("%1 operator not followed by argument") << tok.symbol);
|
||||
|
||||
node->set_right(subnode);
|
||||
} else {
|
||||
|
|
@ -405,7 +405,7 @@ expr_t::parser_t::parse_value_expr(std::istream& in,
|
|||
node->set_right(parse_value_expr(in, tflags));
|
||||
if (! node->right())
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
@ -418,7 +418,7 @@ expr_t::parser_t::parse_value_expr(std::istream& in,
|
|||
}
|
||||
else if (! tflags.has_flags(PARSE_PARTIAL) &&
|
||||
! tflags.has_flags(PARSE_SINGLE)) {
|
||||
throw_(parse_error, "Failed to parse value expression");
|
||||
throw_(parse_error, _("Failed to parse value expression"));
|
||||
}
|
||||
|
||||
return node;
|
||||
|
|
@ -441,7 +441,7 @@ expr_t::parser_t::parse(std::istream& in, const parse_flags_t& flags,
|
|||
}
|
||||
catch (const std::exception& err) {
|
||||
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 pos = end_pos;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace {
|
|||
|
||||
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::istringstream in(str);
|
||||
|
|
@ -69,7 +69,7 @@ value_t parse_command(call_scope_t& args)
|
|||
{
|
||||
string arg = join_args(args);
|
||||
if (arg.empty()) {
|
||||
throw std::logic_error("Usage: parse TEXT");
|
||||
throw std::logic_error(_("Usage: parse TEXT"));
|
||||
return 1L;
|
||||
}
|
||||
|
||||
|
|
@ -78,23 +78,23 @@ value_t parse_command(call_scope_t& args)
|
|||
|
||||
post_t * post = get_sample_post(report);
|
||||
|
||||
out << "--- Input expression ---" << std::endl;
|
||||
out << _("--- Input expression ---") << 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.print(out);
|
||||
out << std::endl;
|
||||
|
||||
out << std::endl << "--- Expression tree ---" << std::endl;
|
||||
out << std::endl << _("--- Expression tree ---") << std::endl;
|
||||
expr.dump(out);
|
||||
|
||||
bind_scope_t bound_scope(args, *post);
|
||||
expr.compile(bound_scope);
|
||||
out << std::endl << "--- Compiled tree ---" << std::endl;
|
||||
out << std::endl << _("--- Compiled tree ---") << std::endl;
|
||||
expr.dump(out);
|
||||
|
||||
out << std::endl << "--- Calculated value ---" << std::endl;
|
||||
out << std::endl << _("--- Calculated value ---") << std::endl;
|
||||
value_t result(expr.calc());
|
||||
result.strip_annotations(report.what_to_keep()).dump(out);
|
||||
out << std::endl;
|
||||
|
|
@ -118,7 +118,7 @@ value_t format_command(call_scope_t& args)
|
|||
{
|
||||
string arg = join_args(args);
|
||||
if (arg.empty()) {
|
||||
throw std::logic_error("Usage: format TEXT");
|
||||
throw std::logic_error(_("Usage: format TEXT"));
|
||||
return 1L;
|
||||
}
|
||||
|
||||
|
|
@ -127,14 +127,14 @@ value_t format_command(call_scope_t& args)
|
|||
|
||||
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 << "--- Format elements ---" << std::endl;
|
||||
out << _("--- Format elements ---") << std::endl;
|
||||
format_t fmt(arg);
|
||||
fmt.dump(out);
|
||||
|
||||
out << std::endl << "--- Formatted string ---" << std::endl;
|
||||
out << std::endl << _("--- Formatted string ---") << std::endl;
|
||||
bind_scope_t bound_scope(args, *post);
|
||||
out << '"';
|
||||
fmt.format(out, bound_scope);
|
||||
|
|
@ -147,7 +147,7 @@ value_t period_command(call_scope_t& args)
|
|||
{
|
||||
string arg = join_args(args);
|
||||
if (arg.empty()) {
|
||||
throw std::logic_error("Usage: period TEXT");
|
||||
throw std::logic_error(_("Usage: period TEXT"));
|
||||
return 1L;
|
||||
}
|
||||
|
||||
|
|
@ -157,10 +157,10 @@ value_t period_command(call_scope_t& args)
|
|||
interval_t interval(arg);
|
||||
|
||||
if (! is_valid(interval.begin)) {
|
||||
out << "Time period has no beginning." << std::endl;
|
||||
out << _("Time period has no beginning.") << std::endl;
|
||||
} else {
|
||||
out << "begin: " << format_date(interval.begin) << std::endl;
|
||||
out << " end: " << format_date(interval.end) << std::endl;
|
||||
out << _("begin: ") << format_date(interval.begin) << std::endl;
|
||||
out << _(" end: ") << format_date(interval.end) << std::endl;
|
||||
out << std::endl;
|
||||
|
||||
date_t date = interval.first();
|
||||
|
|
@ -169,7 +169,7 @@ value_t period_command(call_scope_t& args)
|
|||
out << std::right;
|
||||
out.width(2);
|
||||
|
||||
out << i << ": " << format_date(date) << std::endl;
|
||||
out << i << "): " << format_date(date) << std::endl;
|
||||
|
||||
date = interval.increment(date);
|
||||
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 end = args.value().end();
|
||||
|
||||
out << "--- Input arguments ---" << std::endl;
|
||||
out << _("--- Input arguments ---") << std::endl;
|
||||
args.value().dump(out);
|
||||
out << std::endl << std::endl;
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ void py_parse_2(amount_t& amount, object in, unsigned char flags) {
|
|||
amount.parse(instr, flags);
|
||||
} else {
|
||||
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) {
|
||||
|
|
@ -87,7 +87,7 @@ void py_print(amount_t& amount, object out)
|
|||
amount.print(outstr);
|
||||
} else {
|
||||
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("exact", &amount_t::exact, args("value"),
|
||||
"Construct an amount object whose display precision is always equal to its\n\
|
||||
internal precision.")
|
||||
_("Construct an amount object whose display precision is always equal to its\n\
|
||||
internal precision."))
|
||||
.staticmethod("exact")
|
||||
|
||||
.def(init<amount_t>())
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ amount_t balance_getitem(balance_t& bal, int i)
|
|||
std::size_t len = bal.amounts.size();
|
||||
|
||||
if (abs(i) >= len) {
|
||||
PyErr_SetString(PyExc_IndexError, "Index out of range");
|
||||
PyErr_SetString(PyExc_IndexError, _("Index out of range"));
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ post_t& posts_getitem(xact_base_t& xact, int i)
|
|||
std::size_t len = xact.posts.size();
|
||||
|
||||
if (abs(i) >= len) {
|
||||
PyErr_SetString(PyExc_IndexError, "Index out of range");
|
||||
PyErr_SetString(PyExc_IndexError, _("Index out of range"));
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ xact_t& xacts_getitem(journal_t& journal, int i)
|
|||
std::size_t len = journal.xacts.size();
|
||||
|
||||
if (abs(i) >= len) {
|
||||
PyErr_SetString(PyExc_IndexError, "Index out of range");
|
||||
PyErr_SetString(PyExc_IndexError, _("Index out of range"));
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ account_t& accounts_getitem(account_t& account, int i)
|
|||
std::size_t len = account.accounts.size();
|
||||
|
||||
if (abs(i) >= len) {
|
||||
PyErr_SetString(PyExc_IndexError, "Index out of range");
|
||||
PyErr_SetString(PyExc_IndexError, _("Index out of range"));
|
||||
throw_error_already_set();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace {
|
|||
if (scope_t * scope = value.as_pointer<scope_t>())
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,12 +109,12 @@ void python_interpreter_t::initialize()
|
|||
object main_module = python::import("__main__");
|
||||
if (! main_module)
|
||||
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__"));
|
||||
if (! main_nspace)
|
||||
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);
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ void python_interpreter_t::initialize()
|
|||
ledger_dict["__path__"] = temp_list;
|
||||
} else {
|
||||
throw_(std::logic_error,
|
||||
"Python failed to initialize (couldn't find ledger)");
|
||||
_("Python failed to initialize (couldn't find ledger)"));
|
||||
}
|
||||
path_initialized = true;
|
||||
break;
|
||||
|
|
@ -153,12 +153,12 @@ void python_interpreter_t::initialize()
|
|||
}
|
||||
if (! path_initialized)
|
||||
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;
|
||||
}
|
||||
catch (const error_already_set&) {
|
||||
PyErr_Print();
|
||||
throw_(std::logic_error, "Python failed to initialize");
|
||||
throw_(std::logic_error, _("Python failed to initialize"));
|
||||
}
|
||||
|
||||
TRACE_FINISH(python_init, 1);
|
||||
|
|
@ -172,7 +172,7 @@ object python_interpreter_t::import(const string& str)
|
|||
try {
|
||||
object mod = python::import(str.c_str());
|
||||
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
|
||||
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&) {
|
||||
PyErr_Print();
|
||||
throw_(std::logic_error, "Failed to evaluate Python code");
|
||||
throw_(std::logic_error, _("Failed to evaluate Python code"));
|
||||
}
|
||||
return object();
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ object python_interpreter_t::eval(const string& str, py_eval_mode_t mode)
|
|||
}
|
||||
catch (const error_already_set&) {
|
||||
PyErr_Print();
|
||||
throw_(std::logic_error, "Failed to evaluate Python code");
|
||||
throw_(std::logic_error, _("Failed to evaluate Python code"));
|
||||
}
|
||||
return object();
|
||||
}
|
||||
|
|
@ -297,7 +297,7 @@ value_t python_interpreter_t::functor_t::operator()(call_scope_t& args)
|
|||
return NULL_VALUE;
|
||||
#else
|
||||
throw_(calc_error,
|
||||
"Could not evaluate Python variable '" << name << "'");
|
||||
_("Could not evaluate Python variable '%1'") << name);
|
||||
#endif
|
||||
} else {
|
||||
if (args.size() > 0) {
|
||||
|
|
@ -318,14 +318,14 @@ value_t python_interpreter_t::functor_t::operator()(call_scope_t& args)
|
|||
} else {
|
||||
Py_DECREF(val);
|
||||
throw_(calc_error,
|
||||
"Could not evaluate Python variable '" << name << "'");
|
||||
_("Could not evaluate Python variable '%1'") << name);
|
||||
}
|
||||
std::signal(SIGINT, sigint_handler);
|
||||
return result;
|
||||
}
|
||||
else if (PyErr_Occurred()) {
|
||||
PyErr_Print();
|
||||
throw_(calc_error, "Failed call to Python function '" << name << "'");
|
||||
throw_(calc_error, _("Failed call to Python function '%1'") << name);
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
|
|
@ -338,8 +338,7 @@ value_t python_interpreter_t::functor_t::operator()(call_scope_t& args)
|
|||
catch (const error_already_set&) {
|
||||
std::signal(SIGINT, sigint_handler);
|
||||
PyErr_Print();
|
||||
throw_(calc_error,
|
||||
"Failed call to Python function '" << name << "'");
|
||||
throw_(calc_error, _("Failed call to Python function '%1'") << name);
|
||||
}
|
||||
catch (...) {
|
||||
std::signal(SIGINT, sigint_handler);
|
||||
|
|
|
|||
|
|
@ -99,8 +99,8 @@ void quotes_by_script::operator()(commodity_base_t& commodity,
|
|||
}
|
||||
} else {
|
||||
throw_(std::runtime_error,
|
||||
"Failed to download price for '" << commodity.symbol
|
||||
<< "' (command: \"getquote " << commodity.symbol << "\")");
|
||||
_("Failed to download price for '%1' (command: \"getquote %1\")")
|
||||
<< commodity.symbol);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -253,8 +253,8 @@ public:
|
|||
interval_t interval(args[0].to_string());
|
||||
if (! is_valid(interval.begin))
|
||||
throw_(std::invalid_argument,
|
||||
"Could not determine beginning of period '"
|
||||
<< args[0].to_string() << "'");
|
||||
_("Could not determine beginning of period '%1'")
|
||||
<< args[0].to_string());
|
||||
|
||||
string predicate =
|
||||
"date>=[" + to_iso_extended_string(interval.begin) + "]";
|
||||
|
|
@ -369,8 +369,8 @@ public:
|
|||
interval_t interval(args[0].to_string());
|
||||
if (! is_valid(interval.begin))
|
||||
throw_(std::invalid_argument,
|
||||
"Could not determine end of period '"
|
||||
<< args[0].to_string() << "'");
|
||||
_("Could not determine end of period '%1'")
|
||||
<< args[0].to_string());
|
||||
|
||||
string predicate =
|
||||
"date<[" + to_iso_extended_string(interval.begin) + "]";
|
||||
|
|
|
|||
|
|
@ -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
|
||||
= symbols.insert(symbol_map::value_type(name, def));
|
||||
if (! result2.second)
|
||||
throw_(compile_error, "Redefinition of '" << name << "' in same scope");
|
||||
throw_(compile_error, _("Redefinition of '%1' in same scope") << name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ std::size_t session_t::read_journal(const path& pathname,
|
|||
account_t * master)
|
||||
{
|
||||
if (! exists(pathname))
|
||||
throw_(std::logic_error, "Cannot read file" << pathname);
|
||||
throw_(std::logic_error, _("Cannot read file '%1'") << pathname);
|
||||
|
||||
ifstream stream(pathname);
|
||||
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_)) {
|
||||
path price_db_path = resolve_path(HANDLER(price_db_).str());
|
||||
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) {
|
||||
|
|
@ -141,7 +141,7 @@ std::size_t session_t::read_data(const string& master_account)
|
|||
xact_count += read_journal(filename, acct);
|
||||
}
|
||||
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);
|
||||
if (count == 0)
|
||||
throw_(parse_error, "Failed to locate any transactions; "
|
||||
"did you specify a valid file with -f?");
|
||||
throw_(parse_error,
|
||||
_("Failed to locate any transactions; did you specify a valid file with -f?"));
|
||||
|
||||
INFO_FINISH(journal);
|
||||
|
||||
|
|
|
|||
|
|
@ -65,11 +65,11 @@ namespace {
|
|||
|
||||
int status = pipe(pfd);
|
||||
if (status == -1)
|
||||
throw std::logic_error("Failed to create pipe");
|
||||
throw std::logic_error(_("Failed to create pipe"));
|
||||
|
||||
status = fork();
|
||||
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
|
||||
// Duplicate pipe's reading end into stdin
|
||||
|
|
@ -130,7 +130,7 @@ void output_stream_t::close()
|
|||
int status;
|
||||
wait(&status);
|
||||
if (! WIFEXITED(status) || WEXITSTATUS(status) != 0)
|
||||
throw std::logic_error("Error in the pager");
|
||||
throw std::logic_error(_("Error in the pager"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ namespace {
|
|||
|
||||
value_t result(expr.calc(bound_scope));
|
||||
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();
|
||||
DEBUG("textual.parse", "The posting amount is " << amount);
|
||||
|
|
@ -234,11 +234,11 @@ void instance_t::parse()
|
|||
instances.push_front(instance);
|
||||
|
||||
foreach (instance_t * instance, instances)
|
||||
add_error_context("In file included from "
|
||||
add_error_context(_("In file included from %1")
|
||||
<< file_context(instance->pathname,
|
||||
instance->linenum));
|
||||
}
|
||||
add_error_context("While parsing file "
|
||||
add_error_context(_("While parsing file %1")
|
||||
<< file_context(pathname, linenum));
|
||||
|
||||
if (caught_signal != NONE_CAUGHT)
|
||||
|
|
@ -251,7 +251,7 @@ void instance_t::parse()
|
|||
if (! current_context.empty())
|
||||
std::cerr << current_context << std::endl;
|
||||
|
||||
std::cerr << "Error: " << err.what() << std::endl;
|
||||
std::cerr << _("Error: ") << err.what() << std::endl;
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
|
@ -308,7 +308,7 @@ void instance_t::read_next_directive()
|
|||
#if 0
|
||||
char * p = skip_ws(line);
|
||||
if (*p)
|
||||
throw parse_error("Line begins with whitespace");
|
||||
throw parse_error(_("Line begins with whitespace"));
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
|
@ -446,7 +446,7 @@ namespace {
|
|||
if (*p == '"') {
|
||||
char * q = std::strchr(p + 1, '"');
|
||||
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);
|
||||
p = q + 2;
|
||||
} else {
|
||||
|
|
@ -458,7 +458,7 @@ namespace {
|
|||
p += symbol.length();
|
||||
}
|
||||
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)));
|
||||
if (! pe->period)
|
||||
throw_(parse_error, "Parsing time period '" << line << "'");
|
||||
throw_(parse_error, _("Parsing time period '%1'") << line);
|
||||
|
||||
istream_pos_type pos = curr_pos;
|
||||
std::size_t lnum = linenum;
|
||||
|
|
@ -573,7 +573,7 @@ void instance_t::period_xact_directive(char * line)
|
|||
|
||||
pe.release();
|
||||
} 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
|
||||
// xact, all of whose postings have null amounts).
|
||||
} else {
|
||||
throw parse_error("Failed to parse transaction");
|
||||
throw parse_error(_("Failed to parse transaction"));
|
||||
}
|
||||
|
||||
TRACE_STOP(xacts, 1);
|
||||
|
|
@ -779,7 +779,7 @@ post_t * instance_t::parse_post(char * line,
|
|||
// Parse the account name
|
||||
|
||||
if (! *p)
|
||||
throw parse_error("Posting has no account");
|
||||
throw parse_error(_("Posting has no account"));
|
||||
|
||||
char * next = next_element(p, true);
|
||||
char * e = p + std::strlen(p);
|
||||
|
|
@ -810,10 +810,13 @@ post_t * instance_t::parse_post(char * line,
|
|||
post->account = account->find_account(name);
|
||||
|
||||
if (honor_strict && strict && ! post->account->known) {
|
||||
if (post->_state == item_t::UNCLEARED)
|
||||
std::cerr << "Warning: \"" << pathname << "\", line " << linenum
|
||||
<< ": Unknown account '" << post->account->fullname()
|
||||
<< "'" << std::endl;
|
||||
if (post->_state == item_t::UNCLEARED) {
|
||||
straccstream accum;
|
||||
std::cerr
|
||||
<< ACCUM(accum << _("Warning: \"%1\", line %2: Unknown account '%3'")
|
||||
<< pathname << linenum << post->account->fullname())
|
||||
<< std::endl;
|
||||
}
|
||||
post->account->known = true;
|
||||
}
|
||||
|
||||
|
|
@ -837,10 +840,13 @@ post_t * instance_t::parse_post(char * line,
|
|||
if (! post->amount.is_null() && honor_strict && strict &&
|
||||
post->amount.has_commodity() &&
|
||||
! post->amount.commodity().has_flags(COMMODITY_KNOWN)) {
|
||||
if (post->_state == item_t::UNCLEARED)
|
||||
std::cerr << "Warning: \"" << pathname << "\", line " << linenum
|
||||
<< ": Unknown commodity '" << post->amount.commodity()
|
||||
<< "'" << std::endl;
|
||||
if (post->_state == item_t::UNCLEARED) {
|
||||
straccstream accum;
|
||||
std::cerr
|
||||
<< ACCUM(accum << _("Warning: \"%1\", line %2: Unknown commodity '%3'")
|
||||
<< pathname << linenum << post->amount.commodity())
|
||||
<< std::endl;
|
||||
}
|
||||
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));
|
||||
|
||||
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)
|
||||
*post->cost *= post->amount;
|
||||
|
|
@ -898,7 +904,7 @@ post_t * instance_t::parse_post(char * line,
|
|||
else
|
||||
next = skip_ws(p + cstream.tellg());
|
||||
} 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));
|
||||
|
||||
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 << ": "
|
||||
<< "POST assign: parsed amt = " << *post->assigned_amount);
|
||||
|
|
@ -987,7 +993,7 @@ post_t * instance_t::parse_post(char * line,
|
|||
else
|
||||
next = skip_ws(p + stream.tellg());
|
||||
} 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
|
||||
|
||||
if (next && *next)
|
||||
throw_(parse_error, "Unexpected char '" << *next
|
||||
<< "' (Note: inline math requires parentheses)");
|
||||
throw_(parse_error,
|
||||
_("Unexpected char '%1' (Note: inline math requires parentheses)")
|
||||
<< *next);
|
||||
|
||||
post->end_pos = curr_pos;
|
||||
post->end_line = linenum;
|
||||
|
|
@ -1015,7 +1022,7 @@ post_t * instance_t::parse_post(char * line,
|
|||
|
||||
}
|
||||
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));
|
||||
throw;
|
||||
}
|
||||
|
|
@ -1097,7 +1104,7 @@ xact_t * instance_t::parse_xact(char * line,
|
|||
curr->payee = next;
|
||||
next = next_element(next, true);
|
||||
} else {
|
||||
curr->payee = "<Unspecified payee>";
|
||||
curr->payee = _("<Unspecified payee>");
|
||||
}
|
||||
|
||||
// Parse the xact note
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ namespace {
|
|||
time_xacts.clear();
|
||||
}
|
||||
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) {
|
||||
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 {
|
||||
bool found = false;
|
||||
|
|
@ -68,7 +68,7 @@ namespace {
|
|||
|
||||
if (! found)
|
||||
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()) {
|
||||
|
|
@ -83,7 +83,7 @@ namespace {
|
|||
|
||||
if (when < event.checkin)
|
||||
throw parse_error
|
||||
("Timelog check-out date less than corresponding check-in");
|
||||
(_("Timelog check-out date less than corresponding check-in"));
|
||||
|
||||
char buf[32];
|
||||
std::sprintf(buf, "%lds", long((when - event.checkin).total_seconds()));
|
||||
|
|
@ -96,7 +96,7 @@ namespace {
|
|||
curr->add_post(post);
|
||||
|
||||
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
|
||||
curr.release();
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ void time_log_t::clock_in(const datetime_t& checkin,
|
|||
if (! time_xacts.empty()) {
|
||||
foreach (time_xact_t& time_xact, time_xacts) {
|
||||
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)
|
||||
{
|
||||
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(),
|
||||
journal);
|
||||
|
|
|
|||
74
src/times.cc
74
src/times.cc
|
|
@ -107,19 +107,19 @@ namespace {
|
|||
|
||||
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;
|
||||
else if (str == "mon" || str == "monday" || str == "1")
|
||||
else if (str == _("mon") || str == _("monday") || str == "1")
|
||||
return 1;
|
||||
else if (str == "tue" || str == "tuesday" || str == "2")
|
||||
else if (str == _("tue") || str == _("tuesday") || str == "2")
|
||||
return 2;
|
||||
else if (str == "wed" || str == "wednesday" || str == "3")
|
||||
else if (str == _("wed") || str == _("wednesday") || str == "3")
|
||||
return 3;
|
||||
else if (str == "thu" || str == "thursday" || str == "4")
|
||||
else if (str == _("thu") || str == _("thursday") || str == "4")
|
||||
return 4;
|
||||
else if (str == "fri" || str == "friday" || str == "5")
|
||||
else if (str == _("fri") || str == _("friday") || str == "5")
|
||||
return 5;
|
||||
else if (str == "sat" || str == "saturday" || str == "6")
|
||||
else if (str == _("sat") || str == _("saturday") || str == "6")
|
||||
return 6;
|
||||
|
||||
assert(false);
|
||||
|
|
@ -197,7 +197,7 @@ namespace {
|
|||
struct std::tm 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_min = 0;
|
||||
|
|
@ -251,23 +251,23 @@ namespace {
|
|||
bool mon_spec = false;
|
||||
char buf[32];
|
||||
|
||||
if (word == "this" || word == "last" || word == "next") {
|
||||
if (word == _("this") || word == _("last") || word == _("next")) {
|
||||
type = word;
|
||||
if (! in.eof())
|
||||
read_lower_word(in, word);
|
||||
else
|
||||
word = "month";
|
||||
word = _("month");
|
||||
} else {
|
||||
type = "this";
|
||||
type = _("this");
|
||||
}
|
||||
|
||||
if (word == "month") {
|
||||
if (word == _("month")) {
|
||||
time_t now = to_time_t(CURRENT_TIME());
|
||||
std::strftime(buf, 31, "%B", localtime(&now));
|
||||
word = buf;
|
||||
mon_spec = true;
|
||||
}
|
||||
else if (word == "year") {
|
||||
else if (word == _("year")) {
|
||||
int year = CURRENT_DATE().year();
|
||||
std::sprintf(buf, "%04d", year);
|
||||
word = buf;
|
||||
|
|
@ -275,7 +275,7 @@ namespace {
|
|||
|
||||
parse_inclusion_specifier(word, begin, end);
|
||||
|
||||
if (type == "last") {
|
||||
if (type == _("last")) {
|
||||
if (mon_spec) {
|
||||
if (begin)
|
||||
*begin = interval_t(0, -1, 0).increment(*begin);
|
||||
|
|
@ -288,7 +288,7 @@ namespace {
|
|||
*end = interval_t(0, 0, -1).increment(*end);
|
||||
}
|
||||
}
|
||||
else if (type == "next") {
|
||||
else if (type == _("next")) {
|
||||
if (mon_spec) {
|
||||
if (begin)
|
||||
*begin = interval_t(0, 1, 0).increment(*begin);
|
||||
|
|
@ -310,65 +310,65 @@ void interval_t::parse(std::istream& in)
|
|||
|
||||
while (! in.eof()) {
|
||||
read_lower_word(in, word);
|
||||
if (word == "every") {
|
||||
if (word == _("every")) {
|
||||
read_lower_word(in, word);
|
||||
if (std::isdigit(word[0])) {
|
||||
int quantity = lexical_cast<int>(word);
|
||||
read_lower_word(in, word);
|
||||
if (word == "days")
|
||||
if (word == _("days"))
|
||||
days = quantity;
|
||||
else if (word == "weeks") {
|
||||
else if (word == _("weeks")) {
|
||||
days = 7 * quantity;
|
||||
weekly = true;
|
||||
}
|
||||
else if (word == "months")
|
||||
else if (word == _("months"))
|
||||
months = quantity;
|
||||
else if (word == "quarters")
|
||||
else if (word == _("quarters"))
|
||||
months = 3 * quantity;
|
||||
else if (word == "years")
|
||||
else if (word == _("years"))
|
||||
years = quantity;
|
||||
}
|
||||
else if (word == "day")
|
||||
else if (word == _("day"))
|
||||
days = 1;
|
||||
else if (word == "week") {
|
||||
else if (word == _("week")) {
|
||||
days = 7;
|
||||
weekly = true;
|
||||
}
|
||||
else if (word == "month")
|
||||
else if (word == _("month"))
|
||||
months = 1;
|
||||
else if (word == "quarter")
|
||||
else if (word == _("quarter"))
|
||||
months = 3;
|
||||
else if (word == "year")
|
||||
else if (word == _("year"))
|
||||
years = 1;
|
||||
}
|
||||
else if (word == "daily")
|
||||
else if (word == _("daily"))
|
||||
days = 1;
|
||||
else if (word == "weekly") {
|
||||
else if (word == _("weekly")) {
|
||||
days = 7;
|
||||
weekly = true;
|
||||
}
|
||||
else if (word == "biweekly")
|
||||
else if (word == _("biweekly"))
|
||||
days = 14;
|
||||
else if (word == "monthly")
|
||||
else if (word == _("monthly"))
|
||||
months = 1;
|
||||
else if (word == "bimonthly")
|
||||
else if (word == _("bimonthly"))
|
||||
months = 2;
|
||||
else if (word == "quarterly")
|
||||
else if (word == _("quarterly"))
|
||||
months = 3;
|
||||
else if (word == "yearly")
|
||||
else if (word == _("yearly"))
|
||||
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);
|
||||
}
|
||||
else if (word == "in") {
|
||||
else if (word == _("in")) {
|
||||
read_lower_word(in, word);
|
||||
parse_date_words(in, word, &begin, &end);
|
||||
}
|
||||
else if (word == "from" || word == "since") {
|
||||
else if (word == _("from") || word == _("since")) {
|
||||
read_lower_word(in, word);
|
||||
parse_date_words(in, word, &begin, NULL);
|
||||
}
|
||||
else if (word == "to" || word == "until") {
|
||||
else if (word == _("to") || word == _("until")) {
|
||||
read_lower_word(in, word);
|
||||
parse_date_words(in, word, NULL, &end);
|
||||
}
|
||||
|
|
|
|||
27
src/token.cc
27
src/token.cc
|
|
@ -122,7 +122,7 @@ void expr_t::token_t::next(std::istream& in, const uint_least8_t pflags)
|
|||
return;
|
||||
}
|
||||
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);
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ void expr_t::token_t::next(std::istream& in, const uint_least8_t pflags)
|
|||
return;
|
||||
}
|
||||
if (! in.good())
|
||||
throw_(parse_error, "Input stream no longer valid");
|
||||
throw_(parse_error, _("Input stream no longer valid"));
|
||||
|
||||
symbol[0] = c;
|
||||
symbol[1] = '\0';
|
||||
|
|
@ -362,7 +362,7 @@ void expr_t::token_t::next(std::istream& in, const uint_least8_t pflags)
|
|||
in.clear();
|
||||
in.seekg(pos, std::ios::beg);
|
||||
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
|
||||
|
|
@ -385,7 +385,7 @@ void expr_t::token_t::next(std::istream& in, const uint_least8_t pflags)
|
|||
in.clear();
|
||||
in.seekg(pos, std::ios::beg);
|
||||
if (in.fail())
|
||||
throw_(parse_error, "Failed to reset input stream");
|
||||
throw_(parse_error, _("Failed to reset input stream"));
|
||||
|
||||
c = in.peek();
|
||||
if (std::isdigit(c) || c == '.')
|
||||
|
|
@ -412,7 +412,7 @@ void expr_t::token_t::rewind(std::istream& in)
|
|||
{
|
||||
in.seekg(- length, std::ios::cur);
|
||||
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) {
|
||||
case TOK_EOF:
|
||||
throw_(parse_error, "Unexpected end of expression");
|
||||
throw_(parse_error, _("Unexpected end of expression"));
|
||||
case IDENT:
|
||||
throw_(parse_error, "Unexpected symbol '" << value << "'");
|
||||
throw_(parse_error, _("Unexpected symbol '%1'") << value);
|
||||
case VALUE:
|
||||
throw_(parse_error, "Unexpected value '" << value << "'");
|
||||
throw_(parse_error, _("Unexpected value '%1'") << value);
|
||||
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 (wanted == '\0' || wanted == -1)
|
||||
throw_(parse_error, "Unexpected end");
|
||||
throw_(parse_error, _("Unexpected end"));
|
||||
else
|
||||
throw_(parse_error, "Missing '" << wanted << "'");
|
||||
throw_(parse_error, _("Missing '%1'") << wanted);
|
||||
} else {
|
||||
if (wanted == '\0' || wanted == -1)
|
||||
throw_(parse_error, "Invalid char '" << c << "'");
|
||||
throw_(parse_error, _("Invalid char '%1'") << c);
|
||||
else
|
||||
throw_(parse_error, "Invalid char '" << c
|
||||
<< "' (wanted '" << wanted << "')");
|
||||
throw_(parse_error, _("Invalid char '%1' (wanted '%2')") << c << wanted);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -485,9 +485,9 @@ inline void check_for_signal() {
|
|||
case NONE_CAUGHT:
|
||||
break;
|
||||
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:
|
||||
throw std::runtime_error("Pipe terminated");
|
||||
throw std::runtime_error(_("Pipe terminated"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
53
src/value.cc
53
src/value.cc
|
|
@ -107,7 +107,7 @@ value_t::operator bool() const
|
|||
break;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot determine truth of " << label());
|
||||
throw_(value_error, _("Cannot determine truth of %1") << label());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -277,7 +277,7 @@ value_t& value_t::operator+=(const value_t& val)
|
|||
for (; i != end(); i++, j++)
|
||||
*i += *j;
|
||||
} else {
|
||||
throw_(value_error, "Cannot add sequences of different lengths");
|
||||
throw_(value_error, _("Cannot add sequences of different lengths"));
|
||||
}
|
||||
} else {
|
||||
as_sequence_lval().push_back(val);
|
||||
|
|
@ -386,7 +386,7 @@ value_t& value_t::operator+=(const value_t& val)
|
|||
break;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot add " << val.label() << " to " << label());
|
||||
throw_(value_error, _("Cannot add %1 to %2") << val.label() << label());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -403,7 +403,7 @@ value_t& value_t::operator-=(const value_t& val)
|
|||
for (; i != end(); i++, j++)
|
||||
*i -= *j;
|
||||
} else {
|
||||
throw_(value_error, "Cannot subtract sequences of different lengths");
|
||||
throw_(value_error, _("Cannot subtract sequences of different lengths"));
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot subtract " << val.label() << " from " << label());
|
||||
throw_(value_error, _("Cannot subtract %1 from %2") << val.label() << label());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -596,7 +596,7 @@ value_t& value_t::operator*=(const value_t& val)
|
|||
break;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot multiply " << label() << " with " << val.label());
|
||||
throw_(value_error, _("Cannot multiply %1 with %2") << label() << val.label());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -651,7 +651,7 @@ value_t& value_t::operator/=(const value_t& val)
|
|||
break;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot divide " << label() << " by " << val.label());
|
||||
throw_(value_error, _("Cannot divide %1 by %2") << label() << val.label());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -736,7 +736,7 @@ bool value_t::is_equal_to(const value_t& val) const
|
|||
break;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot compare " << label() << " to " << val.label());
|
||||
throw_(value_error, _("Cannot compare %1 by %2") << label() << val.label());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -831,7 +831,7 @@ bool value_t::is_less_than(const value_t& val) const
|
|||
break;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot compare " << label() << " to " << val.label());
|
||||
throw_(value_error, _("Cannot compare %1 to %2") << label() << val.label());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -921,7 +921,7 @@ bool value_t::is_greater_than(const value_t& val) const
|
|||
break;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot compare " << label() << " to " << val.label());
|
||||
throw_(value_error, _("Cannot compare %1 to %2") << label() << val.label());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -1041,8 +1041,8 @@ void value_t::in_place_cast(type_t cast_type)
|
|||
return;
|
||||
}
|
||||
else {
|
||||
throw_(value_error, "Cannot convert " << label() <<
|
||||
" with multiple commodities to " << label(cast_type));
|
||||
throw_(value_error, _("Cannot convert %1 with multiple commodities to %2")
|
||||
<< label() << label(cast_type));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -1057,9 +1057,6 @@ void value_t::in_place_cast(type_t cast_type)
|
|||
if (all(as_string(), is_digit())) {
|
||||
set_long(lexical_cast<long>(as_string()));
|
||||
return;
|
||||
} else {
|
||||
throw_(value_error,
|
||||
"Cannot convert string '" << *this << "' to an integer");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -1079,7 +1076,7 @@ void value_t::in_place_cast(type_t cast_type)
|
|||
}
|
||||
|
||||
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()
|
||||
|
|
@ -1105,7 +1102,7 @@ void value_t::in_place_negate()
|
|||
break;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot negate " << label());
|
||||
throw_(value_error, _("Cannot negate %1") << label());
|
||||
}
|
||||
|
||||
void value_t::in_place_not()
|
||||
|
|
@ -1134,7 +1131,7 @@ void value_t::in_place_not()
|
|||
break;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot not " << label());
|
||||
throw_(value_error, _("Cannot 'not' %1") << label());
|
||||
}
|
||||
|
||||
bool value_t::is_realzero() const
|
||||
|
|
@ -1161,7 +1158,7 @@ bool value_t::is_realzero() const
|
|||
return as_any_pointer().empty();
|
||||
|
||||
default:
|
||||
throw_(value_error, "Cannot determine if " << label() << " is really zero");
|
||||
throw_(value_error, _("Cannot determine if %1 is really zero") << label());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1190,7 +1187,7 @@ bool value_t::is_zero() const
|
|||
return as_any_pointer().empty();
|
||||
|
||||
default:
|
||||
throw_(value_error, "Cannot determine if " << label() << " is zero");
|
||||
throw_(value_error, _("Cannot determine if %1 is zero") << label());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1219,7 +1216,7 @@ value_t value_t::value(const bool primary_only,
|
|||
break;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot find the value of " << label());
|
||||
throw_(value_error, _("Cannot find the value of %1") << label());
|
||||
return NULL_VALUE;
|
||||
}
|
||||
|
||||
|
|
@ -1272,7 +1269,7 @@ value_t value_t::abs() const
|
|||
break;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot abs " << label());
|
||||
throw_(value_error, _("Cannot abs %1") << label());
|
||||
return NULL_VALUE;
|
||||
}
|
||||
|
||||
|
|
@ -1289,7 +1286,7 @@ value_t value_t::rounded() const
|
|||
break;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot set rounding for " << label());
|
||||
throw_(value_error, _("Cannot set rounding for %1") << label());
|
||||
return NULL_VALUE;
|
||||
}
|
||||
|
||||
|
|
@ -1306,7 +1303,7 @@ value_t value_t::unrounded() const
|
|||
break;
|
||||
}
|
||||
|
||||
throw_(value_error, "Cannot unround " << label());
|
||||
throw_(value_error, _("Cannot unround %1") << label());
|
||||
return NULL_VALUE;
|
||||
}
|
||||
|
||||
|
|
@ -1315,7 +1312,7 @@ void value_t::annotate(const annotation_t& details)
|
|||
if (is_amount())
|
||||
as_amount_lval().annotate(details);
|
||||
else
|
||||
throw_(value_error, "Cannot annotate " << label());
|
||||
throw_(value_error, _("Cannot annotate %1") << label());
|
||||
}
|
||||
|
||||
bool value_t::is_annotated() const
|
||||
|
|
@ -1324,7 +1321,7 @@ bool value_t::is_annotated() const
|
|||
return as_amount().is_annotated();
|
||||
else
|
||||
throw_(value_error,
|
||||
"Cannot determine whether " << label() << " is annotated");
|
||||
_("Cannot determine whether %1 is annotated") << label());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -1333,7 +1330,7 @@ annotation_t& value_t::annotation()
|
|||
if (is_amount())
|
||||
return as_amount_lval().annotation();
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
@ -1462,7 +1459,7 @@ void value_t::print(std::ostream& out,
|
|||
break;
|
||||
|
||||
default:
|
||||
throw_(value_error, "Cannot print " << label());
|
||||
throw_(value_error, _("Cannot print %1") << label());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
24
src/value.h
24
src/value.h
|
|
@ -863,33 +863,33 @@ public:
|
|||
string label(optional<type_t> the_type = none) const {
|
||||
switch (the_type ? *the_type : type()) {
|
||||
case VOID:
|
||||
return "an uninitialized value";
|
||||
return _("an uninitialized value");
|
||||
case BOOLEAN:
|
||||
return "a boolean";
|
||||
return _("a boolean");
|
||||
case DATETIME:
|
||||
return "a date/time";
|
||||
return _("a date/time");
|
||||
case DATE:
|
||||
return "a date";
|
||||
return _("a date");
|
||||
case INTEGER:
|
||||
return "an integer";
|
||||
return _("an integer");
|
||||
case AMOUNT:
|
||||
return "an amount";
|
||||
return _("an amount");
|
||||
case BALANCE:
|
||||
return "a balance";
|
||||
return _("a balance");
|
||||
case STRING:
|
||||
return "a string";
|
||||
return _("a string");
|
||||
case MASK:
|
||||
return "a regexp";
|
||||
return _("a regexp");
|
||||
case SEQUENCE:
|
||||
return "a sequence";
|
||||
return _("a sequence");
|
||||
case POINTER:
|
||||
return "a pointer";
|
||||
return _("a pointer");
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
assert(false);
|
||||
return "<invalid>";
|
||||
return _("<invalid>");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
12
src/xact.cc
12
src/xact.cc
|
|
@ -170,7 +170,7 @@ bool xact_base_t::finalize()
|
|||
null_post->add_flags(POST_CALCULATED);
|
||||
}
|
||||
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;
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ bool xact_base_t::finalize()
|
|||
|
||||
if (post->amount.commodity() == post->cost->commodity())
|
||||
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::exchange(post->amount, *post->cost, false,
|
||||
|
|
@ -304,10 +304,10 @@ bool xact_base_t::finalize()
|
|||
DEBUG("xact.finalize", "final balance = " << balance);
|
||||
|
||||
if (! balance.is_null() && ! balance.is_zero()) {
|
||||
add_error_context(item_context(*this, "While balancing transaction"));
|
||||
add_error_context("Unbalanced remainder is:");
|
||||
add_error_context(item_context(*this, _("While balancing transaction")));
|
||||
add_error_context(_("Unbalanced remainder is:"));
|
||||
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
|
||||
|
|
@ -334,7 +334,7 @@ bool xact_base_t::finalize()
|
|||
return false; // ignore this xact completely
|
||||
else if (some_null)
|
||||
throw_(balance_error,
|
||||
"There cannot be null amounts after balancing a transaction");
|
||||
_("There cannot be null amounts after balancing a transaction"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue