Skip to content

Instantly share code, notes, and snippets.

@rririanto
Last active February 20, 2021 00:53
Show Gist options
  • Save rririanto/8f16bf6913b506cceea7c44497ba29a3 to your computer and use it in GitHub Desktop.
Save rririanto/8f16bf6913b506cceea7c44497ba29a3 to your computer and use it in GitHub Desktop.
Settings Django Translation Manager v2
import environ
from django.utils.translation import gettext_lazy as _
ROOT_DIR = environ.Path(__file__) - 3
APPS_DIR = ROOT_DIR.path("apps")
INSTALLED_APPS = (
...
"translation_manager",
...
)
# Setup LocaleMiddleware to enable translations using ugettext_lazy and ugettext
# Make sure that LocaleMiddleware comes after SessionMiddleware and before CommonMiddleware
MIDDLEWARE = [
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.locale.LocaleMiddleware",
"django.middleware.common.CommonMiddleware",
]
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
# True if you want to support localization
USE_I18N = True
# Default languages
LANGUAGE_CODE = "vi"
# Provide a lists of languages which your site supports.
LANGUAGES = (
('vi', _('Viet Nam')),
('en', _('English')),
)
# If you set this to False, Django will not format dates, numbers and
# Use calendars according to the current locale.
USE_L10N = True
# Contains the path list where Django should look into for django.po files for all supported languages
LOCALE_PATHS = (str(APPS_DIR.path("locale")),)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment