7.1. i18n and l10n

7.1.1. Timezone

  • django.utils.timezone

  • from django.conf.locale.en import formats as en_formats

>>> en_formats.DATETIME_FORMAT = 'Y-m-d H:i'    
>>> en_formats.DATE_FORMAT = 'Y-m-d'            
>>> en_formats.TIME_FORMAT = 'H:i'              
>>>
>>> USE_TZ = True
>>> TIME_ZONE = 'UTC'

7.1.2. Gettext

  • .po files

  • .mo files

  • Using gettext in code

  • Generating translation files

  • Compiling translation files

  • Updating translation files

  • Transifex (tx push and tx pull)

7.1.3. i18n - internationalization

  • django-admin makemessages -l en

  • django-admin compilemessages

  • {% blocktranslate %} and {% endblocktranslate %}

  • {% translate %}

  • from django.utils.translation import gettext_lazy as _

  • transifex-client

  • gettext

  • poedit

>>> # Internationalization
>>> # https://docs.djangoproject.com/en/dev/topics/i18n/
>>>
>>> LANGUAGE_CODE = 'en-us'
>>> USE_I18N = True
>>> USE_L10N = True
$ cd myproject/myapp
$ mkdir locale
$ django-admin makemessages -l en
processing locale en
$ django-admin makemessages -l pl
processing locale pl
$ django-admin compilemessages
processing file django.po in /src/myproject/myapp/locale/en/LC_MESSAGES
processing file django.po in /src/myproject/myapp/locale/pl/LC_MESSAGES