Test date handlers

From Gramps
Jump to: navigation, search

See date handler for new method on master (trunk).

List of date handlers is available.

Date object into Gramps

Dates in Gramps are much more complex than just a month, day, and year. Dates are always in a particular calendar, can span a time frame, can be approximate, and have support for many other subtleties specific to genealogy data.

Lexeme inflections

A lexeme:

  1. (linguistics) Roughly, the set of inflected forms taken by a single word, such as the lexeme RUN including as members "run" (lemma), "running" (inflected form), or "ran", and excluding "runner" (derived term).
  2. (computing) an individual instance of a continuous character sequence without spaces, used in lexical analysis (token)
source : https://en.wiktionary.org/wiki/lexeme

Types of inflections

{n: nominative}
{g: genitive}
{d: dative}

The nominative cases are found in Estonian, Slovak, Ukrainian, Hungarian, Lithuanian, Georgian, German, Latin, Greek, Icelandic, Old English, Old French, Polish, Serbian, Czech, Romanian, Russian, and Pashto, among other languages.

Many languages have a genitive case, including Albanian, Arabic, Armenian, Basque, Dutch, Estonian, Finnish, Georgian, German, Greek, Icelandic, Irish, Latin, Latvian, Lithuanian, Romanian, Sanskrit, Scottish Gaelic, Turkish and all Slavic languages except Bulgarian and Macedonian.

The dative was common among early Indo-European languages and has survived to the present in the Balto-Slavic branch and the Germanic branch, among others. It also exists in similar forms in several non-Indo-European languages, such as the Uralic family of languages, and Altaic languages.

Examples

#: ../gramps/gen/datehandler/_datestrings.py:70
msgid "localized lexeme inflections||May"
msgstr "И=май|Р=мая|Т=маем|П=мае"

How it is used by Gramps

Gramps extracts all inflections of the same lexeme, stripping the ‘|’, like for context.

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 ‘|’.

For example:

  1. “Uninflectable”
  2. “n=Inflected-nominative|g=Inflected-genitive|d=Inflected-dative”
See lexgettext for more details.

Keys into translation strings

Related to month inflections

#. If there is no special inflection for "from <Month>" in your
#. language, don't translate this string.
#. Otherwise, translate it to the ENGLISH!!! ENGLISH!!!
#. key appearing above in the FORMATS_... dict
#. that maps to the special inflected format string that you need to localize.
#: ../gramps/gen/datehandler/_datedisplay.py:340
msgid "from-date|"
msgstr ""
#. If there is no special inflection for "and <Month>" in your
#. language, don't translate this string.
#. Otherwise, translate it to the ENGLISH!!! ENGLISH!!!
#. key appearing above in the FORMATS_... dict
#. that maps to the special inflected format string that you need to localize.
#: ../gramps/gen/datehandler/_datedisplay.py:369
msgid "and-date|"
msgstr ""
#. If there is no special inflection for "before/after/around <Month>" in your
#. language, don't translate this string.
#. Otherwise, translate it to the ENGLISH!!! ENGLISH!!!
#. key appearing above in the FORMATS_... dict
#. that maps to the special inflected format string that you need to localize.
#. TODO are there languages for which the inflections for the different
#. modifiers are different?!
#: ../gramps/gen/datehandler/_datedisplay.py:386
msgid "before-date|"
msgstr ""

date on context is maybe confusing? What about: from-month|, and-month|, before-month|?

#. TRANSLATORS: see
#. http://gramps-project.org/wiki/index.php?title=Translating_Gramps#Translating_dates
#. to learn how to select proper inflection for your language.
#: ../gramps/gen/datehandler/_datedisplay.py:450
msgid "{long_month} {day:d}, {year}"
msgstr ""
#. TRANSLATORS: see
#. http://gramps-project.org/wiki/index.php?title=Translating_Gramps#Translating_dates
#. to learn how to select proper inflection for your language.
#: ../gramps/gen/datehandler/_datedisplay.py:465
msgid "{short_month} {day:d}, {year}"
msgstr ""
#. TRANSLATORS: see
#. http://gramps-project.org/wiki/index.php?title=Translating_Gramps#Translating_dates
#. to learn how to select proper inflection for your language.
#: ../gramps/gen/datehandler/_datedisplay.py:480
msgid "{day:d} {long_month} {year}"
msgstr ""
#. TRANSLATORS: see
#. http://gramps-project.org/wiki/index.php?title=Translating_Gramps#Translating_dates
#. to learn how to select proper inflection for your language.
#: ../gramps/gen/datehandler/_datedisplay.py:496
msgid "{day:d} {short_month} {year}"
msgstr ""

Need new rules for supporting this type of key format into po/check_po script.

Specific mapping

#: ../gramps/gen/datehandler/_datedisplay.py:349
msgid "{date_quality}from {date_start} to {date_stop}{nonstd_calendar_and_ny}"
msgstr ""
return _("{date_quality}from {date_start} to {date_stop}"
                   "{nonstd_calendar_and_ny}").format(
                   date_quality=qual_str, 
                   date_start=d1, 
                   date_stop=d2, 
                   nonstd_calendar_and_ny=scal)

Why to use such a code, there? Same question for:

#: ../gramps/gen/datehandler/_datedisplay.py:371
msgid ""
"{date_quality}between {date_start} and {date_stop}{nonstd_calendar_and_ny}"
msgstr ""
#: ../gramps/gen/datehandler/_datedisplay.py:388
msgid "{date_quality}{noncompound_modifier}{date}{nonstd_calendar_and_ny}"
msgstr ""

Migrations and refactorings

> $ PYTHONPATH=/usr/local/lib/python2.7/site-packages/ GRAMPS_RESOURCES=$PWD LANGUAGE=de
python -m gramps.gen.datehandler._datestrings

LC_TIME={lang_region}.utf8 or LANGUAGE={lang} should match all available date handlers.

See # 6926 for patches. Git => revision 918785..

TO_CHECK

>$ PYTHONPATH=/usr/local/lib/python2.7/site-packages/ LC_ALL=en_GB.utf8 LANG=en_GB.utf8 
GRAMPS_RESOURCES=$PWD python -m unittest discover -p 'date*test.py'
locale score date formats MAX: 8
ar 6
bg 6
ca 6
cs 6
da 6
de Ran 59 tests in 7.665s (using the fallback 'C' locale) 6
en Ran 59 tests in 7.558s (using the fallback 'C' locale) 6
el 5
es 6
fi 2
fr Ran 59 tests in 9.007s (skipped=1) 8
hr Ran 59 tests in 7.771s (using the fallback 'C' locale) 6
it 6
lt 3
nb 6
nl 6
nn 6
ru Ran 59 tests in 7.646s (using the fallback 'C' locale) 6
pl 6
pt 6
sk 6
sl 4
sr 5
sv Ran 59 tests in 7.662s (using the fallback 'C' locale) 6
uk 6
.. .. ..
> $ PYTHONPATH=/usr/local/lib/python2.7/site-packages/  
GRAMPS_RESOURCES=$PWD python -m gramps.gen.datehandler.__init__

See also