looks like it works like this
authorMauro Scomparin <scompo@gmail.com>
Tue, 10 Jul 2018 23:26:15 +0000 (01:26 +0200)
committerMauro Scomparin <scompo@gmail.com>
Tue, 10 Jul 2018 23:26:15 +0000 (01:26 +0200)
money/money.py
money/translations/it/LC_MESSAGES/money.mo [new file with mode: 0644]
money/translations/it/LC_MESSAGES/money.po [new file with mode: 0644]
money/translations/money.pot [new file with mode: 0644]
po/money.pot [deleted file]
setup.py

index 472d29c65a57a930e77cc91b7339a8e0bb80f166..05f9974ec8f6111206fa9abbceef7f0cc52686a0 100755 (executable)
@@ -2,9 +2,15 @@ from time import localtime, gmtime, strftime, strptime
 from os.path import expanduser, join, exists, abspath
 from pprint import pprint
 from decimal import *
+from pkg_resources import resource_filename
 import json
+
 import gettext
-_ = gettext.gettext
+
+loc_dir = resource_filename('money', 'translations')
+t = gettext.translation('money', localedir = loc_dir, fallback=True)
+_ = t.gettext
+t.install()
 
 DATA_FILE_NAME = 'dataFile'
 LAST_MOVEMENT_NUMBER = 'latestMovementsNumber'
diff --git a/money/translations/it/LC_MESSAGES/money.mo b/money/translations/it/LC_MESSAGES/money.mo
new file mode 100644 (file)
index 0000000..a8dacac
Binary files /dev/null and b/money/translations/it/LC_MESSAGES/money.mo differ
diff --git a/money/translations/it/LC_MESSAGES/money.po b/money/translations/it/LC_MESSAGES/money.po
new file mode 100644 (file)
index 0000000..053e348
--- /dev/null
@@ -0,0 +1,66 @@
+# Translations for money template file.
+# Copyright (C) 2018 Mauro Scomparin
+# This file is distributed under the same license as the money package.
+# Mauro Scomparin <scompo@gmail.com>, 2018.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: money 1.0.1\n"
+"Report-Msgid-Bugs-To: scompo@gmail.com\n"
+"POT-Creation-Date: 2018-07-10 23:10+0200\n"
+"PO-Revision-Date: 2018-07-10 23:17+0200\n"
+"Last-Translator:  <scompo@gmail.com>\n"
+"Language-Team: Italian\n"
+"Language: it\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: money/money.py:14
+msgid "type"
+msgstr "tipo"
+
+#: money/money.py:15
+msgid "value"
+msgstr "valore"
+
+#: money/money.py:16
+msgid "date"
+msgstr "data"
+
+#: money/money.py:17
+msgid "hour"
+msgstr "ora"
+
+#: money/money.py:18
+msgid "description"
+msgstr "descrizione"
+
+#: money/money.py:24
+msgid "today"
+msgstr "oggi"
+
+#: money/money.py:25
+msgid "now"
+msgstr "adesso"
+
+#: money/money.py:97
+msgid "data file:"
+msgstr "file dati:"
+
+#: money/money.py:196
+msgid "latest {} movements:"
+msgstr "ultimi {} movimenti:"
+
+#: money/money.py:216
+msgid "actual value: {}"
+msgstr "valore attuale: {}"
+
+#: money/money.py:217
+msgid "total incomes: {}"
+msgstr "incassi totali: {}"
+
+#: money/money.py:218
+msgid "total expenses: {}"
+msgstr "spese totali: {}"
diff --git a/money/translations/money.pot b/money/translations/money.pot
new file mode 100644 (file)
index 0000000..dfab6f2
--- /dev/null
@@ -0,0 +1,66 @@
+# Translations for money template file.
+# Copyright (C) 2018 Mauro Scomparin
+# This file is distributed under the same license as the PACKAGE package.
+# Mauro Scomparin <scompo@gmail.com>, 2018.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: money 1.0.1\n"
+"Report-Msgid-Bugs-To: scompo@gmail.com\n"
+"POT-Creation-Date: 2018-07-10 23:10+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: money/money.py:14
+msgid "type"
+msgstr ""
+
+#: money/money.py:15
+msgid "value"
+msgstr ""
+
+#: money/money.py:16
+msgid "date"
+msgstr ""
+
+#: money/money.py:17
+msgid "hour"
+msgstr ""
+
+#: money/money.py:18
+msgid "description"
+msgstr ""
+
+#: money/money.py:24
+msgid "today"
+msgstr ""
+
+#: money/money.py:25
+msgid "now"
+msgstr ""
+
+#: money/money.py:97
+msgid "data file:"
+msgstr ""
+
+#: money/money.py:196
+msgid "latest {} movements:"
+msgstr ""
+
+#: money/money.py:216
+msgid "actual value: {}"
+msgstr ""
+
+#: money/money.py:217
+msgid "total incomes: {}"
+msgstr ""
+
+#: money/money.py:218
+msgid "total expenses: {}"
+msgstr ""
diff --git a/po/money.pot b/po/money.pot
deleted file mode 100644 (file)
index a17d549..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-# Translations for money template file.
-# Copyright (C) 2018 Mauro Scomparin
-# This file is distributed under the same license as the PACKAGE package.
-# Mauro Scomparin <scompo@gmail.com>, 2018.
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: money 1.0.1\n"
-"Report-Msgid-Bugs-To: scompo@gmail.com\n"
-"POT-Creation-Date: 2018-07-10 23:10+0200\n"
-"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <LL@li.org>\n"
-"Language: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-
-#: money/money.py:14
-msgid "type"
-msgstr ""
-
-#: money/money.py:15
-msgid "value"
-msgstr ""
-
-#: money/money.py:16
-msgid "date"
-msgstr ""
-
-#: money/money.py:17
-msgid "hour"
-msgstr ""
-
-#: money/money.py:18
-msgid "description"
-msgstr ""
-
-#: money/money.py:24
-msgid "today"
-msgstr ""
-
-#: money/money.py:25
-msgid "now"
-msgstr ""
-
-#: money/money.py:97
-msgid "data file:"
-msgstr ""
-
-#: money/money.py:196
-msgid "latest {} movements:"
-msgstr ""
-
-#: money/money.py:216
-msgid "actual value: {}"
-msgstr ""
-
-#: money/money.py:217
-msgid "total incomes: {}"
-msgstr ""
-
-#: money/money.py:218
-msgid "total expenses: {}"
-msgstr ""
-
-#: setup.py:13
-msgid "Money handling program"
-msgstr ""
index d935b4d105f639b6eb2d8415cf3e7e6d907e9e6b..25f327d0e95e7b04ec989ff4b4dda91be1c23f8d 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -4,21 +4,27 @@ from os import path
 
 here = path.abspath(path.dirname(__file__))
 
-with open(path.join(here, 'README.rst'), encoding = 'utf-8') as f:
+with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
     long_description = f.read()
 
 setup(
-    name = 'money',
-    version = '1.0.1',
-    description = _('Money handling program'),
-    long_description = long_description,
-    url = 'http://code.scompo.it:3000/scompo/money',
-    author = 'Mauro Scomparin',
-    author_email = 'scompo@gmail.com',
-    license = 'BSD',
-    packages=find_packages(exclude=['contrib', 'docs', 'tests', 'utils', 'scripts']),
+    name='money',
+    version='1.0.1',
+    description='Money handling program',
+    long_description=long_description,
+    url='http://code.scompo.it:3000/scompo/money',
+    author='Mauro Scomparin',
+    author_email='scompo@gmail.com',
+    license='BSD',
+    packages=find_packages(
+        exclude=['contrib', 'docs', 'tests', 'utils', 'scripts']),
+    package_data={
+        'money': [
+            'translations/*/LC_MESSAGES/money.mo'
+        ],
+    },
     entry_points={
-        'console_scripts' : [
+        'console_scripts': [
             'money-insert=money.money:read_new_movement',
             'money-latest=money.money:latest_movements',
         ],