[Design] Expando Date/Time fields

Brian Kirsch bkirsch at osafoundation.org
Thu Jan 12 11:46:17 PST 2006


Hi Alec and Mike,

 >We're currently using python's string-replacement code and it works 
well. It allows you to set up a dictionary of values, and then >replace 
them "by name" in a way very tightly tied to the python language itself:
 >(I'm making up all these methods just to show a simplified example)


The other major benefit of using dictionaries is that it adds context to 
the sentence structure. This makes it easier for translators to localize 
without having to search through code to figure out what values the 
replacement variables contain.

Hard to interpret:

"on $1 at $2"

Really hard to interpret:

 "on %s at %s"

The context of the sentence fragments above is not clear.

Interpretations:

"on the stairs at the mall"
"on 12/12/05 at 10:00pm"
"on Lewers street at the corner of Pico"

Depending on the language the ordering of the replacement values may 
change based on the interpretation. For example, if the sentence is 
referring to date and time a language may reverse the replacement value 
order so that time comes before date. But if the sentence is referring 
to a street location the language may keep the current replacement value 
order.

Using dictionaries with appropriate key names adds this missing context.

"on %{time}s at %{date}s"


-Brian

 

Brian Kirsch - Email Framework Engineer
Open Source Applications Foundation
543 Howard St. 5th Floor
San Francisco, CA 94105
(415) 946-3056
http://www.osafoundation.org



Alec Flett wrote:

> Mike Carroll wrote:
>
>> The @nn construct signals a hole in the message.  The "nn" value 
>> identifies which of the arguments to MakeMessage should be placed in 
>> the hole.  This allows the message text to be changed without 
>> changing the function call.  (Our testing requirements were much less 
>> strict for message changes than code changes.)
>>
> We're currently using python's string-replacement code and it works 
> well. It allows you to set up a dictionary of values, and then replace 
> them "by name" in a way very tightly tied to the python language itself:
> (I'm making up all these methods just to show a simplified example)
>
> dateStrings = { 'time': time.timestring(), 'date': time.datestring() }
> DisplaySomeDate(_(u'The meeting starts at %{time}s on %{date}s') % 
> dateStrings)
>
> The use of a python dictionary actually buys us quite a bit, because 
> we can keep reusing the dictionary for different strings, and the 
> localizers can pick and choose which segments of the date/time to use 
> where.
>
> For instance in mimi's example:
> dateStrings = { 'time1': time1.timestring(), 'date1': 
> time1.datestring(), 'day': time1.dayName(), ....
>                 'time1': time2.timestring(), 'date1': 
> time2.datestring(), 'day': time2.dayName(), .... }
>
> if date1.date() == date2.date():
>    dateFirstLine = _(u'%{day1}s  %{longDate1}s') % dateStrings
>    dateSecondLine = _(u'%{time1}s to %{time2}s %{timezone1}s') % 
> dateStrings
> else:
>    dateFirstLine = ...
>
> You get the idea.
>
> Alec
>
>> For example, you could change the skeleton to "@02 on @01" and get 
>> the time first then the date.
>>
>> I assume there's something like that in the "modern" programming 
>> world (we had to write our own).
>>
>> We didn't accept date/time combos as input to anything and so never 
>> had to solve that parsing problem.
>>
>> My US$0.02.
>>
>> ++hobbitt
>>
>> ----------
>> Mike Carroll, Pete Townsend, Washington USA
>> http://www.druidlabs.com
>> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>>
>> Open Source Applications Foundation "Design" mailing list
>> http://lists.osafoundation.org/mailman/listinfo/design
>
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> Open Source Applications Foundation "Design" mailing list
> http://lists.osafoundation.org/mailman/listinfo/design



More information about the Design mailing list