本文整理汇总了Python中nxdrive.wui.translator.Translator类的典型用法代码示例。如果您正苦于以下问题:Python Translator类的具体用法?Python Translator怎么用?Python Translator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Translator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: change_systray_icon
def change_systray_icon(self):
syncing = False
engines = self.manager.get_engines()
invalid_credentials = True
paused = True
offline = True
for engine in engines.itervalues():
syncing |= engine.is_syncing()
invalid_credentials &= engine.has_invalid_credentials()
paused &= engine.is_paused()
offline &= engine.is_offline()
if offline:
new_state = 'stopping'
Action(Translator.get('OFFLINE'))
elif invalid_credentials:
new_state = 'stopping'
Action(Translator.get('INVALID_CREDENTIALS'))
elif not engines or paused:
new_state = 'disabled'
Action.finish_action()
elif syncing:
new_state = 'transferring'
else:
new_state = 'asleep'
Action.finish_action()
self.set_icon_state(new_state)
示例2: __init__
def __init__(self, filename):
values = dict()
values["name"] = filename
super(LockNotification, self).__init__("LOCK",
title=Translator.get("LOCK_NOTIFICATION_TITLE", values),
description=Translator.get("LOCK_NOTIFICATION_DESCRIPTION", values), level=Notification.LEVEL_INFO,
flags=Notification.FLAG_VOLATILE|Notification.FLAG_BUBBLE|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD)
示例3: menu_right
def menu_right(self):
"""
Create the context menu.
It shows up on left click.
Note: icons will not be displayed on every GNU/Linux
distributions, it depends on the graphical environment.
"""
if not self.__menu_right:
style = QApplication.style()
menu = QMenu()
menu.addAction(
style.standardIcon(QStyle.SP_FileDialogInfoView),
Translator.get('SETTINGS'),
self.application.show_settings,
)
menu.addSeparator()
menu.addAction(
style.standardIcon(QStyle.SP_MessageBoxQuestion),
Translator.get('HELP'),
self.application.open_help)
menu.addSeparator()
menu.addAction(
style.standardIcon(QStyle.SP_DialogCloseButton),
Translator.get('QUIT'),
self.application.quit)
self.__menu_right = menu
return self.__menu_right
示例4: _direct_edit_conflict
def _direct_edit_conflict(self, filename, ref, digest):
log.trace('Entering _direct_edit_conflict for %r / %r', filename, ref)
try:
filename = unicode(filename)
if filename in self._conflicts_modals:
log.trace('Filename already in _conflicts_modals: %r', filename)
return
log.trace('Putting filename in _conflicts_modals: %r', filename)
self._conflicts_modals[filename] = True
info = dict(name=filename)
dlg = WebModal(
self,
Translator.get('DIRECT_EDIT_CONFLICT_MESSAGE', info),
)
dlg.add_button('OVERWRITE',
Translator.get('DIRECT_EDIT_CONFLICT_OVERWRITE'))
dlg.add_button('CANCEL',
Translator.get('DIRECT_EDIT_CONFLICT_CANCEL'))
res = dlg.exec_()
if res == 'OVERWRITE':
self.manager.direct_edit.force_update(unicode(ref),
unicode(digest))
del self._conflicts_modals[filename]
except:
log.exception('Error while displaying Direct Edit'
' conflict modal dialog for %r', filename)
示例5: _update_notification
def _update_notification(self):
replacements = dict()
replacements["version"] = self.manager.get_updater().get_status()[1]
notification = Notification(uuid="AutoUpdate",
flags=Notification.FLAG_BUBBLE|Notification.FLAG_VOLATILE|Notification.FLAG_UNIQUE,
title=Translator.get("AUTOUPDATE_NOTIFICATION_TITLE", replacements),
description=Translator.get("AUTOUPDATE_NOTIFICATION_MESSAGE", replacements))
self.manager.get_notification_service().send_notification(notification)
示例6: __init__
def __init__(self, engine_uid, filename):
values = dict()
values["name"] = filename
title = Translator.get("DELETE_READONLY", values)
description = Translator.get("DELETE_READONLY_DOCUMENT", values)
super(DeleteReadOnlyNotification, self).__init__("DELETE_READONLY", title=title, description=description,
engine_uid=engine_uid, level=Notification.LEVEL_INFO,
flags=Notification.FLAG_VOLATILE|Notification.FLAG_BUBBLE|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD)
示例7: testLoadExistingLanguage
def testLoadExistingLanguage(self):
Translator(MockManager(), self.getFolder('i18n.js'), "fr")
# Should not fallback on en
self.assertEqual("fr", Translator.locale())
# Test the key fallback
self.assertEqual("Fallback", Translator.get("FALLBACK"))
self.assertEqual(u"Fran\xe7ais", Translator.get("LANGUAGE"))
self.assertEqual("BOUZOUF", Translator.get("BOUZOUF"))
示例8: __init__
def __init__(self, engine_uid, doc_pair):
values = dict()
values["name"] = doc_pair.local_name
title = Translator.get("CONFLICT", values)
description = Translator.get("CONFLICT_ON_FILE", values)
super(ConflictNotification, self).__init__("CONFLICT_FILE", title=title, description=description,
engine_uid=engine_uid, level=Notification.LEVEL_WARNING,
flags=Notification.FLAG_VOLATILE|Notification.FLAG_ACTIONABLE|Notification.FLAG_BUBBLE|Notification.FLAG_PERSISTENT|Notification.FLAG_DISCARD_ON_TRIGGER|Notification.FLAG_REMOVE_ON_DISCARD,
action="drive.showConflicts();")
示例9: _export_state
def _export_state(self, state):
if state is None:
return None
result = super(WebConflictsApi, self)._export_state(state)
result["last_contributor"] = self._engine.get_user_full_name(state.last_remote_modifier)
date_time = self.get_date_from_sqlite(state.last_remote_updated)
result["last_remote_update"] = "" if date_time == 0 else Translator.format_datetime(date_time)
date_time = self.get_date_from_sqlite(state.last_local_updated)
result["last_local_update"] = "" if date_time == 0 else Translator.format_datetime(date_time)
return result
示例10: create_debug_menu
def create_debug_menu(self, parent):
menuDebug = QtGui.QMenu(parent)
menuDebug.addAction(Translator.get("DEBUG_WINDOW"), self.show_debug_window)
menuDebug.addAction(Translator.get("DEBUG_SYSTRAY_MESSAGE"), self._debug_show_message)
for engine in self.manager.get_engines().values():
action = QtGui.QAction(engine._name, menuDebug)
action.setMenu(self._create_debug_engine_menu(engine, menuDebug))
action.setData(engine)
menuDebug.addAction(action)
return menuDebug
示例11: _update_notification
def _update_notification(self):
replacements = dict(version=self.manager.get_updater().get_status()[1])
notification = Notification(
uuid='AutoUpdate',
flags=(Notification.FLAG_BUBBLE
| Notification.FLAG_VOLATILE
| Notification.FLAG_UNIQUE),
title=Translator.get('AUTOUPDATE_NOTIFICATION_TITLE', replacements),
description=Translator.get('AUTOUPDATE_NOTIFICATION_MESSAGE',
replacements),
)
self.manager.notification_service.send_notification(notification)
示例12: _create_debug_engine_menu
def _create_debug_engine_menu(self, engine, parent):
menuDebug = QtGui.QMenu(parent)
action = QtGui.QAction(Translator.get("DEBUG_INVALID_CREDENTIALS"), menuDebug)
action.setCheckable(True)
action.setChecked(engine.has_invalid_credentials())
action.setData(engine)
action.triggered.connect(self._debug_toggle_invalid_credentials)
menuDebug.addAction(action)
action = QtGui.QAction(Translator.get("DEBUG_FILE_STATUS"), menuDebug)
action.setData(engine)
action.triggered.connect(self._debug_show_file_status)
menuDebug.addAction(action)
return menuDebug
示例13: _direct_edit_conflict
def _direct_edit_conflict(self, filename, ref, digest):
filename = unicode(filename)
if filename in self._conflicts_modals:
return
self._conflicts_modals[filename] = True
info = dict()
info["name"] = filename
dlg = WebModal(self, Translator.get("DIRECT_EDIT_CONFLICT_MESSAGE", info))
dlg.add_button("OVERWRITE", Translator.get("DIRECT_EDIT_CONFLICT_OVERWRITE"))
dlg.add_button("CANCEL", Translator.get("DIRECT_EDIT_CONFLICT_CANCEL"))
res = dlg.exec_()
if res == "OVERWRITE":
self.manager.get_drive_edit().force_update(unicode(ref), unicode(digest))
del self._conflicts_modals
示例14: _root_deleted
def _root_deleted(self):
engine = self.sender()
info = dict()
log.debug("Root has been deleted for engine: %s", engine.get_uid())
info["folder"] = engine.get_local_folder()
dlg = WebModal(self, Translator.get("DRIVE_ROOT_DELETED", info))
dlg.add_button("RECREATE", Translator.get("DRIVE_ROOT_RECREATE"), style="primary")
dlg.add_button("DISCONNECT", Translator.get("DRIVE_ROOT_DISCONNECT"), style="danger")
res = dlg.exec_()
if res == "DISCONNECT":
self.manager.unbind_engine(engine.get_uid())
elif res == "RECREATE":
engine.reinit()
engine.start()
示例15: __init__
def __init__(self, filename):
values = dict()
values["name"] = filename
title = Translator.get("READONLY", values)
description = Translator.get("DIRECT_EDIT_READONLY_FILE", values)
super(DirectEditReadOnlyNotification, self).__init__(
"DIRECT_EDIT_READONLY",
title=title,
description=description,
level=Notification.LEVEL_WARNING,
flags=Notification.FLAG_VOLATILE
| Notification.FLAG_BUBBLE
| Notification.FLAG_DISCARD_ON_TRIGGER
| Notification.FLAG_REMOVE_ON_DISCARD,
)