File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 29
29
class GreekLocalizer :
30
30
"""A simple localizer a la gettext"""
31
31
32
- def __init__ (self ):
32
+ def __init__ (self ) -> None :
33
33
self .translations = {"dog" : "σκύλος" , "cat" : "γάτα" }
34
34
35
- def localize (self , msg ) :
35
+ def localize (self , msg : str ) -> str :
36
36
"""We'll punt if we don't have a translation"""
37
37
return self .translations .get (msg , msg )
38
38
39
39
40
40
class EnglishLocalizer :
41
41
"""Simply echoes the message"""
42
42
43
- def localize (self , msg ) :
43
+ def localize (self , msg : str ) -> str :
44
44
return msg
45
45
46
46
47
- def get_localizer (language = "English" ):
47
+ def get_localizer (language : str = "English" ) -> object :
48
+
48
49
"""Factory"""
49
50
localizers = {
50
51
"English" : EnglishLocalizer ,
51
52
"Greek" : GreekLocalizer ,
52
53
}
54
+
53
55
return localizers [language ]()
54
56
55
57
@@ -70,4 +72,5 @@ def main():
70
72
71
73
if __name__ == "__main__" :
72
74
import doctest
75
+
73
76
doctest .testmod ()
You can’t perform that action at this time.
0 commit comments