Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #459 from Bidaya0/optimise-i18n
Browse files Browse the repository at this point in the history
Optimise i18n
  • Loading branch information
Bidaya0 authored Mar 1, 2022
2 parents c624b61 + 0543acf commit 74ff2dc
Show file tree
Hide file tree
Showing 15 changed files with 335 additions and 307 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ENV TZ=Asia/Shanghai
RUN curl -fsSL https://nginx.org/keys/nginx_signing.key | apt-key add - \
&& apt-key fingerprint ABF5BD827BD9BF62 \
&& apt-get update -y \
&& apt install -y libc6-dev unzip curl vim cron swig
&& apt install -y gettext libc6-dev unzip curl vim cron swig

RUN curl -L https://github.com/Endava/cats/releases/download/cats-7.0.1/cats-linux -o /usr/local/bin/cats \
&& chmod +x /usr/local/bin/cats \
Expand All @@ -19,4 +19,6 @@ RUN pip3 install -r /opt/dongtai/webapi/requirements.txt
COPY . /opt/dongtai/webapi
WORKDIR /opt/dongtai/webapi

RUN python manage.py compilemessages --all

ENTRYPOINT ["/bin/bash","/opt/dongtai/webapi/docker/entrypoint.sh"]
4 changes: 3 additions & 1 deletion DockerfileDev
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV TZ=Asia/Shanghai
ENV debug=true

RUN apt-get update -y \
&& apt install -y gcc make cmake libmariadb-dev curl
&& apt install -y gettext gcc make cmake libmariadb-dev curl

RUN curl -L https://github.com/Endava/cats/releases/download/cats-7.0.1/cats-linux -o /usr/local/bin/cats \
&& chmod +x /usr/local/bin/cats \
Expand All @@ -19,4 +19,6 @@ RUN pip3 install --upgrade pip && pip3 install -r /opt/dongtai/webapi/requirem
COPY . /opt/dongtai/webapi
WORKDIR /opt/dongtai/webapi

RUN python manage.py compilemessages --all

CMD ["/usr/local/bin/uwsgi","--ini", "/opt/dongtai/webapi/conf/uwsgi.ini"]
4 changes: 3 additions & 1 deletion DockerfileTest
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ENV debug=true
RUN curl -fsSL https://nginx.org/keys/nginx_signing.key | apt-key add - \
&& apt-key fingerprint ABF5BD827BD9BF62 \
&& apt-get update -y \
&& apt install -y libc6-dev unzip curl vim cron swig gcc make cmake
&& apt install -y gettext libc6-dev unzip curl vim cron swig gcc make cmake

RUN curl -L https://github.com/Endava/cats/releases/download/cats-7.0.1/cats-linux -o /usr/local/bin/cats \
&& chmod +x /usr/local/bin/cats \
Expand All @@ -24,4 +24,6 @@ RUN pip3 install --upgrade pip && pip3 install -r /opt/dongtai/webapi/requirem
COPY . /opt/dongtai/webapi
WORKDIR /opt/dongtai/webapi

RUN python manage.py compilemessages --all

ENTRYPOINT ["/bin/bash","/opt/dongtai/webapi/docker/entrypoint.sh"]
6 changes: 3 additions & 3 deletions apitest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ def get(self, request, pk):
project = IastProject.objects.filter(
user__in=users, pk=pk).order_by('-latest_time').first()
if not project:
return R.failure(msg='no project found')
return R.failure(msg=_('no project found'))
if not project.base_url:
return R.failure(msg=_(
'Please enter the parameters required for the test first'))
agents = IastAgent.objects.filter(user__in=auth_users,
bind_project_id=pk).values("id")
q = Q(agent__in=agents)
if not IastApiRoute.objects.filter(q).exists():
return R.failure(msg='No API collected')
return R.failure(msg=_('No API collected'))
api_routes = IastApiRoute.objects.filter(q).all()
datas = [serialize(api_route) for api_route in api_routes]
swaggerdatas = swagger_trans(datas)
Expand All @@ -69,7 +69,7 @@ def get(self, request, pk):
bind_project_id=pk).values("id")
q = Q(agent__in=agents)
if not IastApiRoute.objects.filter(q).exists():
return R.failure(msg='No API collected')
return R.failure(msg=_('No API collected'))
api_routes = IastApiRoute.objects.filter(q).all()
datas = [serialize(api_route) for api_route in api_routes]
swaggerdatas = swagger_trans(datas)
Expand Down
8 changes: 8 additions & 0 deletions batect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ tasks:
- "8000:8000"
group: serve

makemessages:
description: makemessages about i18n
run:
container: dongtai-webapi
entrypoint: python manage.py makemessages -l zh -l en
ports:
- "8000:8000"
group: tool

serve-with-db:
description: Serve the webapi application with db
Expand Down
Binary file removed i18n/en/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 74ff2dc

Please sign in to comment.