identified translatable strings
authorMauro Scomparin <scompo@gmail.com>
Tue, 10 Jul 2018 21:08:38 +0000 (23:08 +0200)
committerMauro Scomparin <scompo@gmail.com>
Tue, 10 Jul 2018 21:08:38 +0000 (23:08 +0200)
money/money.py
setup.py

index b037d04ed23662c1438ba61aac75028e148f6df9..472d29c65a57a930e77cc91b7339a8e0bb80f166 100755 (executable)
@@ -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):
index 0ddf6af6b24c278b282f7d017b49da3d69b4793b..d935b4d105f639b6eb2d8415cf3e7e6d907e9e6b 100644 (file)
--- 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',