from pprint import pprint
from decimal import *
import json
+import gettext
+_ = gettext.gettext
DATA_FILE_NAME = 'dataFile'
LAST_MOVEMENT_NUMBER = 'latestMovementsNumber'
CONFIG_FILE_NAME = 'money.conf'
CONFIG_FILE_LOCATION = expanduser('~') + '/.config/' + CONFIG_FILE_NAME
-TYPE_FIELD_NAME = 'type'
-VALUE_FIELD_NAME = 'value'
-DATE_FIELD_NAME = 'date'
-HOUR_FIELD_NAME = 'hour'
-DESCRIPTION_FIELD_NAME = 'description'
+TYPE_FIELD_NAME = _('type')
+VALUE_FIELD_NAME = _('value')
+DATE_FIELD_NAME = _('date')
+HOUR_FIELD_NAME = _('hour')
+DESCRIPTION_FIELD_NAME = _('description')
def create_input_message(field_name, field_format, field_default_value):
return field_name + " (" + field_format + ") [" + field_default_value + "]: "
TYPE_MESSAGE = create_input_message(TYPE_FIELD_NAME, '+/-', '-')
-DATE_MESSAGE = create_input_message(DATE_FIELD_NAME, 'DD/MM/YYYY', 'today')
-HOUR_MESSAGE = create_input_message(HOUR_FIELD_NAME, 'HH:MM', 'now')
+DATE_MESSAGE = create_input_message(DATE_FIELD_NAME, 'DD/MM/YYYY', _('today'))
+HOUR_MESSAGE = create_input_message(HOUR_FIELD_NAME, 'HH:MM', _('now'))
VALUE_MESSAGE = create_input_message(VALUE_FIELD_NAME, '(#####.##)', '')
DESCRIPTION_MESSAGE = create_input_message(DESCRIPTION_FIELD_NAME, '', '')
def get_data_file(config):
data_file = abspath(config[DATA_FILE_NAME])
- print('data file:', data_file)
+ print(_('data file:'), data_file)
return data_file
def last_movement_number_message(n):
- return 'latest {} movements:'.format(n)
+ return _('latest {} movements:').format(n)
def value_message(str, value):
total_incomes = total_incomes + movement_value
else:
total_expenses = total_expenses + movement_value
- print(value_message('actual value: {}', actual_value))
- print(value_message('total incomes: {}', total_incomes))
- print(value_message('total expenses: {}', total_expenses))
+ print(value_message(_('actual value: {}'), actual_value))
+ print(value_message(_('total incomes: {}'), total_incomes))
+ print(value_message(_('total expenses: {}'), total_expenses))
print(last_movement_number_message(conf[LAST_MOVEMENT_NUMBER]))
for i in range(conf[LAST_MOVEMENT_NUMBER]):
if i < len(ordered_movements):