-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlanguages.py
More file actions
132 lines (94 loc) · 3.11 KB
/
languages.py
File metadata and controls
132 lines (94 loc) · 3.11 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# -*- coding: utf-8 -*-
# Multilingual support postpone indefinitely. Only Help has a language option.
# (Making `app` method that handles all strings that should contain property `lang` which comes from config",
# doesn't work either because `app` doesn't exist when widgets are initialized.)
"""
Besides differences in written language letters and words,
various languages use different marks as separators for decimals.
Also sometimes variations in the separators exist within the same country.
This module will focus mostly on the most prevalent cases.
An option to choose decimal separator mark could be created
but the selection should NOT be forced on the user
since they might be very inexperienced and not even know which is the correct mark.
"""
class LanguageNotImplemented(Exception):
pass
SUPPORTED_LANGUAGES = {}
class Language(object):
def __init__(self, name, name_native):
self.name_native = name_native # Language name spelled with characters of the language itself
self.name = name
SUPPORTED_LANGUAGES.update({self.name: self})
# In reality, separators differ for different english-speaking countries
# (e.g. eng_US, eng_ireland, eng_UK ..).
# Since this program is not expected to become very popular,
# the convention below should be ok.
# Alternatively, the user could be prompted to select his separator;
# the prompt should be in a very easy to understand form:
# e.g. "Three point one." Select the image that is accurate (used for separator blabla..)
english = Language(name='english', name_native='english')
greek = Language(name='greek', name_native=u'ελληνικά')
class Message(object):
DEFAULT_LANGUAGE = 'english'
selected_language = DEFAULT_LANGUAGE
def __init__(self, only_english=False, **kwargs):
# Ensures required languages are implemented
if only_english:
if self.DEFAULT_LANGUAGE not in kwargs:
raise LanguageNotImplemented(self.DEFAULT_LANGUAGE)
langs_not_implemented = set(kwargs) - set(SUPPORTED_LANGUAGES)
if langs_not_implemented:
raise LanguageNotImplemented(langs_not_implemented)
self.langs_msgs_dct = kwargs
PLAY = Message(
english='Play',
greek=u'Παιχνίδι',
)
ABOUT = Message(
english='About',
greek=u'Σχετικά',
)
HELP = Message(
english='Help',
greek=u'Βοήθεια',
)
REWARDS = Message(
english='Rewards',
greek=u'Βραβεία',
)
VERSION = Message(
english='version',
greek='έκδοση',
)
EASY = Message(
english='easy',
greek='εύκολα',
)
MEDIUM = Message(
english='medium',
greek='μέτρια',
)
HARD = Message(
english='hard',
greek='δύσκολα',
)
OPERATION_CATEGORIES = Message(
english='Operation type',
greek='Είδος πράξεων',
)
DIFFICULTY = Message(
english='Difficulty',
greek='Δυσκολία',
)
CLEAR = Message(
english='Clear',
greek='Σβήσιμο',
)
CHECK_ANSWER = Message(
english='Check\nanswer',
greek='Έλεγχος\nαπάντησης',
)
SEPARATOR_SYMBOL = Message(
english='.',
greek=',',
)