def scan_plugin_info(self): self.word_all_list = [] self.words_all_list = [] self.word_dict = {} self.words_dict = {} for plugin_name in os.listdir(self.plugin_dir): plugin_config_file = os.path.join(self.plugin_dir, plugin_name, self.plugin_config_name) plugin_config = Config(plugin_config_file) plugin_config.load() language = LANGUAGE.replace("_", "-") plugin_display_name = plugin_config.get("Plugin Info", "name[%s]" % language) or plugin_config.get("Plugin Info", "name[en]") is_support_word = is_true(plugin_config.get("Language Info", "word_translate")) is_support_words = is_true(plugin_config.get("Language Info", "words_translate")) support_all_language = is_true(plugin_config.get("Language Info", "support_all_language")) two_way_translate = is_true(plugin_config.get("Language Info", "two_way_translate")) src_language = plugin_config.get("Language Info", "src_language") dst_language = plugin_config.get("Language Info", "dst_language") need_network = is_true(plugin_config.get("Language Info", "need_network")) if is_support_word: if support_all_language: self.word_all_list.append((plugin_name, plugin_display_name, need_network)) else: self.update_dict(self.word_dict, src_language, dst_language, plugin_name, plugin_display_name, need_network) if two_way_translate: self.update_dict(self.word_dict, dst_language, src_language, plugin_name, plugin_display_name, need_network) if is_support_words: if support_all_language: self.words_all_list.append((plugin_name, plugin_display_name, need_network)) else: self.update_dict(self.words_dict, src_language, dst_language, plugin_name, plugin_display_name, need_network) if two_way_translate: self.update_dict(self.words_dict, dst_language, src_language, plugin_name, plugin_display_name, need_network)
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from PyQt5.QtCore import QObject, pyqtSlot import os from xdg import get_config_file from deepin_utils.config import Config from deepin_utils.core import is_true from nls import LANGUAGE init_lang = LANGUAGE.replace("_", "-") if init_lang in ["zh-CN"]: init_word_dict = "youdao" init_word_voice = "youdao" init_words_voice = "google" else: init_word_dict = "google_simple" init_word_voice = "google" init_words_voice = "google" DEFAULT_CONFIG = [ ("trayicon", [("pause", False), ("toggle_speech", True), ("key_trigger_select", False), ]),