Bug 9159: Date format does not match system.
Make US English a special-case locale with en_GB the default if the locale is en_XX where XX != US. Note that untranslated languages will still end up using the 'C' locale.
This commit is contained in:
parent
36da63b33e
commit
54e8ea0e39
@ -120,6 +120,10 @@ def _check_mswin_locale(locale):
|
||||
msloc = _LOCALE_NAMES[locale[:2]][:2]
|
||||
locale = locale[:2]
|
||||
except KeyError:
|
||||
#US English is the outlier, all other English locales want
|
||||
#real English:
|
||||
if locale[:2] == ('en') and locale[:5] != 'en_US':
|
||||
return ('en_GB', '1252')
|
||||
return (None, None)
|
||||
return (locale, msloc)
|
||||
|
||||
@ -127,7 +131,9 @@ def _check_mswin_locale_reverse(locale):
|
||||
for (loc, msloc) in _LOCALE_NAMES.items():
|
||||
if msloc and locale == msloc[0]:
|
||||
return (loc, msloc[1])
|
||||
|
||||
#US English is the outlier, all other English locales want real English:
|
||||
if locale.startswith('English') and locale != 'English_United States':
|
||||
return ('en_GB', '1252')
|
||||
return (None, None)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@ -284,6 +290,8 @@ class GrampsLocale(object):
|
||||
if not locale[0]:
|
||||
return False
|
||||
lang = self.check_available_translations(locale[0])
|
||||
if not lang and locale[0].startswith('en'):
|
||||
locale[0] = lang = 'en_GB'
|
||||
if not lang:
|
||||
return False
|
||||
self.lang = locale[0]
|
||||
@ -795,9 +803,11 @@ class GrampsLocale(object):
|
||||
|
||||
if locale[:5] in self.languages:
|
||||
return locale[:5]
|
||||
#US English is the outlier, all other English locales want real English:
|
||||
if locale[:2] == 'en' and locale[:5] != 'en_US':
|
||||
return 'en_GB'
|
||||
if locale[:2] in self.languages:
|
||||
return locale[:2]
|
||||
|
||||
return None
|
||||
|
||||
def get_language_dict(self):
|
||||
@ -969,8 +979,8 @@ class Lexeme(str):
|
||||
Prints out::
|
||||
|
||||
In English locale:
|
||||
CHRISTMAS
|
||||
Christmas is celebrated in December
|
||||
CHRISTMAS
|
||||
Christmas is celebrated in December
|
||||
Merry Christmas!
|
||||
|
||||
In Russian locale:
|
||||
@ -984,17 +994,17 @@ class Lexeme(str):
|
||||
These forms are accessible under dictionary keys for each form.
|
||||
The names of the forms are language-specific. They are assigned
|
||||
by the human translator of the corresponding language (in XX.po)
|
||||
as in the example above,
|
||||
see :meth:`~GrampsTranslations.lexgettext` docs
|
||||
as in the example above,
|
||||
see :meth:`~GrampsTranslations.lexgettext` docs
|
||||
for more info.
|
||||
|
||||
The translated format string can then refer to a specific form
|
||||
of the lexeme using ``.``:attr:`~Lexeme.f` and square brackets:
|
||||
of the lexeme using ``.``:attr:`~Lexeme.f` and square brackets:
|
||||
``{holiday.f[GENITIVE]}``
|
||||
expects holiday to be a Lexeme which has a form ``'GENITIVE'`` in it.
|
||||
|
||||
An instance of Lexeme can also be used as a regular unicode string.
|
||||
In this case, the work will be delegated to the string for the very
|
||||
In this case, the work will be delegated to the string for the very
|
||||
first form provided in the translated string. In the example above,
|
||||
``{holiday}`` in the translated string will expand to the Russian
|
||||
nominative form for Christmas, and ``xmas.upper()`` will produce
|
||||
@ -1002,9 +1012,9 @@ class Lexeme(str):
|
||||
|
||||
.. rubric:: Motivation
|
||||
|
||||
Lexeme is the term used in linguistics for the set of forms taken
|
||||
Lexeme is the term used in linguistics for the set of forms taken
|
||||
by a particular word, e.g. cases for a noun or tenses for a verb.
|
||||
|
||||
|
||||
Gramps often needs to compose sentences from several blocks of
|
||||
text and single words, often by using python string formatting.
|
||||
|
||||
@ -1017,7 +1027,7 @@ class Lexeme(str):
|
||||
enddate_month = m2,
|
||||
enddate_year = y2)
|
||||
|
||||
To make such text translatable, the arguments injected into
|
||||
To make such text translatable, the arguments injected into
|
||||
format string need to bear all the linguistical information
|
||||
on how to plug them into a sentence, i.e., the forms, depending
|
||||
on the linguistic context of where the argument appears.
|
||||
@ -1026,8 +1036,8 @@ class Lexeme(str):
|
||||
|
||||
On the other hand, for languages where there is no linguistic
|
||||
variation in such sentences, the code needs not to be aware of
|
||||
the underlying :class:`~Lexeme` complexity;
|
||||
and so they can be processed just like simple strings
|
||||
the underlying :class:`~Lexeme` complexity;
|
||||
and so they can be processed just like simple strings
|
||||
both when passed around in the code and when formatted.
|
||||
"""
|
||||
|
||||
@ -1037,7 +1047,7 @@ class Lexeme(str):
|
||||
else:
|
||||
od = collections.OrderedDict(iterable)
|
||||
l = list(od.values()) or [""]
|
||||
newobj = str.__new__(cls, l[0], *args, **kwargs)
|
||||
newobj = str.__new__(cls, l[0], *args, **kwargs)
|
||||
newobj._forms = od
|
||||
return newobj
|
||||
|
||||
@ -1045,7 +1055,7 @@ class Lexeme(str):
|
||||
"""All lexeme forms, in the same order as given upon construction.
|
||||
The first one returned is the default form, which is used when the
|
||||
Lexeme instance is used in lieu of a string object.
|
||||
|
||||
|
||||
Same as ``f.values()``"""
|
||||
return self._forms.values()
|
||||
|
||||
@ -1126,7 +1136,7 @@ class GrampsTranslations(gettext.GNUTranslations):
|
||||
stripping the '|'-separated context using :meth:`~sgettext`
|
||||
|
||||
The *resulting* message provided by the translator
|
||||
is supposed to be '|'-separated as well.
|
||||
is supposed to be '|'-separated as well.
|
||||
The possible formats are either (1) a single string
|
||||
for a language with no inflections, or (2) a list of
|
||||
<inflection name>=<inflected form>, separated with '|'.
|
||||
|
Loading…
Reference in New Issue
Block a user