1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-29 19:15:56 +00:00
bazarr/libs/langdetect/utils/messages.py

24 lines
635 B
Python
Raw Normal View History

from os import path
class Messages(object):
MESSAGES_FILENAME = path.join(path.dirname(__file__), 'messages.properties')
def __init__(self):
self.messages = {}
with open(self.MESSAGES_FILENAME, 'r') as f:
for line in f:
key, _, value = line.strip().partition('=')
self.messages[key] = value.encode().decode('unicode_escape')
def get_string(self, key):
return self.messages.get(key, '!%s!' % key)
_messages = None
def get_string(key):
global _messages
if _messages is None:
_messages = Messages()
return _messages.get_string(key)