mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Override behaviour of {% load i18n %}
- No longer requires custom tag loading - All templates now use escaped translation values - Requires re-ordering of app loading - Revert js_i18n to simply i18n
This commit is contained in:
parent
d13eb84448
commit
473ec9586c
@ -218,18 +218,6 @@ logger.debug(f"STATIC_ROOT: '{STATIC_ROOT}'")
|
|||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
|
||||||
# Core django modules
|
|
||||||
'django.contrib.admin',
|
|
||||||
'django.contrib.auth',
|
|
||||||
'django.contrib.contenttypes',
|
|
||||||
'user_sessions', # db user sessions
|
|
||||||
'django.contrib.messages',
|
|
||||||
'django.contrib.staticfiles',
|
|
||||||
'django.contrib.sites',
|
|
||||||
|
|
||||||
# Maintenance
|
|
||||||
'maintenance_mode',
|
|
||||||
|
|
||||||
# InvenTree apps
|
# InvenTree apps
|
||||||
'build.apps.BuildConfig',
|
'build.apps.BuildConfig',
|
||||||
'common.apps.CommonConfig',
|
'common.apps.CommonConfig',
|
||||||
@ -243,6 +231,18 @@ INSTALLED_APPS = [
|
|||||||
'plugin.apps.PluginAppConfig',
|
'plugin.apps.PluginAppConfig',
|
||||||
'InvenTree.apps.InvenTreeConfig', # InvenTree app runs last
|
'InvenTree.apps.InvenTreeConfig', # InvenTree app runs last
|
||||||
|
|
||||||
|
# Core django modules
|
||||||
|
'django.contrib.admin',
|
||||||
|
'django.contrib.auth',
|
||||||
|
'django.contrib.contenttypes',
|
||||||
|
'user_sessions', # db user sessions
|
||||||
|
'django.contrib.messages',
|
||||||
|
'django.contrib.staticfiles',
|
||||||
|
'django.contrib.sites',
|
||||||
|
|
||||||
|
# Maintenance
|
||||||
|
'maintenance_mode',
|
||||||
|
|
||||||
# Third part add-ons
|
# Third part add-ons
|
||||||
'django_filters', # Extended filter functionality
|
'django_filters', # Extended filter functionality
|
||||||
'rest_framework', # DRF (Django Rest Framework)
|
'rest_framework', # DRF (Django Rest Framework)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
Translated strings are escaped, such that they can be used as string literals in a javascript file.
|
Translated strings are escaped, such that they can be used as string literals in a javascript file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import django.templatetags.i18n
|
||||||
from django import template
|
from django import template
|
||||||
from django.template import TemplateSyntaxError
|
from django.template import TemplateSyntaxError
|
||||||
from django.templatetags.i18n import TranslateNode
|
from django.templatetags.i18n import TranslateNode
|
||||||
@ -100,3 +101,21 @@ def do_translate(parser, token):
|
|||||||
seen.add(option)
|
seen.add(option)
|
||||||
|
|
||||||
return CustomTranslateNode(message_string, noop, asvar, message_context)
|
return CustomTranslateNode(message_string, noop, asvar, message_context)
|
||||||
|
|
||||||
|
|
||||||
|
# Re-register tags which we have not explicitly overridden
|
||||||
|
register.tag("blocktrans", django.templatetags.i18n.do_block_translate)
|
||||||
|
register.tag("blocktranslate", django.templatetags.i18n.do_block_translate)
|
||||||
|
|
||||||
|
register.tag("language", django.templatetags.i18n.language)
|
||||||
|
|
||||||
|
register.tag("get_available_languages", django.templatetags.i18n.do_get_available_languages)
|
||||||
|
register.tag("get_language_info", django.templatetags.i18n.do_get_language_info)
|
||||||
|
register.tag("get_language_info_list", django.templatetags.i18n.do_get_language_info_list)
|
||||||
|
register.tag("get_current_language", django.templatetags.i18n.do_get_current_language)
|
||||||
|
register.tag("get_current_language_bidi", django.templatetags.i18n.do_get_current_language_bidi)
|
||||||
|
|
||||||
|
register.filter("language_name", django.templatetags.i18n.language_name)
|
||||||
|
register.filter("language_name_translated", django.templatetags.i18n.language_name_translated)
|
||||||
|
register.filter("language_name_local", django.templatetags.i18n.language_name_local)
|
||||||
|
register.filter("language_bidi", django.templatetags.i18n.language_bidi)
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
*/
|
*/
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
makeIconButton,
|
makeIconButton,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
imageHoverIcon,
|
imageHoverIcon,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
constructForm,
|
constructForm,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
constructForm,
|
constructForm,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
getAvailableTableFilters,
|
getAvailableTableFilters,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
/* exported
|
/* exported
|
||||||
blankImage,
|
blankImage,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
attachSelect,
|
attachSelect,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
inventreeGet,
|
inventreeGet,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
blankImage,
|
blankImage,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
/* exported
|
/* exported
|
||||||
loadNotificationTable,
|
loadNotificationTable,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
attachSelect,
|
attachSelect,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
/* globals
|
/* globals
|
||||||
*/
|
*/
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
{% load status_codes %}
|
{% load status_codes %}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
{% load status_codes %}
|
{% load status_codes %}
|
||||||
{% load inventree_extras %}
|
{% load inventree_extras %}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% load js_i18n %}
|
{% load i18n %}
|
||||||
|
|
||||||
/* global
|
/* global
|
||||||
inventreeLoad,
|
inventreeLoad,
|
||||||
|
Loading…
Reference in New Issue
Block a user