Skip to content
Snippets Groups Projects
Commit b71ab506 authored by Helena Jank's avatar Helena Jank
Browse files

# enabled translation to add matching synonyms to a given attribute

parent 39c3c62b
No related branches found
No related tags found
No related merge requests found
......@@ -529,7 +529,7 @@ define(['MathUuid', 'widget', 'attribute', 'attributeList', 'subscriber', 'subsc
for (var translationIndex in allTranslations) {
var translation = allTranslations[translationIndex];
if (translation.isTranslation(theInAttribute)) {
theInAttribute = translation.getOrigin();
theInAttribute = translation.translate(theInAttribute);
console.log("This attribute seems to be a translation. One possible synonym is "+theInAttribute+".")
break;
}
......
......@@ -217,8 +217,7 @@ define(['attributeList', 'attribute', 'parameter', 'widget', 'interpreter', 'agg
}
for (var index in this._translations) {
var translation = this._translations[index];
if (translation.translates(newAttribute))
newAttribute = newAttribute.withSynonym(translation.getSynonym());
newAttribute = translation.translate(newAttribute);
}
return newAttribute;
};
......
......@@ -59,7 +59,7 @@ define('translation', ['attribute'], function(Attribute) {
* @param {Attribute} attribute Attribute whose synonym is queried
* @returns {boolean}
*/
Translation.prototype.translates = function(attribute) {
Translation.prototype.hasTranslation = function(attribute) {
return this._fromAttribute.equalsTypeOf(attribute);
};
......@@ -73,6 +73,24 @@ define('translation', ['attribute'], function(Attribute) {
return this._toAttribute.equalsTypeOf(attribute);
};
/**
* Look for a translation result and return true if one exists.
*
* @param {Attribute} attribute Attribute whose synonym is queried
* @returns {Attribute}
*/
Translation.prototype.translate = function(attribute) {
if (this.hasTranslation(attribute)) {
return attribute.withSynonym(this._toAttribute);
}
else if (this.isTranslation(attribute)) {
return attribute.withSynonym(this._fromAttribute);
}
else {
return attribute;
}
};
return Translation;
})();
});
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment