本文整理汇总了Python中ubiquity.i18n.get_string函数的典型用法代码示例。如果您正苦于以下问题:Python get_string函数的具体用法?Python get_string怎么用?Python get_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_string函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_link_clicked
def on_link_clicked(self, widget, uri):
# Connected in glade.
lang = self.get_language()
if not lang:
lang = 'C'
lang = lang.split('.')[0] # strip encoding
if uri == 'update':
if self.updating_installer:
return True
self.updating_installer = True
if not auto_update.update(self.controller._wizard):
# no updates, so don't check again
if self.release_notes_url:
text = i18n.get_string('release_notes_only', lang)
self.release_notes_label.set_markup(text)
else:
self.release_notes_label.hide()
self.updating_installer = False
elif uri == 'release-notes':
import subprocess
# uri = self.release_notes_url.replace('${LANG}', lang)
#subprocess.Popen(['sensible-browser', uri], close_fds=True,
# preexec_fn=misc.drop_all_privileges)
uri = '/cdrom/.disk/release_notes_url'
subprocess.Popen(['/usr/bin/gedit', uri], close_fds=True,
preexec_fn=misc.drop_all_privileges) #change by wangjingsi
return True
示例2: get_string
def get_string(self, name, lang=None, prefix=None):
"""Get the string name in the given lang or a default."""
if lang is None:
lang = self.locale
if lang is None and 'LANG' in os.environ:
lang = os.environ['LANG']
return i18n.get_string(name, lang, prefix)
示例3: on_language_selection_changed
def on_language_selection_changed(self):
lang = self.selected_language()
if not lang:
return
# strip encoding; we use UTF-8 internally no matter what
lang = lang.split('.')[0]
self.controller.translate(lang)
if not self.only:
release = misc.get_release()
install_medium = misc.get_install_medium()
install_medium = i18n.get_string(install_medium, lang)
for widget in (self.page.try_install_text_label,
self.page.try_ubuntu,
self.page.install_ubuntu,
self.page.alpha_warning_label):
text = widget.text()
text = text.replace('${RELEASE}', release.name)
text = text.replace('${MEDIUM}', install_medium)
text = text.replace('Ubuntu', 'Kubuntu')
widget.setText(text)
self.update_release_notes_label()
for w in self.widgetHidden:
w.show()
self.widgetHidden = []
示例4: plugin_translate
def plugin_translate(self, lang):
PreparePageBase.plugin_translate(self, lang)
release = misc.get_release()
from gi.repository import Gtk
for widget in [self.prepare_foss_disclaimer]:
text = i18n.get_string(Gtk.Buildable.get_name(widget), lang)
text = text.replace('${RELEASE}', release.name)
widget.set_label(text)
示例5: update_release_notes_label
def update_release_notes_label(self):
lang = self.selected_language()
if not lang:
return
# strip encoding; we use UTF-8 internally no matter what
lang = lang.split('.')[0]
# Either leave the release notes label alone (both release notes and a
# critical update are available), set it to just the release notes,
# just the critical update, or neither, as appropriate.
if self.page.release_notes_label:
if self.release_notes_found and self.update_installer:
text = i18n.get_string('release_notes_label', lang)
self.page.release_notes_label.setText(text)
elif self.release_notes_found:
text = i18n.get_string('release_notes_only', lang)
self.page.release_notes_label.setText(text)
elif self.update_installer:
text = i18n.get_string('update_installer_only', lang)
self.page.release_notes_label.setText(text)
示例6: on_language_selection_changed
def on_language_selection_changed(self, *args, **kwargs):
lang = self.get_language()
if not lang:
return
# strip encoding; we use UTF-8 internally no matter what
lang = lang.split(".")[0]
self.controller.translate(lang)
import gtk
ltr = i18n.get_string("default-ltr", lang, "ubiquity/imported")
if ltr == "default:RTL":
gtk.widget_set_default_direction(gtk.TEXT_DIR_RTL)
else:
gtk.widget_set_default_direction(gtk.TEXT_DIR_LTR)
if not self.only:
release_name = misc.get_release_name()
install_medium = misc.get_install_medium()
install_medium = i18n.get_string(install_medium, lang)
for widget in (
self.try_text_label,
self.try_ubuntu,
self.install_ubuntu,
self.ready_text_label,
self.alpha_warning_label,
):
text = i18n.get_string(gtk.Buildable.get_name(widget), lang)
text = text.replace("${RELEASE}", release_name)
text = text.replace("${MEDIUM}", install_medium)
widget.set_label(text)
if self.release_notes_label:
if self.release_notes_url and self.update_installer:
pass
elif self.release_notes_url:
text = i18n.get_string("release_notes_only", lang)
self.release_notes_label.set_markup(text)
elif self.update_installer:
text = i18n.get_string("update_installer_only", lang)
self.release_notes_label.set_markup(text)
else:
self.release_notes_label.hide()
for w in self.page.get_children():
w.show()
示例7: plugin_translate
def plugin_translate(self, lang):
PreparePageBase.plugin_translate(self, lang)
release = misc.get_release()
from gi.repository import Gtk
for widget in [self.prepare_download_updates,
self.label_required_space,
self.label_free_space]:
text = i18n.get_string(Gtk.Buildable.get_name(widget), lang)
text = text.replace('${RELEASE}', release.name)
widget.set_label(text)
示例8: on_release_notes_link
def on_release_notes_link(self, link):
lang = self.selected_language()
if link == "release-notes":
if lang:
lang = lang.split(".")[0].lower()
url = self.release_notes_url.replace("${LANG}", lang)
self.openURL(url)
elif link == "update":
if not auto_update.update(self.controller._wizard):
# no updates, so don't check again
text = i18n.get_string("release_notes_only", lang)
self.page.release_notes_label.setText(text)
示例9: on_release_notes_link
def on_release_notes_link(self, link):
lang = self.selected_language()
if link == "release-notes":
if lang:
lang = lang.split('.')[0].lower()
url = self.release_notes_url.replace('${LANG}', lang)
self.openURL(url)
elif link == "update":
if self.updating_installer:
return
self.updating_installer = True
if not auto_update.update(self.controller._wizard):
# no updates, so don't check again
text = i18n.get_string('release_notes_only', lang)
self.page.release_notes_label.setText(text)
self.updating_installer = False
示例10: on_link_clicked
def on_link_clicked(self, widget, uri):
# Connected in glade.
lang = self.get_language()
lang = lang.split(".")[0] # strip encoding
if uri == "update":
if not auto_update.update(self.controller._wizard):
# no updates, so don't check again
if self.release_notes_url:
text = i18n.get_string("release_notes_only", lang)
self.release_notes_label.set_markup(text)
else:
self.release_notes_label.hide()
elif uri == "release-notes":
import subprocess
uri = self.release_notes_url.replace("${LANG}", lang)
subprocess.Popen(["sensible-browser", uri], close_fds=True, preexec_fn=misc.drop_all_privileges)
return True
示例11: progress_loop
def progress_loop(self):
"""prepare, copy and config the system in the core install process."""
syslog.syslog('progress_loop()')
self.current_page = None
slideshow_dir = '/usr/share/ubiquity-slideshow'
slideshow_locale = self.slideshow_get_available_locale(slideshow_dir, self.locale)
slideshow_main = slideshow_dir + '/slides/index.html'
s = self.app.desktop().availableGeometry()
fail = None
if os.path.exists(slideshow_main):
if s.height >= 600 and s.width >= 800:
slides = 'file://' + slideshow_main
if slideshow_locale != 'c': #slideshow will use default automatically
slides += '#?locale=' + slideshow_locale
ltr = i18n.get_string('default-ltr', slideshow_locale, 'ubiquity/imported')
if ltr == 'default:RTL':
slides += '?rtl'
try:
from PyQt4.QtWebKit import QWebView
from PyQt4.QtWebKit import QWebPage
def openLink(qUrl):
QDesktopServices.openUrl(qUrl)
webView = QWebView()
webView.linkClicked.connect(openLink)
webView.setContextMenuPolicy(Qt.NoContextMenu)
webView.page().setLinkDelegationPolicy(QWebPage.DelegateExternalLinks)
webView.page().mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
webView.page().mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
webView.setFixedSize(700,420)
webView.load(QUrl(slides))
#add the webview to the extra frame of the progress dialog
self.progressDialog.extraFrame.layout().addWidget(webView)
self.progressDialog.extraFrame.setVisible(True)
except ImportError:
fail = 'Webkit not present.'
else:
fail = 'Display < 800x600 (%sx%s).' % (s.width, s.height)
else:
fail = 'No slides present for %s.' % slideshow_dir
if fail:
syslog.syslog('Not displaying the slideshow: %s' % fail)
self.progressDialog.show()
self.debconf_progress_start(
0, 100, self.get_string('ubiquity/install/title'))
self.debconf_progress_region(0, 15)
if not self.oem_user_config:
self.start_debconf()
dbfilter = partman_commit.PartmanCommit(self)
if dbfilter.run_command(auto_process=True) != 0:
while self.progress_position.depth() != 0:
self.debconf_progress_stop()
self.progressDialog.hide()
self.return_to_partitioning()
return
# No return to partitioning from now on
self.installing_no_return = True
self.debconf_progress_region(15, 100)
self.start_debconf()
dbfilter = install.Install(self)
ret = dbfilter.run_command(auto_process=True)
if ret != 0:
self.installing = False
if ret == 3:
# error already handled by Install
sys.exit(ret)
elif (os.WIFSIGNALED(ret) and
os.WTERMSIG(ret) in (signal.SIGINT, signal.SIGKILL,
signal.SIGTERM)):
sys.exit(ret)
elif os.path.exists('/var/lib/ubiquity/install.trace'):
tbfile = open('/var/lib/ubiquity/install.trace')
realtb = tbfile.read()
tbfile.close()
raise RuntimeError, ("Install failed with exit code %s\n%s" %
(ret, realtb))
else:
raise RuntimeError, ("Install failed with exit code %s; see "
"/var/log/syslog" % ret)
while self.progress_position.depth() != 0:
self.debconf_progress_stop()
# just to make sure
self.progressDialog.hide()
#.........这里部分代码省略.........
示例12: get_string
def get_string(self, name, lang=None):
"""Get the string name in the given lang or a default."""
if lang is None:
lang = self.locale
return i18n.get_string(name, lang)