[dojo-contributors] Dojo data discussion

Brian Douglas Skinner skinner at dojotoolkit.org
Thu Jun 7 18:36:11 EDT 2007

Adam L. Peller wrote:
> I see your point, but is it really common to wrap localization in 
> the schema? If so, and you want to encapsulate this in your data 
> store, you could just query dojo.i18n.normalizeLocale() to get the 
> user's locale, and you could optionally pass a locale (or any other 
> implementation-specific data) in with the data store object's 
> constructor. I wouldn't try to fold this into the dojo.data APIs.

Just to be clear: I am *not* advocating that we have methods in the the 
dojo.data APIs for setting locale, or passing in locale info -- if 
that's what you mean when you say "fold this into the dojo.data APIs".

I'm suggesting that we leave the dojo.data APIs just as they are, with 
no mention of locale at all.

> So yeah, the database design I had in mind might be defined to 
> return some token to make localization more explicit, e.g.
> { id: 'facility123', country: 'countryDE'}
> and then your UI code would delegate by doing the look up in a
> localization table -- another database, or perhaps a json resource
> designed for your locale (the latter is how Dojo does localization 
> -- only your language comes over the wire).  

Hmmm, I don't see how the UI code could reliably do string conversion 
without knowing about the semantics of the data items...

For example, let's say you have an astronomy database, with info about 
planets.  It has an item representing Pluto, with attributes like mass, 
volume, oblateness, etc.  For the name attribute, the database may know 
the name in a variety of languages: "Pluto" in English, "Pluton" in 
French, "Plutone" in Italian, etc.  Or the database itself may not know 
all the names, but the datastore implementation may know where to look 
up those string translations.

You could also have a journalism database, with info about newspaper and 
journalists.  One of the items in that database might represent the 
sportswriter Terry Pluto.  In this case Terry's name is always "Pluto", 
in English or French or Italian.

If you've got an item x, and the datastore getLabel(x) method returns 
"Pluto", there's no reliable way for the UI code to translate that 
without knowledge about the semantics of the data.  I think that 
generally speaking, knowledge about the semantics of the data should 
live in the datastore and the database, rather than in the widgets.  I 
don't think the ComboBox should ever try to do any translation -- it 
should just call getLabel(x) and then display whatever string is returned.

:o) Brian

More information about the dojo-contributors mailing list