def findTranslations(): dir = QDir(":/translations") fileNames = dir.entryList(QDir.Files, QDir.Name) fileNames = [dir.filePath(fileName) for fileName in fileNames] return fileNames
def set_language(self, language): if language != "Default": trans_dir = QDir(os.fspath(TRANSLATIONS_DIR)) filename = trans_dir.filePath(f"i18n_{language}.qm") if not self._translator.load(filename): print("Failed") QGuiApplication.installTranslator(self._translator) else: QGuiApplication.removeTranslator(self._translator) self._engine.retranslate()
def save_dictionary(file_name: str, dict_src: str, regex_map: Dict[str, Entry]): """Saves the dictionary if user modified it. Connected to aboutToQuit signal.""" if MainWindow.dict_modified: if dict_src == file_name: # TODO: change for deploy? check sig too app_data_loc: str = QStandardPaths.writableLocation(QStandardPaths.AppDataLocation) if app_data_loc: # Qt found a place we could save (may not exist) dir_exists = QDir().mkpath(app_data_loc) if dir_exists: # Exists / created abs_dir = QDir(app_data_loc) dict_src = abs_dir.filePath(file_name) with open(dict_src, 'w') as f: json.dump(regex_map, f)