musicbrainz/picard — pull request #359 by zas (2014-09-19 07:35:33+00:00)
Title: Picard-633: rework aliases selection for translation of artist's name

See discussion starting at http://chatlogs.musicbrainz.org/musicbrainz-devel/2014/2014-09/2014-09-18.html#T20-39-39-835764

http://tickets.musicbrainz.org/browse/PICARD-633
http://tickets.musicbrainz.org/browse/PICARD-200
http://tickets.musicbrainz.org/browse/PICARD-17

Basically, we only consider aliases with the Primary flag set.
Then order of preference is:
- alias with exact same locale (than the user chosen locale)
- alias with same language
Artist name alias is preferred over Legal Name alias (which can be set primary too), if both exists for the same locale.

The fallback on translate_from_sortname() can have undesired results imho.

Tests were added (test_mbxml.py) to cover almost all cases.