mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-08 22:17:34 +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])
|
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/")
|
@bp.route("/api/dependencies/")
|
||||||
@cors_allowed
|
@cors_allowed
|
||||||
def all_deps():
|
def all_deps():
|
||||||
|
@ -466,31 +466,43 @@ Supported query parameters:
|
|||||||
|
|
||||||
### Tags
|
### Tags
|
||||||
|
|
||||||
* GET `/api/tags/` ([View](/api/tags/)): List of:
|
* GET `/api/tags/` ([View](/api/tags/))
|
||||||
* `name`: technical name.
|
* List of objects with:
|
||||||
* `title`: human-readable title.
|
* `name`: technical name.
|
||||||
* `description`: tag description or null.
|
* `title`: human-readable title.
|
||||||
* `views`: number of views of this tag.
|
* `description`: tag description or null.
|
||||||
|
* `views`: number of views of this tag.
|
||||||
|
|
||||||
### Content Warnings
|
### Content Warnings
|
||||||
|
|
||||||
* GET `/api/content_warnings/` ([View](/api/content_warnings/)): List of:
|
* GET `/api/content_warnings/` ([View](/api/content_warnings/))
|
||||||
* `name`: technical name
|
* List of objects with
|
||||||
* `title`: human-readable title
|
* `name`: technical name
|
||||||
* `description`: tag description or null
|
* `title`: human-readable title
|
||||||
|
* `description`: tag description or null
|
||||||
|
|
||||||
### Licenses
|
### Licenses
|
||||||
|
|
||||||
* GET `/api/licenses/` ([View](/api/licenses/)): List of:
|
* GET `/api/licenses/` ([View](/api/licenses/))
|
||||||
* `name`
|
* List of objects with:
|
||||||
* `is_foss`: whether the license is foss
|
* `name`
|
||||||
|
* `is_foss`: whether the license is foss
|
||||||
|
|
||||||
### Minetest Versions
|
### Minetest Versions
|
||||||
|
|
||||||
* GET `/api/minetest_versions/` ([View](/api/minetest_versions/))
|
* GET `/api/minetest_versions/` ([View](/api/minetest_versions/))
|
||||||
* `name`: Version name.
|
* List of objects with:
|
||||||
* `is_dev`: boolean, is dev version.
|
* `name`: Version name.
|
||||||
* `protocol_version`: protocol version umber.
|
* `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
|
## Misc
|
||||||
|
@ -847,6 +847,17 @@ class Language(db.Model):
|
|||||||
id = db.Column(db.String(10), primary_key=True)
|
id = db.Column(db.String(10), primary_key=True)
|
||||||
title = db.Column(db.String(100), unique=True, nullable=False)
|
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):
|
class PackageTranslation(db.Model):
|
||||||
package_id = db.Column(db.Integer, db.ForeignKey("package.id"), primary_key=True)
|
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">
|
||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
<div class="row text-muted">
|
<div class="row text-muted">
|
||||||
<div class="col-sm-2">
|
<div class="col-2">
|
||||||
{{ _("Id") }}
|
{{ _("Id") }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm">
|
<div class="col">
|
||||||
{{ _("Title") }}
|
{{ _("Title") }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col-3 text-end">
|
||||||
|
{{ _("Has ContentDB translation?") }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -26,12 +30,19 @@
|
|||||||
<a class="list-group-item list-group-item-action"
|
<a class="list-group-item list-group-item-action"
|
||||||
href="{{ url_for('admin.create_edit_language', id_=l.id) }}">
|
href="{{ url_for('admin.create_edit_language', id_=l.id) }}">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-2">
|
<div class="col-2">
|
||||||
{{ l.id }}
|
{{ l.id }}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm">
|
<div class="col">
|
||||||
{{ l.title }}
|
{{ l.title }}
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
Loading…
Reference in New Issue
Block a user