Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 637082 Details for
Bug 866730
invalid locales configured for some languages
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Patch for LocaleInfo.__repr__
0001-Handle-locale-s-encoding-and-script-in-a-better-way.patch (text/plain), 3.98 KB, created by
Vratislav Podzimek
on 2012-11-02 13:53:24 UTC
(
hide
)
Description:
Patch for LocaleInfo.__repr__
Filename:
MIME Type:
Creator:
Vratislav Podzimek
Created:
2012-11-02 13:53:24 UTC
Size:
3.98 KB
patch
obsolete
>From 3c019340e3c3cbb3916b4a4d10bcf4577535005a Mon Sep 17 00:00:00 2001 >From: Vratislav Podzimek <vpodzime@redhat.com> >Date: Fri, 2 Nov 2012 13:55:38 +0100 >Subject: [PATCH] Handle locale's encoding and script in a better way > >Encoding should go between _territory and @script. Script is not parsed >by babel.Locale.parse. > >Related: rhbz#866730 >--- > pyanaconda/localization.py | 63 +++++++++++++++++++++++++++++++++++++++------- > 1 file changed, 54 insertions(+), 9 deletions(-) > >diff --git a/pyanaconda/localization.py b/pyanaconda/localization.py >index c343888..0495411 100644 >--- a/pyanaconda/localization.py >+++ b/pyanaconda/localization.py >@@ -40,8 +40,15 @@ class LocalizationConfigError(Exception): > > class LocaleInfo(object): > >- def __init__(self, localedata): >+ def __init__(self, localedata, encoding=""): >+ """ >+ @param encoding: encoding from the locale specification, e.g. UTF-8 >+ (localedata object has no attribute for that) >+ >+ """ >+ > self._localedata = localedata >+ self._encoding = encoding or "UTF-8" > > @property > def language(self): >@@ -60,6 +67,10 @@ class LocaleInfo(object): > return self._localedata.variant > > @property >+ def encoding(self): >+ return self._encoding >+ >+ @property > def english_name(self): > return self._localedata.english_name or u'' > >@@ -79,17 +90,14 @@ class LocaleInfo(object): > formatstr = '{0.language}' > if self.territory is not None: > formatstr += '_{0.territory}' >+ if self.encoding: >+ formatstr += '.{0.encoding}' > if self.script is not None: > formatstr += '@{0.script}' > if self.variant is not None: > formatstr += '#{0.variant}' > >- langcode = formatstr.format(self) >- if "." not in langcode: >- # add enconding suffix >- langcode = langcode + ".UTF-8" >- >- return langcode >+ return formatstr.format(self) > > def __str__(self): > return self.english_name.encode('ascii', 'replace') >@@ -141,10 +149,15 @@ def get_all_locales(): > for localename in sorted(babel.localedata.list()): > try: > localedata = babel.Locale.parse(localename) >+ # BUG: babel.Locale.parse does not parse @script >+ script = _get_locale_script(localename) >+ if script: >+ localedata.script(script) > except babel.core.UnknownLocaleError: > continue > >- locale = LocaleInfo(localedata) >+ encoding = _get_locale_encoding(localename) >+ locale = LocaleInfo(localedata, encoding) > if repr(locale) not in localeset: > localeset.add(repr(locale)) > yield locale >@@ -168,7 +181,15 @@ def get_available_translations(domain=None, localedir=None): > except babel.core.UnknownLocaleError: > continue > >- yield LocaleInfo(localedata) >+ encoding = _get_locale_encoding(langcode) >+ localedata = LocaleInfo(localedata, encoding) >+ >+ # BUG: babel.Locale.parse does not parse @script >+ script = _get_locale_script(langcode) >+ if script: >+ localedata.script(script) >+ >+ yield localedata > > def expand_langs(astring): > """ >@@ -220,6 +241,30 @@ def expand_langs(astring): > > return list(langs) > >+def _get_locale_encoding(locale): >+ """ >+ If locale specification includes encoding (e.g. cs_CZ.UTF-8) returns >+ the encoding. Otherwise returns "". >+ >+ """ >+ >+ if "@" in locale: >+ # remove @script suffix >+ locale = locale.split("@", -1)[0] >+ >+ if "." in locale: >+ return locale.split(".", -1)[1] >+ else: >+ return "" >+ >+def _get_locale_script(locale): >+ """Same as _get_locale_encoding but with the script.""" >+ >+ if "@" in locale: >+ return locale.split("@", -1)[1] >+ else: >+ return "" >+ > def write_language_configuration(lang, root): > """ > Write language configuration to the $root/etc/sysconfig/i18n and the >-- >1.7.11.7 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 866730
:
629895
|
630267
|
630273
|
632405
|
632419
|
635283
|
635315
|
635331
|
636385
|
637082
|
637222
|
637237
|
637385