The constants will be set before the language is selected, so only mark the strings as translatable in constants.py and translate them where they are used. --- pyanaconda/constants.py | 24 ++++++++++++------------ pyanaconda/ui/gui/spokes/password.py | 16 ++++++++-------- pyanaconda/ui/gui/spokes/user.py | 16 ++++++++-------- pyanaconda/ui/tui/spokes/__init__.py | 2 +- pyanaconda/ui/tui/spokes/askvnc.py | 4 ++-- 5 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py index 13440e2..7af5014 100644 --- a/pyanaconda/constants.py +++ b/pyanaconda/constants.py @@ -19,7 +19,7 @@ # Author(s): Erik Troan ewt@redhat.com #
-from pyanaconda.i18n import _ +from pyanaconda.i18n import N_
SELINUX_DEFAULT = 1
@@ -70,8 +70,8 @@ DEFAULT_KEYBOARD = "us" DRACUT_SHUTDOWN_EJECT = "/run/initramfs/usr/lib/dracut/hooks/shutdown/99anaconda-eject.sh"
# VNC questions -USEVNC = _("Start VNC") -USETEXT = _("Use text mode") +USEVNC = N_("Start VNC") +USETEXT = N_("Use text mode")
# Runlevel files RUNLEVELS = {3: 'multi-user.target', 5: 'graphical.target'} @@ -133,12 +133,12 @@ UNSUPPORTED_HW = 1 << 28
# Password validation PASSWORD_MIN_LEN = 6 -PASSWORD_EMPTY_ERROR = _("The password is empty.") -PASSWORD_CONFIRM_ERROR_GUI = _("The passwords do not match.") -PASSWORD_CONFIRM_ERROR_TUI = _("The passwords you entered were different. Please try again.") -PASSWORD_WEAK = _("The password you have provided is weak. You will have to press Done twice to confirm it.") -PASSWORD_WEAK_WITH_ERROR = _("The password you have provided is weak: %s. You will have to press Done twice to confirm it.") -PASSWORD_WEAK_CONFIRM = _("You have provided a weak password. Press Done again to use anyway.") -PASSWORD_WEAK_CONFIRM_WITH_ERROR = _("You have provided a weak password: %s. Press Done again to use anyway.") - -PASSWORD_STRENGTH_DESC = [_("Empty"), _("Weak"), _("Fair"), _("Good"), _("Strong")] +PASSWORD_EMPTY_ERROR = N_("The password is empty.") +PASSWORD_CONFIRM_ERROR_GUI = N_("The passwords do not match.") +PASSWORD_CONFIRM_ERROR_TUI = N_("The passwords you entered were different. Please try again.") +PASSWORD_WEAK = N_("The password you have provided is weak. You will have to press Done twice to confirm it.") +PASSWORD_WEAK_WITH_ERROR = N_("The password you have provided is weak: %s. You will have to press Done twice to confirm it.") +PASSWORD_WEAK_CONFIRM = N_("You have provided a weak password. Press Done again to use anyway.") +PASSWORD_WEAK_CONFIRM_WITH_ERROR = N_("You have provided a weak password: %s. Press Done again to use anyway.") + +PASSWORD_STRENGTH_DESC = [N_("Empty"), N_("Weak"), N_("Fair"), N_("Good"), N_("Strong")] diff --git a/pyanaconda/ui/gui/spokes/password.py b/pyanaconda/ui/gui/spokes/password.py index 58e6719..703e726 100644 --- a/pyanaconda/ui/gui/spokes/password.py +++ b/pyanaconda/ui/gui/spokes/password.py @@ -148,9 +148,9 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke):
if not editable.get_text(): if editable == self.pw: - return PASSWORD_EMPTY_ERROR + return _(PASSWORD_EMPTY_ERROR) else: - return PASSWORD_CONFIRM_ERROR_GUI + return _(PASSWORD_CONFIRM_ERROR_GUI) else: return GUICheck.CHECK_OK
@@ -170,7 +170,7 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke): if (not pw and not confirm) and self._kickstarted: result = GUICheck.CHECK_OK elif confirm and (pw != confirm): - result = PASSWORD_CONFIRM_ERROR_GUI + result = _(PASSWORD_CONFIRM_ERROR_GUI) else: result = GUICheck.CHECK_OK
@@ -207,7 +207,7 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke): val = 3 else: val = 4 - text = PASSWORD_STRENGTH_DESC[val] + text = _(PASSWORD_STRENGTH_DESC[val])
self.pw_bar.set_value(val) self.pw_label.set_text(text) @@ -237,14 +237,14 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke): return GUICheck.CHECK_OK elif self._waivePasswordClicks == 1: if self._pwq_error: - return PASSWORD_WEAK_CONFIRM_WITH_ERROR % self._pwq_error + return _(PASSWORD_WEAK_CONFIRM_WITH_ERROR) % self._pwq_error else: - return PASSWORD_WEAK_CONFIRM + return _(PASSWORD_WEAK_CONFIRM) else: if self._pwq_error: - return PASSWORD_WEAK_WITH_ERROR % self._pwq_error + return _(PASSWORD_WEAK_WITH_ERROR) % self._pwq_error else: - return PASSWORD_WEAK + return _(PASSWORD_WEAK) else: return GUICheck.CHECK_OK
diff --git a/pyanaconda/ui/gui/spokes/user.py b/pyanaconda/ui/gui/spokes/user.py index b6d855b..591f65b 100644 --- a/pyanaconda/ui/gui/spokes/user.py +++ b/pyanaconda/ui/gui/spokes/user.py @@ -417,7 +417,7 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke): val = 3 else: val = 4 - text = PASSWORD_STRENGTH_DESC[val] + text = _(PASSWORD_STRENGTH_DESC[val])
self.pw_bar.set_value(val) self.pw_label.set_text(text) @@ -480,9 +480,9 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke): return GUICheck.CHECK_OK elif not editable.get_text(): if editable == self.pw: - return PASSWORD_EMPTY_ERROR + return _(PASSWORD_EMPTY_ERROR) else: - return PASSWORD_CONFIRM_ERROR_GUI + return _(PASSWORD_CONFIRM_ERROR_GUI) else: return GUICheck.CHECK_OK
@@ -499,7 +499,7 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke): if (not self.usepassword.get_active()) or self._user.password_kickstarted: result = GUICheck.CHECK_OK elif self.confirm.get_text() and (self.pw.get_text() != self.confirm.get_text()): - result = PASSWORD_CONFIRM_ERROR_GUI + result = _(PASSWORD_CONFIRM_ERROR_GUI) else: result = GUICheck.CHECK_OK
@@ -541,14 +541,14 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke): return GUICheck.CHECK_OK elif self._waivePasswordClicks == 1: if self._pwq_error: - return PASSWORD_WEAK_CONFIRM_WITH_ERROR % self._pwq_error + return _(PASSWORD_WEAK_CONFIRM_WITH_ERROR) % self._pwq_error else: - return PASSWORD_WEAK_CONFIRM + return _(PASSWORD_WEAK_CONFIRM) else: if self._pwq_error: - return PASSWORD_WEAK_WITH_ERROR % self._pwq_error + return _(PASSWORD_WEAK_WITH_ERROR) % self._pwq_error else: - return PASSWORD_WEAK + return _(PASSWORD_WEAK) else: return GUICheck.CHECK_OK
diff --git a/pyanaconda/ui/tui/spokes/__init__.py b/pyanaconda/ui/tui/spokes/__init__.py index c9c80c7..8ffe5d1 100644 --- a/pyanaconda/ui/tui/spokes/__init__.py +++ b/pyanaconda/ui/tui/spokes/__init__.py @@ -116,7 +116,7 @@ class EditTUIDialog(NormalTUISpoke): " it a second time to continue.")) return None if (pw != confirm): - print(PASSWORD_CONFIRM_ERROR_TUI) + print(_(PASSWORD_CONFIRM_ERROR_TUI)) return None
valid, strength, message = validatePassword(pw, user=None) diff --git a/pyanaconda/ui/tui/spokes/askvnc.py b/pyanaconda/ui/tui/spokes/askvnc.py index 5734365..d97763e 100644 --- a/pyanaconda/ui/tui/spokes/askvnc.py +++ b/pyanaconda/ui/tui/spokes/askvnc.py @@ -60,7 +60,7 @@ class AskVNCSpoke(NormalTUISpoke): "graphical installation or continue " "with a text mode installation?")
- self._choices = (USEVNC, USETEXT) + self._choices = (_(USEVNC), _(USETEXT)) self._usevnc = False
@property @@ -92,7 +92,7 @@ class AskVNCSpoke(NormalTUISpoke): else: return INPUT_PROCESSED
- if choice == USETEXT: + if choice == _(USETEXT): self._usevnc = False else: self._usevnc = True
On Tue, 2013-10-08 at 14:54 -0400, David Shea wrote:
The constants will be set before the language is selected, so only mark the strings as translatable in constants.py and translate them where they are used.
pyanaconda/constants.py | 24 ++++++++++++------------ pyanaconda/ui/gui/spokes/password.py | 16 ++++++++-------- pyanaconda/ui/gui/spokes/user.py | 16 ++++++++-------- pyanaconda/ui/tui/spokes/__init__.py | 2 +- pyanaconda/ui/tui/spokes/askvnc.py | 4 ++-- 5 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py index 13440e2..7af5014 100644 --- a/pyanaconda/constants.py +++ b/pyanaconda/constants.py @@ -19,7 +19,7 @@ # Author(s): Erik Troan ewt@redhat.com #
-from pyanaconda.i18n import _ +from pyanaconda.i18n import N_
SELINUX_DEFAULT = 1
@@ -70,8 +70,8 @@ DEFAULT_KEYBOARD = "us" DRACUT_SHUTDOWN_EJECT = "/run/initramfs/usr/lib/dracut/hooks/shutdown/99anaconda-eject.sh"
# VNC questions -USEVNC = _("Start VNC") -USETEXT = _("Use text mode") +USEVNC = N_("Start VNC") +USETEXT = N_("Use text mode")
# Runlevel files RUNLEVELS = {3: 'multi-user.target', 5: 'graphical.target'} @@ -133,12 +133,12 @@ UNSUPPORTED_HW = 1 << 28
# Password validation PASSWORD_MIN_LEN = 6 -PASSWORD_EMPTY_ERROR = _("The password is empty.") -PASSWORD_CONFIRM_ERROR_GUI = _("The passwords do not match.") -PASSWORD_CONFIRM_ERROR_TUI = _("The passwords you entered were different. Please try again.") -PASSWORD_WEAK = _("The password you have provided is weak. You will have to press Done twice to confirm it.") -PASSWORD_WEAK_WITH_ERROR = _("The password you have provided is weak: %s. You will have to press Done twice to confirm it.") -PASSWORD_WEAK_CONFIRM = _("You have provided a weak password. Press Done again to use anyway.") -PASSWORD_WEAK_CONFIRM_WITH_ERROR = _("You have provided a weak password: %s. Press Done again to use anyway.")
-PASSWORD_STRENGTH_DESC = [_("Empty"), _("Weak"), _("Fair"), _("Good"), _("Strong")] +PASSWORD_EMPTY_ERROR = N_("The password is empty.") +PASSWORD_CONFIRM_ERROR_GUI = N_("The passwords do not match.") +PASSWORD_CONFIRM_ERROR_TUI = N_("The passwords you entered were different. Please try again.") +PASSWORD_WEAK = N_("The password you have provided is weak. You will have to press Done twice to confirm it.") +PASSWORD_WEAK_WITH_ERROR = N_("The password you have provided is weak: %s. You will have to press Done twice to confirm it.") +PASSWORD_WEAK_CONFIRM = N_("You have provided a weak password. Press Done again to use anyway.") +PASSWORD_WEAK_CONFIRM_WITH_ERROR = N_("You have provided a weak password: %s. Press Done again to use anyway.")
+PASSWORD_STRENGTH_DESC = [N_("Empty"), N_("Weak"), N_("Fair"), N_("Good"), N_("Strong")] diff --git a/pyanaconda/ui/gui/spokes/password.py b/pyanaconda/ui/gui/spokes/password.py index 58e6719..703e726 100644 --- a/pyanaconda/ui/gui/spokes/password.py +++ b/pyanaconda/ui/gui/spokes/password.py @@ -148,9 +148,9 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke):
if not editable.get_text(): if editable == self.pw:
return PASSWORD_EMPTY_ERROR
return _(PASSWORD_EMPTY_ERROR) else:
return PASSWORD_CONFIRM_ERROR_GUI
return _(PASSWORD_CONFIRM_ERROR_GUI) else: return GUICheck.CHECK_OK
@@ -170,7 +170,7 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke): if (not pw and not confirm) and self._kickstarted: result = GUICheck.CHECK_OK elif confirm and (pw != confirm):
result = PASSWORD_CONFIRM_ERROR_GUI
result = _(PASSWORD_CONFIRM_ERROR_GUI) else: result = GUICheck.CHECK_OK
@@ -207,7 +207,7 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke): val = 3 else: val = 4
text = PASSWORD_STRENGTH_DESC[val]
text = _(PASSWORD_STRENGTH_DESC[val]) self.pw_bar.set_value(val) self.pw_label.set_text(text)
@@ -237,14 +237,14 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke): return GUICheck.CHECK_OK elif self._waivePasswordClicks == 1: if self._pwq_error:
return PASSWORD_WEAK_CONFIRM_WITH_ERROR % self._pwq_error
return _(PASSWORD_WEAK_CONFIRM_WITH_ERROR) % self._pwq_error else:
return PASSWORD_WEAK_CONFIRM
return _(PASSWORD_WEAK_CONFIRM) else: if self._pwq_error:
return PASSWORD_WEAK_WITH_ERROR % self._pwq_error
return _(PASSWORD_WEAK_WITH_ERROR) % self._pwq_error else:
return PASSWORD_WEAK
return _(PASSWORD_WEAK) else: return GUICheck.CHECK_OK
diff --git a/pyanaconda/ui/gui/spokes/user.py b/pyanaconda/ui/gui/spokes/user.py index b6d855b..591f65b 100644 --- a/pyanaconda/ui/gui/spokes/user.py +++ b/pyanaconda/ui/gui/spokes/user.py @@ -417,7 +417,7 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke): val = 3 else: val = 4
text = PASSWORD_STRENGTH_DESC[val]
text = _(PASSWORD_STRENGTH_DESC[val]) self.pw_bar.set_value(val) self.pw_label.set_text(text)
@@ -480,9 +480,9 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke): return GUICheck.CHECK_OK elif not editable.get_text(): if editable == self.pw:
return PASSWORD_EMPTY_ERROR
return _(PASSWORD_EMPTY_ERROR) else:
return PASSWORD_CONFIRM_ERROR_GUI
return _(PASSWORD_CONFIRM_ERROR_GUI) else: return GUICheck.CHECK_OK
@@ -499,7 +499,7 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke): if (not self.usepassword.get_active()) or self._user.password_kickstarted: result = GUICheck.CHECK_OK elif self.confirm.get_text() and (self.pw.get_text() != self.confirm.get_text()):
result = PASSWORD_CONFIRM_ERROR_GUI
result = _(PASSWORD_CONFIRM_ERROR_GUI) else: result = GUICheck.CHECK_OK
@@ -541,14 +541,14 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke): return GUICheck.CHECK_OK elif self._waivePasswordClicks == 1: if self._pwq_error:
return PASSWORD_WEAK_CONFIRM_WITH_ERROR % self._pwq_error
return _(PASSWORD_WEAK_CONFIRM_WITH_ERROR) % self._pwq_error else:
return PASSWORD_WEAK_CONFIRM
return _(PASSWORD_WEAK_CONFIRM) else: if self._pwq_error:
return PASSWORD_WEAK_WITH_ERROR % self._pwq_error
return _(PASSWORD_WEAK_WITH_ERROR) % self._pwq_error else:
return PASSWORD_WEAK
return _(PASSWORD_WEAK) else: return GUICheck.CHECK_OK
diff --git a/pyanaconda/ui/tui/spokes/__init__.py b/pyanaconda/ui/tui/spokes/__init__.py index c9c80c7..8ffe5d1 100644 --- a/pyanaconda/ui/tui/spokes/__init__.py +++ b/pyanaconda/ui/tui/spokes/__init__.py @@ -116,7 +116,7 @@ class EditTUIDialog(NormalTUISpoke): " it a second time to continue.")) return None if (pw != confirm):
print(PASSWORD_CONFIRM_ERROR_TUI)
print(_(PASSWORD_CONFIRM_ERROR_TUI)) return None valid, strength, message = validatePassword(pw, user=None)
diff --git a/pyanaconda/ui/tui/spokes/askvnc.py b/pyanaconda/ui/tui/spokes/askvnc.py index 5734365..d97763e 100644 --- a/pyanaconda/ui/tui/spokes/askvnc.py +++ b/pyanaconda/ui/tui/spokes/askvnc.py @@ -60,7 +60,7 @@ class AskVNCSpoke(NormalTUISpoke): "graphical installation or continue " "with a text mode installation?")
self._choices = (USEVNC, USETEXT)
self._choices = (_(USEVNC), _(USETEXT)) self._usevnc = False
@property
@@ -92,7 +92,7 @@ class AskVNCSpoke(NormalTUISpoke): else: return INPUT_PROCESSED
if choice == USETEXT:
if choice == _(USETEXT): self._usevnc = False else: self._usevnc = True
This looks good to me.
anaconda-patches@lists.fedorahosted.org