NoLiD / Disquo

Data comparator for humans.
1 stars 1 forks source link

labels of rdf types, things, and predicates should be exposed by an interface #11

Closed kdbanman closed 10 years ago

kdbanman commented 10 years ago

Having code like this in more than one place is too implementation-dependent:

var label;
if (rdfObj.labels.en !== undefined) {
    label = rdfObj.labels.en;
} else {
    label = rdfObj.labels.default;
}

I would rather see something like this across components.

var label = rdfObj.get('label');  // Option 1: getter knows preferred language

// OR

var label = rdfObject.getLabel('en');  // Option 2: getter is passed the preferred language

I'm not sure how best to make that work with language localization options in the future. This depends upon how we implement localization state, but it needs be possible to make the label getter aware of the currently preferred language.

Using an Ember.Model doesn't make sense for this, because a Model has a one-to-one relationship with controllers, routes, etc. (right?) There are reasonable options in es6 for defining our own objects/classes with dynamically computed properties.

xkb commented 10 years ago

I have been avoiding to deal with this mainly because we are still using Jassa and haven't gotten into how we're going to replace the basic functionality we use from it. There is also the question of we want to get into using Ember-Data which is nearing a stable release.

Localization state can be managed using a global or route based binding such as property in the endpoint route.

Not really sure what you mean by Ember.Model. A route's model hook is what holds current route's data and can be backed by a single or an array controller. I'll try adding an Ember friendly POJO to represent resources.

xkb commented 10 years ago

I have added a very basic model for resources that supports labels and comments. It has a binded value to the store singleton.

Only thing left is to add a some UI element that sets the language value on store and then every resource will change labels/comment automatically.