def getCheckCategoriesTemplate(usage, galleries, ncats):
    """Build the check categories template with all parameters."""
    result = ('{{Check categories|year={{subst:CURRENTYEAR}}|month={{subst:'
              'CURRENTMONTHNAME}}|day={{subst:CURRENTDAY}}\n')
    usageCounter = 1
    for (lang, project, article) in usage:
        result += '|lang%d=%s' % (usageCounter, lang)
        result += '|wiki%d=%s' % (usageCounter, project)
        result += '|article%d=%s' % (usageCounter, article)
        result += '\n'
        usageCounter += 1
    galleryCounter = 1
    for gallery in galleries:
        result += '|gallery{}={}'.format(galleryCounter,
                                         gallery.replace('_', ' ')) + '\n'
        galleryCounter += 1
    result += '|ncats={}\n}}\n'.format(ncats)
    return result