# Path: libraries/tools.py
# def findInOpendView(view_name):
#     """
#     Search a specific view in the list of available views
# 
#     Arguments:
#         view_name {string}
#             Name of the view to search
#     """
#     opened_view = None
#     found = False
#     fwindows = windows()
#     for window in fwindows:
#         views = window.views()
#         for view in views:
#             name = view.name()
#             if name == view_name:
#                 opened_view = view
#                 found = True
#                 break
#         if found:
#             break
#     return (window, opened_view)
# 
# 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
# 
# Path: libraries/I18n.py
# class I18n(object):
#     def __init__(self):
#         self.sys_lang = None
#         self.lang_list = {}
#         self.lang_params = {}
#         self.ids_lang = []
#         self.id_name_dict = {}
#         self.translations = {}
#         self.lang_list = {}
# 
#         self.get_system_lang()
#         self.set_lang()
# 
#     def translate(self, text, *params):
#         """Trnaslate string
# 
#         Translate the text string in the selected language (in the UI
#         of the plugin) and return it
# 
#         Arguments:
#             text {str} -- text to translate
#             *params {[type]} -- [description]
# 
#         Returns:
#             str -- text translated
#         """
#         translated = self.translations.get(text, text)
# 
#         for seq, param in enumerate(params):
#             seq_text = '{%d}' % seq
#             translated = translated.replace(seq_text, str(param))
# 
#         return translated
# 
#     def set_lang(self):
#         """Set Language
# 
#         Sets the language that will be used in the plugin. If there is none
#         option in the preferences file, the system language will be used
# 
#         Arguments:
#             selection {str} -- ISO 639*1 language string
#         """
#         selection = get_setting('lang_id', self.sys_lang)
# 
#         self.get_lang_files()
# 
#         lang = selection if(self.sys_lang in self.id_name_dict) else 'en'
#         file_path = self.id_name_dict[lang]
#         lang_file = TranslatedLines(file_path)
# 
#         self.translations = lang_file.translte_text()
#         save_setting('lang_id', lang)
# 
#     def get_lang_ids(self):
#         """Language ids lists
# 
#         List of the language ids (en, es, fr, etc)
# 
#         Returns:
#             list -- list with ids
#         """
#         return self.ids_lang
# 
#     def get_lang_name(self, lang_id):
#         """Full Language Name
# 
#         Given the ISO 639*1 language name, it will return the name of the
#         language firs in english and the second in the language itself
# 
#         Arguments:
#             lang_id {str} -- ISO 639*1 language name
# 
#         Returns:
#             list -- names of the language
#         """
#         self.get_lang_list()
# 
#         return self.lang_list.get(lang_id, ['Unknown', 'Unknown'])
# 
#     def get_lang_list(self):
#         """Language List
# 
#         Get a list with all languages, the main file is located in
#         deviot/presets/language.list
#         """
#         file_path = deviot.lang_list_path()
#         file = File(file_path)
# 
#         self.lang_list = file.read_json()
# 
#     def get_lang_files(self):
#         """Available Languages
# 
#         Finds all the languages availables in deviot, the language (translated)
#         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)
#         """
#         from locale import getdefaultlocale
# 
#         sys_language = getdefaultlocale()[0]
#         if not sys_language:
#             sys_language = 'en'
#         else:
#             sys_language = sys_language.lower()
# 
#         self.sys_lang = sys_language[:2]


import sublime
import sublime_plugin
import collections
import threading
from ..api import deviot
from .tools import findInOpendView, get_setting
from .I18n import I18n

        Arguments:
            in_file {bool} -- if it's true a new view will be created

        Keyword Arguments:
            name {str} -- name of the new view (default: {''})
        """
        if(in_file):
            self.output_view = self.new_file_panel(direction)
        else:
            package_name = deviot.plugin_name()
            syntax = "Packages/{0}/Console.tmLanguage".format(package_name)

            self.output_view = self.window.create_output_panel('deviot')
            self.output_view.assign_syntax(syntax)
        self.output_view.set_read_only(True)

    def set_focus(self):
        """Set focus

        Sets the focus to the console window
        """
        window = sublime.active_window()
        window.focus_view(self.output_view)

    def print(self, text, *args):
        """
        Adds the string in the deque list
        """
        # translate strings before append

# Path: libraries/tools.py
# def findInOpendView(view_name):
#     """
#     Search a specific view in the list of available views
# 
#     Arguments:
#         view_name {string}
#             Name of the view to search
#     """
#     opened_view = None
#     found = False
#     fwindows = windows()
#     for window in fwindows:
#         views = window.views()
#         for view in views:
#             name = view.name()
#             if name == view_name:
#                 opened_view = view
#                 found = True
#                 break
#         if found:
#             break
#     return (window, opened_view)
# 
# 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
# 
# Path: libraries/I18n.py
# class I18n(object):
#     def __init__(self):
#         self.sys_lang = None
#         self.lang_list = {}
#         self.lang_params = {}
#         self.ids_lang = []
#         self.id_name_dict = {}
#         self.translations = {}
#         self.lang_list = {}
# 
#         self.get_system_lang()
#         self.set_lang()
# 
#     def translate(self, text, *params):
#         """Trnaslate string
# 
#         Translate the text string in the selected language (in the UI
#         of the plugin) and return it
# 
#         Arguments:
#             text {str} -- text to translate
#             *params {[type]} -- [description]
# 
#         Returns:
#             str -- text translated
#         """
#         translated = self.translations.get(text, text)
# 
#         for seq, param in enumerate(params):
#             seq_text = '{%d}' % seq
#             translated = translated.replace(seq_text, str(param))
# 
#         return translated
# 
#     def set_lang(self):
#         """Set Language
# 
#         Sets the language that will be used in the plugin. If there is none
#         option in the preferences file, the system language will be used
# 
#         Arguments:
#             selection {str} -- ISO 639*1 language string
#         """
#         selection = get_setting('lang_id', self.sys_lang)
# 
#         self.get_lang_files()
# 
#         lang = selection if(self.sys_lang in self.id_name_dict) else 'en'
#         file_path = self.id_name_dict[lang]
#         lang_file = TranslatedLines(file_path)
# 
#         self.translations = lang_file.translte_text()
#         save_setting('lang_id', lang)
# 
#     def get_lang_ids(self):
#         """Language ids lists
# 
#         List of the language ids (en, es, fr, etc)
# 
#         Returns:
#             list -- list with ids
#         """
#         return self.ids_lang
# 
#     def get_lang_name(self, lang_id):
#         """Full Language Name
# 
#         Given the ISO 639*1 language name, it will return the name of the
#         language firs in english and the second in the language itself
# 
#         Arguments:
#             lang_id {str} -- ISO 639*1 language name
# 
#         Returns:
#             list -- names of the language
#         """
#         self.get_lang_list()
# 
#         return self.lang_list.get(lang_id, ['Unknown', 'Unknown'])
# 
#     def get_lang_list(self):
#         """Language List
# 
#         Get a list with all languages, the main file is located in
#         deviot/presets/language.list
#         """
#         file_path = deviot.lang_list_path()
#         file = File(file_path)
# 
#         self.lang_list = file.read_json()
# 
#     def get_lang_files(self):
#         """Available Languages
# 
#         Finds all the languages availables in deviot, the language (translated)
#         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)
#         """
#         from locale import getdefaultlocale
# 
#         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/messages.py
import sublime
import sublime_plugin
import collections
import threading
from ..api import deviot
from .tools import findInOpendView, get_setting
from .I18n import I18n


        Arguments:
            in_file {bool} -- if it's true a new view will be created

        Keyword Arguments:
            name {str} -- name of the new view (default: {''})
        """
        if(in_file):
            self.output_view = self.new_file_panel(direction)
        else:
            package_name = deviot.plugin_name()
            syntax = "Packages/{0}/Console.tmLanguage".format(package_name)

            self.output_view = self.window.create_output_panel('deviot')
            self.output_view.assign_syntax(syntax)
        self.output_view.set_read_only(True)

    def set_focus(self):
        """Set focus

        Sets the focus to the console window
        """
        window = sublime.active_window()
        window.focus_view(self.output_view)

    def print(self, text, *args):
        """
        Adds the string in the deque list
        """
        # translate strings before append

        text = I18n().translate(text, *args)