-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlanguage_controller.py
More file actions
29 lines (23 loc) · 1.06 KB
/
language_controller.py
File metadata and controls
29 lines (23 loc) · 1.06 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
import os.path
import utility_controller as uc
from language_strategy import (LanguageStrategy, EnglishLanguageStrategy, GermanLanguageStrategy,
FrenchLanguageStrategy, \
SpanishLanguageStrategy)
from message_dto import MessageDTO
class LanguageController:
def __init__(self, strategy: LanguageStrategy):
self._strategy = strategy
def get_messages(self) -> MessageDTO:
return self._strategy.get_messages()
def path_to_json_file() -> str:
return os.path.join(uc.get_plugin_path(), 'messages.json')
def get_language_controller() -> LanguageController:
language = uc.get_language()
if language == 'de':
return LanguageController(GermanLanguageStrategy(path_to_json_file()))
elif language == 'fr':
return LanguageController(FrenchLanguageStrategy(path_to_json_file()))
elif language == 'es':
return LanguageController(SpanishLanguageStrategy(path_to_json_file()))
else:
return LanguageController(EnglishLanguageStrategy(path_to_json_file()))