File: lng.py

package info (click to toggle)
playonlinux 4.3.4-5
  • links: PTS, VCS
  • area: contrib
  • in suites: trixie
  • size: 8,252 kB
  • sloc: sh: 5,390; python: 5,150; ansic: 72; makefile: 57; xml: 47
file content (36 lines) | stat: -rwxr-xr-x 1,086 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import wx
import gettext, os
from . import Variables
import locale

class Lang(object):
    def __init__(self):
        return None

class iLang(object):
    def __init__(self):
        if(os.environ["DEBIAN_PACKAGE"] == "TRUE"):
            languages = os.listdir('/usr/share/locale')
        else:
            languages = os.listdir(Variables.playonlinux_env+'/lang/locale')

        if(os.environ["POL_OS"] == "Mac"):
            langid = wx.Locale().FindLanguageInfo(os.environ["RLANG"]).Language
        else:
            langid = wx.LANGUAGE_DEFAULT

        if(os.environ["DEBIAN_PACKAGE"] == "TRUE"):
            localedir = "/usr/share/locale"
        else:
            localedir = os.path.join(Variables.playonlinux_env, "lang/locale")

        domain = "pol"
        mylocale = wx.Locale(langid)
        mylocale.AddCatalogLookupPathPrefix(localedir)
        mylocale.AddCatalog(domain)

        mytranslation = gettext.translation(domain, localedir, [mylocale.GetCanonicalName()], fallback = True)
        mytranslation.install()