mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-08 22:17:34 +01:00
Make QueryBuilder default to get_locale()
This commit is contained in:
parent
65dc8c0891
commit
2621e9f7d3
@ -14,8 +14,9 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
from flask import abort, current_app, request
|
from flask import abort, current_app, request
|
||||||
from flask_babel import lazy_gettext, gettext
|
from flask_babel import lazy_gettext, gettext, get_locale
|
||||||
from sqlalchemy import or_
|
from sqlalchemy import or_
|
||||||
from sqlalchemy.orm import subqueryload
|
from sqlalchemy.orm import subqueryload
|
||||||
from sqlalchemy.sql.expression import func
|
from sqlalchemy.sql.expression import func
|
||||||
@ -60,8 +61,13 @@ class QueryBuilder:
|
|||||||
return (self.search is not None or len(self.tags) > 1 or len(self.types) > 1 or len(self.hide_flags) > 0 or
|
return (self.search is not None or len(self.tags) > 1 or len(self.types) > 1 or len(self.hide_flags) > 0 or
|
||||||
self.random or self.lucky or self.author or self.version or self.game)
|
self.random or self.lucky or self.author or self.version or self.game)
|
||||||
|
|
||||||
def __init__(self, args, cookies=False, lang="en"):
|
def __init__(self, args, cookies: bool = False, lang: Optional[str] = None):
|
||||||
self.lang = lang
|
if lang is None:
|
||||||
|
locale = get_locale()
|
||||||
|
if locale:
|
||||||
|
self.lang = locale.language
|
||||||
|
else:
|
||||||
|
self.lang = lang
|
||||||
|
|
||||||
# Get request types
|
# Get request types
|
||||||
types = args.getlist("type")
|
types = args.getlist("type")
|
||||||
|
Loading…
Reference in New Issue
Block a user