Merge branch 'add-webapi-endpoint-get-translation' into 'master'

Add web API endpoint get configured language

See merge request openlp/openlp!730
This commit is contained in:
Raoul Snyman 2024-03-28 03:17:33 +00:00
commit 39833c770d
2 changed files with 13 additions and 0 deletions

View File

@ -24,6 +24,7 @@ from flask import jsonify, request, abort, Blueprint
from PyQt5 import QtCore from PyQt5 import QtCore
from openlp.core.api.lib import login_required from openlp.core.api.lib import login_required
from openlp.core.common.i18n import LanguageManager
from openlp.core.common.registry import Registry from openlp.core.common.registry import Registry
from openlp.core.lib.plugin import PluginStatus, StringContent from openlp.core.lib.plugin import PluginStatus, StringContent
from openlp.core.state import State from openlp.core.state import State
@ -82,6 +83,12 @@ def system_information():
return jsonify(data) return jsonify(data)
@core.route('/language')
def language():
language = LanguageManager.get_language()
return jsonify({'language': language})
@core.route('/login', methods=['POST']) @core.route('/login', methods=['POST'])
def login(): def login():
data = request.json data = request.json

View File

@ -69,6 +69,12 @@ def test_shortcuts(flask_client: FlaskClient, settings: Settings):
assert res.get_json()[0]['shortcut'] == shortcut assert res.get_json()[0]['shortcut'] == shortcut
def test_language(flask_client: FlaskClient, settings: Settings):
res = flask_client.get('/api/v2/core/language')
assert res.status_code == 200
assert res.get_json()['language']
def test_poll_backend(settings: Settings): def test_poll_backend(settings: Settings):
""" """
Test the raw poll function returns the correct JSON Test the raw poll function returns the correct JSON