from django.conf import settings
from django.urls import resolve
from django.utils import translation
from django.middleware.locale import LocaleMiddleware

class CustomLocaleMiddleware(LocaleMiddleware):
    def process_request(self, request):
        url_path = request.path_info.lstrip('/')

        # 检查是否是 API 路径
        if url_path.startswith('api/'):
            return None

        return super().process_request(request)
