CA: Edit locale-specific date/time input formats

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
peter_b
Chatterbox
Posts: 371
Joined: Tue Nov 12, 2013 2:05 am

CA: Edit locale-specific date/time input formats

Post by peter_b »

If you want to edit/tweak the date input formats in CollectiveAccess Providence (v1.4) for different locales than the English default (e.g. German/Deutsch), then you can edit the files in: "app/lib/core/Parsers/TimeExpressionParser/"

For example, the file for German is called "app/lib/core/Parsers/TimeExpressionParser/de_DE.lang" and looks like this:

Code: Select all

# *** use ONLY lowercase letters in lists: input will be forced to lowercase for comparison ***

# List month names; used whenever name of month needs to be displayed
monthList = [januar, februar, märz, april, mai, juni, juli, august, september, oktober, november, dezember]

# *** the following list of months is for display and *SHOULD* be capitalized where appropriate
monthListDisplay = [Januar, Februar, März, April, Mai, Juni, Juli, August, September, Oktober, November, Dezember]

# Hash table mapping acceptable month names to the display names defined in 'monthList'
monthTable = {
    jan = januar, jan. = januar,
    feb = februar, feb. = februar,
    mar = märz, mar. = märz,
    apr = april, apr. = april,
    ma = mai,
    jun = juni, jun. = juni,
    jul = juli, jul. = juli,
    aug = august, aug. = august,
    sep = september, sep. = september,
    oct = oktober, oct. = oktober,
    nov = november, nov. = november,
    dec = dezember, dec. = dezember
}

# List of day names, starting with Sunday
dayListDisplay = [Sonntag, Montag, Dienstag, Mittwoch, Donnerstag, Freitag, Samstag]

rangePreConjunctions = [von, zwischen]
rangeConjunctions = [bis, -, und, ..]

dateTimeConjunctions = [um]

dateDelimiters = [/,-,.]
timeDelimiters = [:,.]

timeAMMeridian = am
timePMMeridian = pm

meridianTable = {
    a.m. = am,
    p.m. = pm
}

dateCircaIndicator = [circa, c, c., ca, ca.]
dateUncertaintyIndicator = [~]
dateUncertaintyYearIndicator = [y]
dateUncertaintyDayIndicator = [d]

# What to use to indicate a geological date ("millions of years ago")
dateMYA = [mya]

dateADIndicator = ad
dateBCIndicator = bc
ADBCTable = {
    a.d. = ad, n.chr. = ad,
    b.c. = bc, v.chr. = bc, v.u.z = bc
}

nowDate = [jetzt,now]
todayDate = [heute]
yesterdayDate = [gestern]
tomorrowDate = [morgen]
undatedDate = [undated, unknown]

presentDate = [gegenwart, ?, ??, ???, ????]
beforeQualifier = [vor]
diedQualifier = [gestorben, gest., gest, d, d.]
afterQualifier = [nach, ab, seit]
bornQualifier = [geboren, geb., geb, b, b.]

# Text to indicate century (as in "20th century")
centuryIndicator = [jahrhundert]

# Text to indicate decdae (as in "1920s")
decadeIndicator = [er]

# list of numeric suffixes, starting with the one for zero
# (eg. 0th, 1st, 2nd, 3rd would be a list like so: [th, st, nd, rd])
ordinalSuffixes = [.]
ordinalSuffixDefault = .

# in delimited dates (ex. 12/10/2009) is the first number a month or a day?
# set to "0" for European style dates (day comes first); "1" for American-style dates (month comes first)
monthComesFirstInDelimitedDate = 0

# character(s) to append to day in full (not delimited) date
# eg. in the date "1. February 2009", "." is the daySuffix
# Note: you can put arbitrary text here - only punctuation
daySuffix = .

# Definite articles
definiteArticles = [der, die, das]

# Indefinite articles
indefiniteArticles = [ein, eine, einem, einen, einer]

# Seasons
winterSeason = [winter]
springSeason = [frühling]
summerSeason = [sommer]
autumnSeason = [herbst]
As you can see, that set does not cover the Austrian month names, like "Jänner". So maybe I'll fork it as "de_AT.lang" ;)
NOTE: At the moment there seems to be an issue with month names that contain umlauts :(


Links:
User avatar
peter_b
Chatterbox
Posts: 371
Joined: Tue Nov 12, 2013 2:05 am

Re: CA: Edit locale-specific date/time input formats

Post by peter_b »

Problem with the umlauts fixed: :D
Thanks to a hint from Stefan Keidel, I replaced the "ä" in 2 variables in "app/lib/core/Parsers/TimeExpressionParser/de_DE.lang":
  • monthList:
    • monthList = [januar, februar, marz, april, mai, juni, juli, august, september, oktober, november, dezember]
  • monthTable
    • mar = marz, mar. = marz,
Now it displays properly as "dd. month yyyy", when the date field is rendered, and using "März" as input works fine as well.
Problem solved.
Post Reply