Space Pong 프로젝트 Backend
참고자료
- OAUTH 2.0 with Django : https://django-oauth-toolkit.readthedocs.io/en/latest/tutorial/tutorial.html
- Introduction to Django Channels: https://testdriven.io/blog/topics/django/
- Guide to Django Channels: https://ably.com/docs/channels
사용 Framework
- Django + Django Rest + Django Channel
- requests
Django를 이용한 다국어 지원 방법 : ref
apt-get install gettextGNU gettext toolkit은 언어변환에 필요한 각 언어별 단어사전을 관리하기 위한 도구- Django setting file 변경. SpacePong 경우 Localization(L10N)만 필요하나 USE_I18N이 True이어야 LANGUAGE_CODE to take effect
USE_I18N = True
USE_L10N = True
MIDDLEWARE = [
'django.middleware.locale.LocaleMiddleware',
] # 기존 middleware list에 항목 추가
LOCALE_PATHS = [
BASE_DIR / 'locale/',
] # 언어별 단어사전 file, 소위 message file들을 저장하기 위한 locale directory path. locale directory는 일반적으로 django project base directory 바로 아래 생성
- 각 언어별 message file 생성
$django-admin makemessages -l es $django-admin makemessages -l fr $django-admin makemessages -l en-us - locale/es/LC_MESSAGES/django.po <- 각 언어별 단어 사전 file 수정
msgid "Welcome" msgstr "Bienvenidos" - 4번 단어 file이 다 수정됐으면 단어 file compile
$django-admin compilemessages --all - django python code example :
from django import forms
from django.utils.translation import gettext_lazy as _
class ExampleForm(forms.Form):
first_name = forms.CharField(label=_('Welcome'))
- django html example :
{% trans "Welcome" %}
Leave a comment