zotero / scaffold

Zotero translator creation IDE
http://www.zotero.org/support/dev/scaffold
38 stars 9 forks source link

Make translator tests language-independent #21

Open zuphilip opened 9 years ago

zuphilip commented 9 years ago

The tests can fail, if there is an English date saved and compared with a German date, e.g.

         -   "date": "June 1, 2014"
         +   "date": "Juni 1, 2014"

Is it possible to compare the standardized date format (i.e. 2014-06-01) instead? (see also https://github.com/zotero/translators/pull/845#discussion_r24078272 )

aurimasv commented 9 years ago

I don't think we want to compare the interpreted date, but we can make sure that only en-US is used to generate and run tests by setting the locale to en-US before running/generating tests and reverting it right after. It's not a great option, since there's always a chance that we will fail to revert the locale under some condition, but given Scaffold's target audience, it's probably not as big of an issue.

zuphilip commented 9 years ago

Are you saying that "2014-06-01" is the interpreted date? I tought that would be the internal format of dates...

aurimasv commented 9 years ago

What you see in the test is what Zotero imports. It will then attempt to interpret the date and store it internally as YYYY-MM-DD

aurimasv commented 9 years ago

Actually it will store both formats. YYYY-MM-DD is not displayed to the user, just the raw imported date is shown.

zuphilip commented 9 years ago

Hm.. I think I am missing a step. For example this happens when importing RIS:

Changing the locale preferences for testing seems to be hacky and I would rather prefer not to do that. Anyway, if it is not possible to change the comparison in the test, I can also use my Firefox English Portable Version for testing, or ask you to do the tests;-)

aurimasv commented 9 years ago

RIS translator does pretty formatting for a date, which is locale dependent, so running the test and generating the test have to be done in the same locale. I'm not really sure which part of that is not clear.

zuphilip commented 9 years ago

Okay, and why is RIS translator doing that? For example another translator is saving the date as YYYY-MM-DD: https://github.com/zotero/translators/blob/master/semantics%20Visual%20Library.js#L241 (Didn't you advice me to do it like that?)

Maybe I am wrong, but wouldn't it be better to import the date as YYYY-MM-DD whenever possible and just render it in the client in the language the user choose?

dstillman commented 9 years ago

The date field can contain anything (e.g., "Summer 2014"), so it can't be limited to that, but we could say that if there's an ISO8601 date and nothing else, it gets rendered nicely.

dstillman commented 9 years ago

(And this would address a long-standing complaint about varying date formats in the middle pane.)

aurimasv commented 9 years ago

I like that, but it may be confusing for the user when editing the field. Though I suppose it's not terribly unusual to be editing editing data in one format and have it displayed in a different format (e.g. dates in excel)

why is RIS translator doing that?

I'm not sure. That dates way way back. The formatting should really be done in Zotero UI (as Dan suggests) and the data should be stored in a structured format unless the user specifically puts something else in there. Imagine sharing an item with locale-dependent date formatting in a group. It wouldn't make sense to show a German date to someone using en-US locale.

dstillman commented 9 years ago

We could possibly use an HTML datepicker with a locale-aware free-form field, in which case we wouldn't necessarily even need to show something different when editing.