diff --git a/app/flatpages/help/api.md b/app/flatpages/help/api.md index 8113a2fd..7fef151f 100644 --- a/app/flatpages/help/api.md +++ b/app/flatpages/help/api.md @@ -189,6 +189,7 @@ Supported query parameters: * `tag`: Filter by tags. * `flag`: Filter to show packages with [Content Flags](/help/content_flags/). * `game`: Filter by [Game Support](/help/game_support/), ex: `Wuzzy/mineclone2`. (experimental, doesn't show items that support every game currently). +* `lang`: Filter by translation support, eg: `en`/`de`/`ja`/`zh_TW`. * `random`: When present, enable random ordering and ignore `sort`. * `limit`: Return at most `limit` packages. * `hide`: Hide content based on [Content Flags](/help/content_flags/). diff --git a/app/querybuilder.py b/app/querybuilder.py index c50097ca..885739f9 100644 --- a/app/querybuilder.py +++ b/app/querybuilder.py @@ -52,7 +52,8 @@ class QueryBuilder: ret = f"{self.search} - {ret}" if self.game: - ret = gettext("%(package_type)s for %(game_name)s", package_type=ret, game_name=self.game.title) + meta = self.game.get_translated(load_desc=False) + ret = gettext("%(package_type)s for %(game_name)s", package_type=ret, game_name=meta["title"]) return ret @@ -132,6 +133,8 @@ class QueryBuilder: if self.game: self.game = Package.get_by_key(self.game) + self.has_lang = args.get("lang") + if cookies and request.cookies.get("hide_nonfree") == "1": self.hide_nonfree = True @@ -197,6 +200,9 @@ class QueryBuilder: if self.game: query = query.filter(Package.supported_games.any(game=self.game, supports=True)) + if self.has_lang: + query = query.filter(Package.translations.any(language_id=self.has_lang)) + for tag in self.tags: query = query.filter(Package.tags.any(Tag.id == tag.id))