Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

feat: optimize api language support (#344)

John Wang1af968e73a70
diff --git a/api/controllers/console/admin.py b/api/controllers/console/admin.py
index 92c94221b81..0c8d4e331cd 100644
--- a/api/controllers/console/admin.py
+++ b/api/controllers/console/admin.py
@@ -8,6 +8,7 @@ from werkzeug.exceptions import NotFound, Unauthorized
from controllers.console import api
from controllers.console.wraps import only_edition_cloud
from extensions.ext_database import db
+from libs.helper import supported_language
from models.model import RecommendedApp, App, InstalledApp
@@ -47,8 +48,7 @@ class InsertExploreAppListApi(Resource):
parser.add_argument('desc', type=str, location='json')
parser.add_argument('copyright', type=str, location='json')
parser.add_argument('privacy_policy', type=str, location='json')
- parser.add_argument('language', type=str, required=True, nullable=False, choices=['en-US', 'zh-Hans'],
- location='json')
+ parser.add_argument('language', type=supported_language, required=True, nullable=False, location='json')
parser.add_argument('category', type=str, required=True, nullable=False, location='json')
parser.add_argument('position', type=int, required=True, nullable=False, location='json')
args = parser.parse_args()
diff --git a/api/controllers/console/app/app.py b/api/controllers/console/app/app.py
index 83d6840838f..127a568f7f6 100644
--- a/api/controllers/console/app/app.py
+++ b/api/controllers/console/app/app.py
@@ -215,7 +215,11 @@ class AppTemplateApi(Resource):
account = current_user
interface_language = account.interface_language
- return {'data': demo_model_templates.get(interface_language)}
+ templates = demo_model_templates.get(interface_language)
+ if not templates:
+ templates = demo_model_templates.get('en-US')
+
+ return {'data': templates}
class AppApi(Resource):