Files
shields/services/sourceforge/sourceforge-translations.service.js
Av32000 c2998a2dc9 [SourceForge] Added badges for SourceForge (#9078)
* Added sourceforge last-commit badge

* Added sourceforge commit-count badge

* Added sourceforge languages badge

* Added sourceforge contributors badge

* Added sourceforge translations badge

* Added sourceforge platform badge

* Fix SourceForge services ClassName

* Fixed JoiSchema + Added BaseSourceForgeService + Fixed last-commit and commit-count
2023-04-17 19:23:42 +00:00

47 lines
1.0 KiB
JavaScript

import Joi from 'joi'
import { metric } from '../text-formatters.js'
import BaseSourceForgeService from './sourceforge-base.js'
const schema = Joi.object({
categories: Joi.object({
translation: Joi.array().required(),
}).required(),
}).required()
export default class SourceforgeTranslations extends BaseSourceForgeService {
static category = 'activity'
static route = {
base: 'sourceforge/translations',
pattern: ':project',
}
static examples = [
{
title: 'SourceForge Translations',
namedParams: {
project: 'guitarix',
},
staticPreview: this.render({
translationCount: 4,
}),
},
]
static defaultBadgeData = { label: 'translations' }
static render({ translationCount }) {
return {
message: metric(translationCount),
color: 'blue',
}
}
async handle({ project }) {
const body = await this.fetch({ project, schema })
return this.constructor.render({
translationCount: body.categories.translation.length,
})
}
}