[PATCH 4/4] Translate layout and switching options descriptions on the fly
Vratislav Podzimek
vpodzime at redhat.com
Fri Sep 13 12:02:06 UTC 2013
On Fri, 2013-09-13 at 12:59 +0200, Vratislav Podzimek wrote:
> Creating a new instance of the XklWrapper is quite an expensive action as it
> reads and processes a lot of data and creates a lot of internal structure. So
> instead of creating new instance the get fresh translations on language change,
> it's better to translate strings on the fly if they are requested.
>
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
> pyanaconda/keyboard.py | 19 +++++++++++--------
> 1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/pyanaconda/keyboard.py b/pyanaconda/keyboard.py
> index 1f6cb5a..945c52b 100644
> --- a/pyanaconda/keyboard.py
> +++ b/pyanaconda/keyboard.py
> @@ -37,6 +37,7 @@ import os
> import re
> import shutil
> import ctypes
> +import gettext
>
> from collections import namedtuple
>
> @@ -64,6 +65,9 @@ LAYOUT_VARIANT_RE = re.compile(r'^\s*(\w+)\s*' # layout plus
> # namedtuple for information about a keyboard layout (its language and description)
> LayoutInfo = namedtuple("LayoutInfo", ["lang", "desc"])
>
> +Xkb_ = lambda x: gettext.ldgettext("xkeyboard-config", x)
> +iso_ = lambda x: gettext.ldgettext("iso_639", x)
> +
> class KeyboardConfigError(Exception):
> """Exception class for keyboard configuration related problems"""
>
> @@ -363,13 +367,8 @@ class XklWrapper(object):
>
> @staticmethod
> def get_instance():
> - # If the language has changed, we need to grab new strings
> - if os.environ["LANG"] != XklWrapper._instance_lang:
The _instance_lang class attribute should be removed completely from the
class. Fixed locally.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list