Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Soapy7261 committed Aug 9, 2024
1 parent 0d7eaa2 commit d40bbc0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions providers/translation/get_translate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from os import walk
from json import load
from sys import exit as sysexit

class Translation:
def _get_translation_map(self) -> dict:
"You shouldn't have to use this unless your debugging."
Expand All @@ -22,19 +23,24 @@ def get_translation(self, language: str, message_code: str) -> str:
return translation_map["en-US"][message_code] # Default to US
except KeyError:
return "No message available for this given message code"

if __name__ == "__main__":
#Just some tests
translation_class = Translation()
if translation_class.get_translation("en-GB", "test") != "British!":
print ("Test 1 failed")
sysexit(1)

if translation_class.get_translation("thislanguage-doesnotexist", "test") != "Works!":
print ("Test 2 failed")
sysexit(1)

if translation_class.get_translation("en-US", "test") != "Works!":
print ("Test 3 failed")
sysexit(1)

if translation_class.get_translation("en-US", "thisdoesnotexist") != "No message available for this given message code":
print ("Test 4 failed")
sysexit(1)

print ("All tests passed!")

0 comments on commit d40bbc0

Please sign in to comment.