mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Add has_contentdb_translation
to Language, add API
This commit is contained in:
parent
6b34a91241
commit
b1a9398ed1
@ -648,6 +648,12 @@ def versions():
|
||||
for rel in MinetestRelease.query.all() if rel.get_actual() is not None])
|
||||
|
||||
|
||||
@bp.route("/api/languages/")
|
||||
@cors_allowed
|
||||
def languages():
|
||||
return jsonify([x.as_dict() for x in Language.query.all()])
|
||||
|
||||
|
||||
@bp.route("/api/dependencies/")
|
||||
@cors_allowed
|
||||
def all_deps():
|
||||
|
@ -466,31 +466,43 @@ Supported query parameters:
|
||||
|
||||
### Tags
|
||||
|
||||
* GET `/api/tags/` ([View](/api/tags/)): List of:
|
||||
* `name`: technical name.
|
||||
* `title`: human-readable title.
|
||||
* `description`: tag description or null.
|
||||
* `views`: number of views of this tag.
|
||||
* GET `/api/tags/` ([View](/api/tags/))
|
||||
* List of objects with:
|
||||
* `name`: technical name.
|
||||
* `title`: human-readable title.
|
||||
* `description`: tag description or null.
|
||||
* `views`: number of views of this tag.
|
||||
|
||||
### Content Warnings
|
||||
|
||||
* GET `/api/content_warnings/` ([View](/api/content_warnings/)): List of:
|
||||
* `name`: technical name
|
||||
* `title`: human-readable title
|
||||
* `description`: tag description or null
|
||||
* GET `/api/content_warnings/` ([View](/api/content_warnings/))
|
||||
* List of objects with
|
||||
* `name`: technical name
|
||||
* `title`: human-readable title
|
||||
* `description`: tag description or null
|
||||
|
||||
### Licenses
|
||||
|
||||
* GET `/api/licenses/` ([View](/api/licenses/)): List of:
|
||||
* `name`
|
||||
* `is_foss`: whether the license is foss
|
||||
* GET `/api/licenses/` ([View](/api/licenses/))
|
||||
* List of objects with:
|
||||
* `name`
|
||||
* `is_foss`: whether the license is foss
|
||||
|
||||
### Minetest Versions
|
||||
|
||||
* GET `/api/minetest_versions/` ([View](/api/minetest_versions/))
|
||||
* `name`: Version name.
|
||||
* `is_dev`: boolean, is dev version.
|
||||
* `protocol_version`: protocol version umber.
|
||||
* List of objects with:
|
||||
* `name`: Version name.
|
||||
* `is_dev`: boolean, is dev version.
|
||||
* `protocol_version`: protocol version number.
|
||||
|
||||
### Languages
|
||||
|
||||
* GET `/api/languages/` ([View](/api/languages/))
|
||||
* List of objects with:
|
||||
* `id`: language code.
|
||||
* `title`: native language name.
|
||||
* `has_contentdb_translation`: whether ContentDB has been translated into this language.
|
||||
|
||||
|
||||
## Misc
|
||||
|
@ -847,6 +847,17 @@ class Language(db.Model):
|
||||
id = db.Column(db.String(10), primary_key=True)
|
||||
title = db.Column(db.String(100), unique=True, nullable=False)
|
||||
|
||||
@property
|
||||
def has_contentdb_translation(self):
|
||||
return self.id in app.config["LANGUAGES"].keys()
|
||||
|
||||
def as_dict(self):
|
||||
return {
|
||||
"id": self.id,
|
||||
"title": self.title,
|
||||
"has_contentdb_translation": self.has_contentdb_translation,
|
||||
}
|
||||
|
||||
|
||||
class PackageTranslation(db.Model):
|
||||
package_id = db.Column(db.Integer, db.ForeignKey("package.id"), primary_key=True)
|
||||
|
@ -12,13 +12,17 @@
|
||||
<div class="list-group">
|
||||
<div class="list-group-item">
|
||||
<div class="row text-muted">
|
||||
<div class="col-sm-2">
|
||||
<div class="col-2">
|
||||
{{ _("Id") }}
|
||||
</div>
|
||||
|
||||
<div class="col-sm">
|
||||
<div class="col">
|
||||
{{ _("Title") }}
|
||||
</div>
|
||||
|
||||
<div class="col-3 text-end">
|
||||
{{ _("Has ContentDB translation?") }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -26,12 +30,19 @@
|
||||
<a class="list-group-item list-group-item-action"
|
||||
href="{{ url_for('admin.create_edit_language', id_=l.id) }}">
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
<div class="col-2">
|
||||
{{ l.id }}
|
||||
</div>
|
||||
<div class="col-sm">
|
||||
<div class="col">
|
||||
{{ l.title }}
|
||||
</div>
|
||||
<div class="col-3 text-end">
|
||||
{% if l.has_contentdb_translation %}
|
||||
<i class="fas fa-check text-success"></i>
|
||||
{% else %}
|
||||
<i class="fas fa-times text-danger"></i>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in New Issue
Block a user