Commit 5ba35e8c authored by Tankypon's avatar Tankypon

Modify the way to translate dontpanic

parent 9ac5b9a8
......@@ -4,9 +4,6 @@ __pycache__/
# Python 2.7 compiled files
*.py[cod]
# Locale
locale/
# Idea content
.idea/
......
......@@ -16,11 +16,11 @@ import logging
import os
import sys
from gettext import gettext as _
from argparse import ArgumentParser
from utils import setup_logging, progname, progversion
from dontpanic import DontPanic
from i18n import _
from utils import setup_logging, progname, progversion
serverlist = ["cgi", "paste", "cherrypy", "tornado", "auto"]
logger = logging.getLogger(__name__)
......
......@@ -11,7 +11,6 @@ Description :
"""
import getpass
import gettext
import sys
from argparse import ArgumentParser
......@@ -20,15 +19,12 @@ from threading import Thread
from urllib.parse import quote as quoteurl
from database import DontPanicDB
from i18n import _
from subtitles import get_hash, sch_subtitle, dl_subtitle
from torrentsession import TorrentSession
from utils import *
from webutils import *
gettext.bindtextdomain(progname, '/usr/share/locale')
gettext.textdomain(progname)
_ = gettext.gettext
# For python2 or 3
if sys.version_info < (3, 0):
print("You need python3 to use dontpanic")
......
import gettext
import locale
import logging
import os
import sys
# Global directories
currentdir = os.path.dirname(os.curdir)
# Translation directories
localedir = os.path.join(currentdir, 'locale')
# Util global variables
progname = "dontpanic"
logger = logging.getLogger(__name__)
gettext.bindtextdomain(progname, localedir)
i18n_domain = gettext.textdomain(progname)
current_locale, encoding = locale.getdefaultlocale()
language = gettext.translation(progname, localedir, languages=[current_locale], fallback=True)
language.install()
# FIXME: The logging at the moment is not working here, because we use the logger before its init
# A translated language has been found
if language.info():
logger.info("Set {} language to {}".format(progname, current_locale))
# No translated language has been found
else:
logger.info("Your language ({}) is not translated".format(current_locale))
if sys.version_info >= (3, 0):
_ = language.gettext
else:
# Support of unicode fol version of Python older than 3
_ = language.ugettext
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import gettext
import logging
import os
import subprocess
from utils import *
from utils import localedir, podir, progname, setup_logging
from argparse import ArgumentParser
from glob import glob
from i18n import _, i18n_domain
i18n_domain = gettext.textdomain()
_ = gettext.gettext
logger = logging.getLogger(__name__)
......
......@@ -7,7 +7,8 @@ import random
import socket
import logging
import tempfile
import gettext
from i18n import _
####################
# Global variables #
......@@ -33,11 +34,6 @@ progname = "dontpanic"
progurl = "http://yeuxdelibad.net/Programmation/dontpanic.html"
progversion = "0.9.2"
# Binding for the translation
gettext.bindtextdomain(progname, '/usr/share/locale')
gettext.textdomain(progname)
_ = gettext.gettext
defaultconf = {'STARTPERC': 7,
'UPLIMIT': 20,
'DOWNLIMIT': -1
......
......@@ -3,9 +3,10 @@
import requests
import bs4
from gettext import gettext as _
from utils import convb
from i18n import _
def do_req_get(url, ret, keys=""):
"""
......@@ -150,6 +151,7 @@ def get_episode_list(title, year):
return eplist
class BestIMDB:
URL_TVSHOWS = "http://www.imdb.com/chart/tvmeter?ref_=nv_tvv_mptv_4"
......@@ -277,6 +279,7 @@ class BestAllocine:
def url_best_tvshows(cls):
return cls.URL_TVSHOWS
class TorrentSearch:
def __init__(self, searchengine):
......@@ -345,8 +348,7 @@ class TorrentSearch:
return results
def _torrentproject(self,sch):
def _torrentproject(self, sch):
"""
Search on torrentproject.se
......@@ -385,7 +387,6 @@ class TorrentSearch:
return results
def _torrentz(self, sch):
"""
Search on torrentz.eu
......@@ -444,15 +445,10 @@ class TorrentSearch:
return results
def main():
if __name__ == '__main__':
searchengine = "torrentz"
with TorrentSearch(searchengine) as ts:
s = ts.search("test")
print(s)
return 0
if __name__ == '__main__':
main()
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment