def lang_template_idx_adjust(template, idx):
    """
    Many templates take lang as the first parameter, except if the deprecated
    lang parameter is passed, in which case all the parameters are moved back a
    position. This normalises these cases.
    """
    assert idx >= 1
    if template.has("lang"):
        return idx - 1
    else:
        return idx