# Path: libraries/tools.py
# def singleton(cls):
#     """
#     restricts the instantiation of a class to one object
#     """
#     instances = {}
# 
#     def _singleton(*args, **kw):
#         if cls not in instances:
#             instances[cls] = cls(*args, **kw)
#         return instances[cls]
#     return _singleton
# 
# def get_setting(key, default=None):
#     """
#     get setting handled by ST
#     """
#     settings = load_settings("deviot.sublime-settings")
#     value = settings.get(key, default)
# 
#     try:
#         return eval(value)
#     except(NameError, SyntaxError, TypeError) as e:
#         return value
# 
# def save_setting(key, value=None, sys_options=False):
#     """
#     save setting handled by ST
#     """
#     settings = load_settings("deviot.sublime-settings")
# 
#     if(value is None):
#         settings.erase(key)
#     else:
#         settings.set(key, value)
# 
#     save_settings("deviot.sublime-settings")
# 
# Path: libraries/file.py
# class File(object):
# 
#     def __init__(self, file_name):
#         self.file_name = file_name
# 
#     def write(self, text):
#         """Write File
# 
#         Writes the content of text in the file set in self.file_name
# 
#         Arguments:
#             text {str} -- text to write
# 
#         Returns:
#             bool -- true if was writed succesuflly
#         """
#         encoding = 'utf-8'
#         with codecs.open(self.file_name, 'w', encoding) as file:
#             file.write(text)
#             return True
# 
#     def read(self):
#         """Read File
# 
#         returns the content of the file set in self.file_name
# 
#         Returns:
#             str -- string from file
#         """
#         encoding = 'utf-8'
#         text = ''
# 
#         try:
#             with codecs.open(self.file_name, 'r', encoding) as file:
#                 text = file.read()
#         except(IOError, UnicodeError):
#             pass
#         return text
# 
#     def read_json(self):
#         """read JSON
#         serialize the content of the file and transform it in
#         a json format type
# 
#         Returns:
#             JSON -- serialized json data
#         """
# 
#         file = self.read()
# 
#         if(file):
#             return json.loads(file)
# 
#         return []
# 
#     def save_json(self, text):
#         """Save JSON
# 
#         Stores JSON data in a file, before do it deserialize
# 
#         Arguments:
#             text {str} -- json data to stored
#         """
#         text = json.dumps(text, sort_keys=True, indent=4)
#         self.write(text)


from ..api import deviot
from .tools import singleton, get_setting, save_setting
from os import path
from .file import File
from glob import glob
        from locale import getdefaultlocale
        files are located in Deviot/languages/nn.lang.

        NOTE: the language file MUST be in the ISO 639*1 format (two letters)
        and must have the extension .lang
        """
        lang_path = deviot.lang_path()
        lang_paths = glob(lang_path + '/*.lang')
        lang_file_names = [path.basename(file_path)
                           for file_path in lang_paths]  # es.lang
        ids_lang = [path.splitext(name)[0] for name in lang_file_names]  # es
        self.id_name_dict.update(dict(zip(ids_lang, lang_paths))
                                 )  # {"es": 'path/es.lang'}
        ids_lang.sort()  # order list
        self.ids_lang = ids_lang

    def get_system_lang(self):
        """System Language

        Get the language of the system (O.S)
        """

        sys_language = getdefaultlocale()[0]
        if not sys_language:
            sys_language = 'en'
        else:
            sys_language = sys_language.lower()

        self.sys_lang = sys_language[:2]



# Path: libraries/tools.py
# def singleton(cls):
#     """
#     restricts the instantiation of a class to one object
#     """
#     instances = {}
# 
#     def _singleton(*args, **kw):
#         if cls not in instances:
#             instances[cls] = cls(*args, **kw)
#         return instances[cls]
#     return _singleton
# 
# def get_setting(key, default=None):
#     """
#     get setting handled by ST
#     """
#     settings = load_settings("deviot.sublime-settings")
#     value = settings.get(key, default)
# 
#     try:
#         return eval(value)
#     except(NameError, SyntaxError, TypeError) as e:
#         return value
# 
# def save_setting(key, value=None, sys_options=False):
#     """
#     save setting handled by ST
#     """
#     settings = load_settings("deviot.sublime-settings")
# 
#     if(value is None):
#         settings.erase(key)
#     else:
#         settings.set(key, value)
# 
#     save_settings("deviot.sublime-settings")
# 
# Path: libraries/file.py
# class File(object):
# 
#     def __init__(self, file_name):
#         self.file_name = file_name
# 
#     def write(self, text):
#         """Write File
# 
#         Writes the content of text in the file set in self.file_name
# 
#         Arguments:
#             text {str} -- text to write
# 
#         Returns:
#             bool -- true if was writed succesuflly
#         """
#         encoding = 'utf-8'
#         with codecs.open(self.file_name, 'w', encoding) as file:
#             file.write(text)
#             return True
# 
#     def read(self):
#         """Read File
# 
#         returns the content of the file set in self.file_name
# 
#         Returns:
#             str -- string from file
#         """
#         encoding = 'utf-8'
#         text = ''
# 
#         try:
#             with codecs.open(self.file_name, 'r', encoding) as file:
#                 text = file.read()
#         except(IOError, UnicodeError):
#             pass
#         return text
# 
#     def read_json(self):
#         """read JSON
#         serialize the content of the file and transform it in
#         a json format type
# 
#         Returns:
#             JSON -- serialized json data
#         """
# 
#         file = self.read()
# 
#         if(file):
#             return json.loads(file)
# 
#         return []
# 
#     def save_json(self, text):
#         """Save JSON
# 
#         Stores JSON data in a file, before do it deserialize
# 
#         Arguments:
#             text {str} -- json data to stored
#         """
#         text = json.dumps(text, sort_keys=True, indent=4)
#         self.write(text)


# Path: libraries/I18n.py
from ..api import deviot
from .tools import singleton, get_setting, save_setting
from os import path
from .file import File
from glob import glob
        from locale import getdefaultlocale

        files are located in Deviot/languages/nn.lang.

        NOTE: the language file MUST be in the ISO 639*1 format (two letters)
        and must have the extension .lang
        """
        lang_path = deviot.lang_path()
        lang_paths = glob(lang_path + '/*.lang')
        lang_file_names = [path.basename(file_path)
                           for file_path in lang_paths]  # es.lang
        ids_lang = [path.splitext(name)[0] for name in lang_file_names]  # es
        self.id_name_dict.update(dict(zip(ids_lang, lang_paths))
                                 )  # {"es": 'path/es.lang'}
        ids_lang.sort()  # order list
        self.ids_lang = ids_lang

    def get_system_lang(self):
        """System Language

        Get the language of the system (O.S)
        """

        sys_language = getdefaultlocale()[0]
        if not sys_language:
            sys_language = 'en'
        else:
            sys_language = sys_language.lower()

        self.sys_lang = sys_language[:2]



class TranslatedLines(File):