Browse Source

Added i18n support.

master
Alexander Stubbins 3 years ago
parent
commit
d7551343cc
3 changed files with 164 additions and 15 deletions
  1. 16
    15
      limf/cli.py
  2. 74
    0
      limf/locale/en_US/limf.po
  3. 74
    0
      limf/locale/limf.pot

+ 16
- 15
limf/cli.py View File

@@ -5,42 +5,43 @@ from .parse_arguments import parse_arguments
from .hostlist import retrieve_online_host_list
from .hostlist import generate_host_string
from .hostlist import retrieve_local_host_list

import gettext
gettext.install("limf", "locale")
def main():
"""Creates arguments and parses user input"""
parser = argparse.ArgumentParser(
description='Uploads selected file to working pomf.se clone')
description=_('Uploads selected file to working pomf.se clone'))
parser.add_argument('files', metavar='file', nargs='*', type=str,
help='Files to upload')
help=_('Files to upload'))
parser.add_argument('-c', metavar='host_number', type=int,
dest='host', default=None,
help='The number (0-n) of the selected host (default is random)')
help=_('The number (0-n) of the selected host (default is random)'))
parser.add_argument('-l', dest='only_link', action='store_const',
const=True, default=False,
help='Changes output to just link to the file')
help=_('Changes output to just link to the file'))
parser.add_argument('-e', dest='encrypt', action='store_const',
const=True, default=False,
help='Encrypts then uploads the files.')
help=_('Encrypts then uploads the files.'))
parser.add_argument('-d', dest='decrypt', action='store_const',
const=True, default=False,
help='Decrypts files from links with encrypted files')
help=_('Decrypts files from links with encrypted files'))
parser.add_argument('-j', dest="local_list",
default=False, help='Path to a local list file')
default=False, help=_('Path to a local list file'))
parser.add_argument('-s', dest="show_list", action='store_const',
const=True, default=False,
help='Show the host list (will not upload your files when called)')
help=_('Show the host list (will not upload your files when called)'))
parser.add_argument('-m', dest='limit_size', action='store_const',
const=True, default=False,
help='Do not upload file if it exceeds the certain host limit')
help=_('Do not upload file if it exceeds the certain host limit'))
parser.add_argument('-nc', dest='no_cloudflare', action='store_const',
const=True, default=False,
help='Do not use hosts which use Cloudflare.')
help=_('Do not use hosts which use Cloudflare.'))
parser.add_argument('--log-file', metavar="LOGFILE", dest="logfile",
default="~/limf.log",
help="The location of log file")
help=_("The location of log file"))
parser.add_argument('--log', dest='log', action="store_const",
const=True, default=False,
help="Enables the logging feature, default logfile is ~/limf.log")
help=_("Enables the logging feature, default logfile is ~/limf.log"))
args = parser.parse_args()
try:
if args.local_list:
@@ -48,7 +49,7 @@ def main():
else:
clone_list = retrieve_online_host_list()
if len(min(clone_list, key=len)) < 5 and (args.limit_size or args.no_cloudflare):
print("For newer options, please update your host_list.")
print(_("For newer options, please update your host_list."))
exit()
if args.host and not(0 <= args.host < len(clone_list)):
print(generate_host_string(clone_list))
@@ -56,7 +57,7 @@ def main():

parse_arguments(args, clone_list)
except FileNotFoundError:
print('Plese enter valid file.')
print(_('Plese enter valid file.'))

if __name__ == '__main__':
main()

+ 74
- 0
limf/locale/en_US/limf.po View File

@@ -0,0 +1,74 @@
# English translations for limf package.
# Copyright (C) 2017 THE limf'S COPYRIGHT HOLDER
# This file is distributed under the same license as the limf package.
# John Doe <acstubbins@opmbx.org>, 2017.
#
msgid ""
msgstr ""
"Project-Id-Version: limf master\n"
"Report-Msgid-Bugs-To: acstubbins@opmbx.org\n"
"POT-Creation-Date: 2017-05-07 14:14-0700\n"
"PO-Revision-Date: 2017-05-07 14:19-0700\n"
"Last-Translator: John Doe <acstubbins@opmbx.org>\n"
"Language-Team: English\n"
"Language: en_US\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"

#: cli.py:21
msgid "Changes output to just link to the file"
msgstr "Changes output to just link to the file"

#: cli.py:27
msgid "Decrypts files from links with encrypted files"
msgstr "Decrypts files from links with encrypted files"

#: cli.py:35
msgid "Do not upload file if it exceeds the certain host limit"
msgstr "Do not upload file if it exceeds the certain host limit"

#: cli.py:38
msgid "Do not use hosts which use Cloudflare."
msgstr "Do not use hosts which use Cloudflare."

#: cli.py:44
msgid "Enables the logging feature, default logfile is ~/limf.log"
msgstr "Enables the logging feature, default logfile is ~/limf.log"

#: cli.py:24
msgid "Encrypts then uploads the files."
msgstr "Encrypts then uploads the files."

#: cli.py:15
msgid "Files to upload"
msgstr "Files to upload"

#: cli.py:52
msgid "For newer options, please update your host_list."
msgstr "For newer options, please update your host_list."

#: cli.py:29
msgid "Path to a local list file"
msgstr "Path to a local list file"

#: cli.py:60
msgid "Plese enter valid file."
msgstr "Plese enter valid file."

#: cli.py:32
msgid "Show the host list (will not upload your files when called)"
msgstr "Show the host list (will not upload your files when called)"

#: cli.py:41
msgid "The location of log file"
msgstr "The location of log file"

#: cli.py:18
msgid "The number (0-n) of the selected host (default is random)"
msgstr "The number (0-n) of the selected host (default is random)"

#: cli.py:13
msgid "Uploads selected file to working pomf.se clone"
msgstr "Uploads selected file to working pomf.se clone"

+ 74
- 0
limf/locale/limf.pot View File

@@ -0,0 +1,74 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: limf master\n"
"Report-Msgid-Bugs-To: acstubbins@opmbx.org\n"
"POT-Creation-Date: 2017-05-07 14:14-0700\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"

#: cli.py:21
msgid "Changes output to just link to the file"
msgstr ""

#: cli.py:27
msgid "Decrypts files from links with encrypted files"
msgstr ""

#: cli.py:35
msgid "Do not upload file if it exceeds the certain host limit"
msgstr ""

#: cli.py:38
msgid "Do not use hosts which use Cloudflare."
msgstr ""

#: cli.py:44
msgid "Enables the logging feature, default logfile is ~/limf.log"
msgstr ""

#: cli.py:24
msgid "Encrypts then uploads the files."
msgstr ""

#: cli.py:15
msgid "Files to upload"
msgstr ""

#: cli.py:52
msgid "For newer options, please update your host_list."
msgstr ""

#: cli.py:29
msgid "Path to a local list file"
msgstr ""

#: cli.py:60
msgid "Plese enter valid file."
msgstr ""

#: cli.py:32
msgid "Show the host list (will not upload your files when called)"
msgstr ""

#: cli.py:41
msgid "The location of log file"
msgstr ""

#: cli.py:18
msgid "The number (0-n) of the selected host (default is random)"
msgstr ""

#: cli.py:13
msgid "Uploads selected file to working pomf.se clone"
msgstr ""

Loading…
Cancel
Save