Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add preset aliases property [WIP, Feedback required] #6412

Closed
wants to merge 4 commits into from

Conversation

westnordost
Copy link
Contributor

@westnordost westnordost commented May 22, 2019

Implementation for #6139

Work in progress. Basically done except for the UI.

There are a few basic questions that need to be cleared before I can continue with the implementation:

  1. extending Transifex name key with extended descriptions for translators okay? @1ec5 had some comments on that
  2. refactor of presetCollection.search to return a list of matches instead of simply the presets okay? This has some more implications for the UI code because the UI that works with the results of this function needs to be refactored to be able to display these (alongside "raw" presets, recents, categories, ...). Advice how to do that is very welcome.
  3. reconsider convert terms back to array on transifex import [Suggestion] #6298 in the frame of this PR? It is now a bit inconsistent that aliases are a string array while terms is a comma separated string.

More detailed comments in the code.

}
preset.terms = '<translate with synonyms or related terms for \'' + preset.name + '\', separated by commas>';
preset.terms = '<>';
} else {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ....# stuff is the description that is shown in Transifex as "Developer Notes".

The description for name mentions the possibility to add aliases after the name.
The description for terms now also mentions what they are used for and how to explicitly omit them. The previous message directly in the translation was sometimes misunderstood by translators so that they literally translated the English terms.

cc @1ec5

preset.name = names[0];
if(names.length > 1) preset.aliases = names.slice(1);
// terms stay Transifex'ied (comma separated string)
if(transifex.terms.length) preset.terms = transifex.terms;
Copy link
Contributor Author

@westnordost westnordost May 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#6298

The ifs are not necessary but keep unnecessary terms: "" and aliases: [] out of en.json.

return r;
}).sort(sortMatches);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides making this filter + map + sort more concise in the code below, this is also a performance improvement: Presets that are added to the results are not searched again.

if (value === aCompare) return -1;
if (value === bCompare) return 1;

// priority for smaller edit distance
var i = a.fuzziness - b.fuzziness;
if (i !== 0) return i;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this since it is now easy to get this information

return { preset: a, tagValue: tagValue };
}
}
});
Copy link
Contributor Author

@westnordost westnordost May 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both tagValue and term could as well be just booleans isTagMatch, isTermMatch or similar or as well be left out completely because it is currently not used in the UI besides sorting (which did not happen before). It is simply "free" to record this info at this point and could be used in the UI to display term-matches differently.

if (dist + Math.min(value.length - a.originalName.length, 0) < 1) {
return { preset: a, fuzziness: dist };
}
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fuzziness is used for sorting and could be used (in the future) to display those items differently.

} else {
geometry.forEach(function(geom) {
results.push(presets.fallback(geom));
results.push({ preset: presets.fallback(geom) });
});
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: If the desired geometry is already passed in this function as a parameter, why is the whole collection not filtered to only return presets that can be used with this geometry? Is this is a bug?

@westnordost westnordost changed the title Aliases [WIP, Feedback required] Add preset aliases property [WIP, Feedback required] May 22, 2019
@quincylvania
Copy link
Collaborator

@westnordost I've been thinking about this a lot in light of recent events, and unfortunately came to the conclusion that we should put features like this and #6137 on hold.

iD's interpretation of tagging via its presets is a continuous source of conflict that has grated on the project. We've started to think of ways to separate OSM tagging from iD (like #6483), and until then I'd rather not make any major preset changes.

Sorry for all the work you put into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants