(literalEntities, prefLanguage="en")
return match
from a list of literals, returns the one in prefLanguage
    if no language specification is available, return first element
from a list of literals, returns the one in prefLanguage
    if no language specification is available, return first element
from a list of literals returns the one in prefLanguage if no language specification is available return first element
def firstStringInList(literalEntities, prefLanguage="en"):
    """
    from a list of literals, returns the one in prefLanguage
    if no language specification is available, return first element
    """
    match = ""

    if len(literalEntities) == 1:
        match = literalEntities[0]
    elif len(literalEntities) > 1:
        for x in literalEntities:
            if getattr(x, 'language') and getattr(x,
                                                  'language') == prefLanguage:
                match = x
        if not match:  # don't bother about language
            match = literalEntities[0]
    return match
def firstStringInList ( literalEntities , prefLanguage = "en" ) : match = "" if len ( literalEntities ) == 1 : match = literalEntities [ 0 ] elif len ( literalEntities ) > 1 : for x in literalEntities : if getattr ( x , 'language' ) and getattr ( x , 'language' ) == prefLanguage : match = x if not match : # don't bother about language match = literalEntities [ 0 ] return match