From 9ac02ba10cb028034c8362a33b2bfbdbe7d3d1ff Mon Sep 17 00:00:00 2001 From: Mauro Scomparin Date: Tue, 10 Jul 2018 23:08:38 +0200 Subject: [PATCH] identified translatable strings --- money/money.py | 26 ++++++++++++++------------ setup.py | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/money/money.py b/money/money.py index b037d04..472d29c 100755 --- a/money/money.py +++ b/money/money.py @@ -3,24 +3,26 @@ from os.path import expanduser, join, exists, abspath 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, '', '') @@ -92,7 +94,7 @@ def read_movement(): 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 @@ -191,7 +193,7 @@ def default_configuration(): def last_movement_number_message(n): - return 'latest {} movements:'.format(n) + return _('latest {} movements:').format(n) def value_message(str, value): @@ -211,9 +213,9 @@ def write_latest_movements(data_file, conf): 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): diff --git a/setup.py b/setup.py index 0ddf6af..d935b4d 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ with open(path.join(here, 'README.rst'), encoding = 'utf-8') as f: setup( name = 'money', version = '1.0.1', - description = 'Money handling program', + description = _('Money handling program'), long_description = long_description, url = 'http://code.scompo.it:3000/scompo/money', author = 'Mauro Scomparin', -- 2.25.1