Bug 509424

Summary: Switch to using python's gettext module
Product: [Fedora] Fedora Reporter: Jeremy Katz <katzj>
Component: revisorAssignee: Jeroen van Meeuwen <vanmeeuwen+fedora>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: jonathansteffan, vanmeeuwen+fedora
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-09-07 22:30:43 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 508951    
Attachments:
Description Flags
switch to gettext directly none

Description Jeremy Katz 2009-07-02 17:48:56 UTC
We're hoping to kill of rhpl for Fedora 12.  The attached (untested -- my box at the office that has bandwidth and disk space is acting up and I'm not in the office still for ~ a week) patch switches revisor to use python's gettext module directly instead of rhpl.translate.  It's a pretty mechanical change. 

revisor will still depend on rhpl for keyboard stuff after this, but clumens and I are going to sit down and figure out the best way to kill that off after the holiday as there are about 4 or 5 packages in that position

Comment 1 Jeremy Katz 2009-07-02 17:50:22 UTC
Created attachment 350318 [details]
switch to gettext directly

Comment 2 Jonathan Steffan 2009-07-04 20:14:22 UTC
revisor/modgui/package_selection.py:from rhpl.translate import getDefaultLangs
revisor/modgui/lm_basic.py:from rhpl import keyboard_models
revisor/modgui/lm_basic.py:import rhpl.keyboard as keyboard

This is all that is left. Please let us know what the solution for removing this is.

Comment 3 Jeremy Katz 2009-07-27 13:34:07 UTC
For the keyboard stuff, system-config-keyboard >= 1.3.0 has the same files if you do
   import system_config_keyboard.keyboard as keyboard
   import system_config_keyboard.keyboard_models as keyboard_models
If you want to keep compat between releases, you can wrap that in a try/except ImportError piece and fall back to importing rhpl

For getDefaultLangs(), you can either require anaconda and use anaconda's implementation of the comps sorting or you also need to pull in your own version of the method (below from anaconda)

def _getDefaultLangs():
    languages = []
    for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'):
        val = os.environ.get(envar)
        if val:
            languages = val.split(':')
            break
    if 'C' not in languages:
        languages.append('C')

    # now normalize and expand the languages
    nelangs = []
    for lang in languages:
        for nelang in gettext._expand_lang(lang):
            if nelang not in nelangs:
                nelangs.append(nelang)
    return nelangs

Comment 4 Jonathan Steffan 2009-09-07 22:30:43 UTC
Finalized in a4e103b943bd19dda2627114644a2e4a5f225554