[r21694]GrampsLocale: Use glocale.lang or glocale.language[0]

To get the default localization instead of locale.getlocale() or
glocale.get_translation().language().

svn: r21698
This commit is contained in:
John Ralls 2013-03-19 18:34:11 +00:00
parent 38cc711bde
commit 1f38fd43f5
5 changed files with 8 additions and 16 deletions

View File

@ -1794,7 +1794,7 @@ def get_relationship_calculator(reinit=False):
global __RELCALC_CLASS
if __RELCALC_CLASS is None or reinit:
lang = glocale.get_translation().language()
lang = glocale.language[0]
__RELCALC_CLASS = RelationshipCalculator
# If lang not set default to English relationship calulator
# See if lang begins with en_, English_ or english_

View File

@ -40,7 +40,7 @@ MANUALS = {
}
#first, determine language code, so nl_BE --> wiki /nl
lang = glocale.get_translation().language()
lang = glocale.language[0]
if lang in MANUALS:
EXTENSION = MANUALS[lang]
else:

View File

@ -337,7 +337,7 @@ class GedcomWriter(UpdateCallback):
# write the language string if the current LANG variable
# matches something we know about.
lang = os.getenv('LANG')
lang = glocale.language[0]
if lang and len(lang) >= 2:
lang_code = LANGUAGES.get(lang[0:2])
if lang_code:

View File

@ -34,7 +34,6 @@ from __future__ import print_function
# Python modules
#------------------------------------------------------------------------
import re
import locale
from gramps.gen.constfunc import STRTYPE, cuni
"""
@ -51,7 +50,7 @@ __all__ = ['Html']
# GRAMPS modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
#------------------------------------------------------------------------
#
# Constants
@ -581,11 +580,7 @@ class Html(list):
#
#------------------------------------------------------------------------
def xml_lang():
loc = locale.getlocale()
if loc[0] is None:
return ""
else:
return loc[0].replace('_', '-')
return glocale.lang[:5].replace('_', '-')
#-------------------------------------------
#

View File

@ -32,11 +32,8 @@ Can use the Webkit or Gecko ( Mozilla ) library
# Python modules
#
#-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.get_translation().gettext
import os
import sys
import locale
if sys.version_info[0] < 3:
from urlparse import urlunsplit
else:
@ -68,6 +65,8 @@ from gramps.gen.utils.file import get_empty_tempdir
from gramps.gen.constfunc import lin, mac, win
from gramps.gen.config import config
from gramps.gen.const import TEMP_DIR
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.get_translation().gettext
#-------------------------------------------------------------------------
#
@ -84,9 +83,7 @@ def get_identity():
platform = "Macintosh"
else:
platform = "Unknown"
(lang_country, modifier ) = locale.getlocale()
lang = lang_country.replace('_','-')
#lang += ", " + lang_country.split('_')[0]
lang = glocale.lang[:5].replace('_','-')
return "Mozilla/5.0 (%s; U; %s) Gramps/3.2" % ( platform, lang)
#-------------------------------------------------------------------------