Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 374871 | Differences between
and this patch

Collapse All | Expand All

(-)d23f9c796805 (+54 lines)
Added Link Here
1
#!/usr/bin/env python2
2
3
from gettext import *
4
5
_searchdirs=None
6
7
origfind=find
8
9
def setpaths(pathlist):
10
    global _searchdirs
11
    if isinstance(pathlist,list):
12
        _searchdirs=pathlist
13
    else:
14
        _searchdirs=list(pathlist)
15
16
def addpath(path):
17
    global _searchdirs
18
    if _searchdirs is None:
19
        _searchdirs=list(path)
20
    else:
21
        if path not in _searchdirs:
22
	    _searchdirs.append(path)
23
24
def delpath(path):
25
    global _searchdirs
26
    if _searchdirs is not None:
27
        if path in _searchdirs:
28
	     _searchdirs.remove(path)
29
30
def clearpath():
31
    global _searchdirs
32
    if _searchdirs is not None:
33
        _searchdirs=None
34
35
def find(domain, localedir=None, languages=None, all=False):
36
    if _searchdirs is None:
37
       return origfind(domain, localedir, languages, all)
38
    searches=[localedir]+_searchdirs
39
    results=list()
40
    for dir in searches:
41
       res=origfind(domain,dir,languages,all)
42
       if all is False:
43
           results.append(res)
44
       else:
45
           results.extend(res)
46
    if all is False:
47
        results=filter(lambda x:x is not None,results)
48
        if len(results)==0:
49
            return None
50
        else:
51
            return results[0]
52
    else:
53
       return results
54
(-)a/module/setup.py (-5 / +7 lines)
Lines 17-23 Link Here
17
    @author: RaNaN
17
    @author: RaNaN
18
"""
18
"""
19
from getpass import getpass
19
from getpass import getpass
20
import gettext
20
import module.common.pylgettext as gettext
21
import os
21
import os
22
from os import makedirs
22
from os import makedirs
23
from os.path import abspath
23
from os.path import abspath
Lines 44-50 Link Here
44
44
45
        langs = self.config.getMetaData("general", "language")["type"].split(";")
45
        langs = self.config.getMetaData("general", "language")["type"].split(";")
46
        lang = self.ask(u"Choose your Language / Wähle deine Sprache", "en", langs)
46
        lang = self.ask(u"Choose your Language / Wähle deine Sprache", "en", langs)
47
        translation = gettext.translation("setup", join(self.path, "locale"), languages=["en", lang])
47
        gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
48
        translation = gettext.translation("setup", join(self.path, "locale"), languages=[lang, "en"],fallback=True)
48
        translation.install(True)
49
        translation.install(True)
49
50
50
#        print ""
51
#        print ""
Lines 342-349 Link Here
342
        self.config["ssl"]["activated"] = self.ask(_("Activate SSL?"), "y", bool=True)
343
        self.config["ssl"]["activated"] = self.ask(_("Activate SSL?"), "y", bool=True)
343
344
344
    def set_user(self):
345
    def set_user(self):
345
346
        gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
346
        translation = gettext.translation("setup", join(self.path, "locale"), languages=["en", self.config["general"]["language"]])
347
        translation = gettext.translation("setup", join(self.path, "locale"), languages=[self.config["general"]["language"],"en"],fallback=True)
347
        translation.install(True)
348
        translation.install(True)
348
        
349
        
349
        from module.database import DatabaseBackend
350
        from module.database import DatabaseBackend
Lines 394-400 Link Here
394
395
395
    def conf_path(self, trans=False):
396
    def conf_path(self, trans=False):
396
        if trans:
397
        if trans:
397
            translation = gettext.translation("setup", join(self.path, "locale"), languages=[self.config["general"]["language"]])
398
            gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
399
            translation = gettext.translation("setup", join(self.path, "locale"), languages=[self.config["general"]["language"], "en"],fallback=True)
398
            translation.install(True)
400
            translation.install(True)
399
        
401
        
400
        print _("Setting new configpath, current configuration will not be transfered!")
402
        print _("Setting new configpath, current configuration will not be transfered!")
(-)a/module/web/webinterface.py (-2 / +4 lines)
Lines 18-25 Link Here
18
"""
18
"""
19
19
20
import sys
20
import sys
21
import gettext
21
import module.common.pylgettext as gettext
22
22
23
import os
23
from os.path import join, abspath, dirname, exists
24
from os.path import join, abspath, dirname, exists
24
from os import makedirs
25
from os import makedirs
25
26
Lines 98-105 Link Here
98
else:
99
else:
99
    env.filters["url"] = lambda x: PREFIX + x if x.startswith("/") else x
100
    env.filters["url"] = lambda x: PREFIX + x if x.startswith("/") else x
100
101
102
gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
101
translation = gettext.translation("django", join(PYLOAD_DIR, "locale"),
103
translation = gettext.translation("django", join(PYLOAD_DIR, "locale"),
102
    languages=["en", config.get("general", "language")])
104
    languages=[config.get("general", "language"), "en"],fallback=True)
103
translation.install(True)
105
translation.install(True)
104
env.install_gettext_translations(translation)
106
env.install_gettext_translations(translation)
105
107
(-)a/pyLoadCli.py (-4 / +6 lines)
Lines 20-26 Link Here
20
from __future__ import with_statement
20
from __future__ import with_statement
21
from getopt import GetoptError, getopt
21
from getopt import GetoptError, getopt
22
22
23
import gettext
23
import module.common.pylgettext as gettext
24
import os
24
import os
25
from os import _exit
25
from os import _exit
26
from os.path import join, exists, abspath, basename
26
from os.path import join, exists, abspath, basename
Lines 490-497 Link Here
490
        for opt in configFile.items("cli"):
490
        for opt in configFile.items("cli"):
491
            config[opt[0]] = opt[1]
491
            config[opt[0]] = opt[1]
492
492
493
    gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
493
    translation = gettext.translation("pyLoadCli", join(pypath, "locale"),
494
    translation = gettext.translation("pyLoadCli", join(pypath, "locale"),
494
        languages=["en", config["language"]])
495
        languages=[config["language"],"en"],fallback=True)
495
    translation.install(unicode=True)
496
    translation.install(unicode=True)
496
497
497
    interactive = False
498
    interactive = False
Lines 515-522 Link Here
515
                config["port"] = params
516
                config["port"] = params
516
            elif option in ("-l", "--language"):
517
            elif option in ("-l", "--language"):
517
                config["language"] = params
518
                config["language"] = params
519
                gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
518
                translation = gettext.translation("pyLoadCli", join(pypath, "locale"),
520
                translation = gettext.translation("pyLoadCli", join(pypath, "locale"),
519
                    languages=["en", config["language"]])
521
                    languages=[config["language"],"en"],fallback=True)
520
                translation.install(unicode=True)
522
                translation.install(unicode=True)
521
            elif option in ("-h", "--help"):
523
            elif option in ("-h", "--help"):
522
                print_help(config)
524
                print_help(config)
Lines 585-588 Link Here
585
587
586
588
587
if __name__ == "__main__":
589
if __name__ == "__main__":
588
    main()
590
    main()
(-)a/pyLoadCore.py (-2 / +3 lines)
Lines 25-31 Link Here
25
import __builtin__
25
import __builtin__
26
26
27
from getopt import getopt, GetoptError
27
from getopt import getopt, GetoptError
28
import gettext
28
import module.common.pylgettext as gettext
29
from imp import find_module
29
from imp import find_module
30
import logging
30
import logging
31
import logging.handlers
31
import logging.handlers
Lines 288-295 Link Here
288
288
289
        self.config = ConfigParser()
289
        self.config = ConfigParser()
290
290
291
        gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
291
        translation = gettext.translation("pyLoad", self.path("locale"),
292
        translation = gettext.translation("pyLoad", self.path("locale"),
292
                                          languages=["en", self.config['general']['language']])
293
                                          languages=[self.config['general']['language'],"en"],fallback=True)
293
        translation.install(True)
294
        translation.install(True)
294
295
295
        self.debug = self.doDebug or self.config['general']['debug_mode']
296
        self.debug = self.doDebug or self.config['general']['debug_mode']
(-)a/pyLoadGui.py (-2 / +4 lines)
Lines 29-35 Link Here
29
from PyQt4.QtGui import *
29
from PyQt4.QtGui import *
30
30
31
import re
31
import re
32
import gettext
32
import module.common.pylgettext as gettext
33
import os
33
from os.path import abspath
34
from os.path import abspath
34
from os.path import join
35
from os.path import join
35
from os.path import basename
36
from os.path import basename
Lines 77-83 Link Here
77
            parser = XMLParser(join(self.path, "module", "config", "gui_default.xml"))
78
            parser = XMLParser(join(self.path, "module", "config", "gui_default.xml"))
78
            lang = parser.xml.elementsByTagName("language").item(0).toElement().text()
79
            lang = parser.xml.elementsByTagName("language").item(0).toElement().text()
79
80
80
        translation = gettext.translation("pyLoadGui", join(pypath, "locale"), languages=["en", str(lang)])
81
        gettext.setpaths([join(os.sep, "usr", "share", "pyload", "locale"), None])
82
        translation = gettext.translation("pyLoadGui", join(pypath, "locale"), languages=[str(lang), "en"], fallback=True)
81
        try:
83
        try:
82
            translation.install(unicode=(True if sys.stdout.encoding.lower().startswith("utf") else False))
84
            translation.install(unicode=(True if sys.stdout.encoding.lower().startswith("utf") else False))
83
        except:
85
        except:

Return to bug 374871