-
Notifications
You must be signed in to change notification settings - Fork 4
/
strings.py
63 lines (53 loc) · 1.59 KB
/
strings.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from codecs import decode
from codecs import encode
import yaml
from skynoid import logging as LOGGER
from skynoid import Owner
from skynoid.plugins.database.lang_db import prev_locale
LANGUAGES = [
'en-US'
]
try:
strings = {
i: yaml.full_load(
open('locales/' + i + '.yml'),
) for i in LANGUAGES
}
except UnicodeDecodeError:
strings = {
i: yaml.full_load(
open('locales/' + i + '.yml', encoding='utf8'),
) for i in LANGUAGES
}
def tld(t, _show_none=True):
LANGUAGE = prev_locale(Owner)
if LANGUAGE:
LOCALE = LANGUAGE.locale_name
if LOCALE in ('en-US') and t in strings['en-US']:
result = decode(
encode(strings['en-US'][t], 'latin-1', 'backslashreplace'),
'unicode-escape',
)
if t in strings['en-US']:
result = decode(
encode(
strings['en-US'][t],
'latin-1',
'backslashreplace',
),
'unicode-escape',
)
return result
err = f'No string found for {t}.\nReport it in @SkynoidSupport.'
LOGGER.warning(err)
return err
def tld_list(t):
LANGUAGE = prev_locale(Owner)
if LANGUAGE:
LOCALE = LANGUAGE.locale_name
if LOCALE in ('en-US') and t in strings['en-US']:
return strings['en-US'][t]
if t in strings['en-US']:
return strings['en-US'][t]
LOGGER.warning(f'#NOSTR No string found for {t}.')
return f'No string found for {t}.\nReport it in @SkynoidSupport.'