From e99245cc271237ef00b4bde0d31ee876c859ed3a Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Wed, 7 Aug 2019 20:37:25 +0300 Subject: [PATCH 1/2] Fix a 500 error in i18n default_copyright --- lms/templates/theme-variables.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lms/templates/theme-variables.html b/lms/templates/theme-variables.html index 93f209e0..e39f589e 100644 --- a/lms/templates/theme-variables.html +++ b/lms/templates/theme-variables.html @@ -140,13 +140,14 @@ <% footer_options = get_current_site_configuration().page_elements.get('footer', {}).get('options', {}) - def _default_copy_right(): - return ugettext('{copy_sign} {year} Company Name. All rights reserved.').format( - copy_sign='©', + def _default_copyright(): + return ugettext('{copy_sign} {year} {platform_name}. All rights reserved.').format( + copy_sign=u'©', + platform_name=force_text(get_value('PLATFORM_NAME', ugettext('Company Name'))), year=date.today().strftime('%Y'), ) - default_copy_right = lazy(_default_copy_right, six.text_type) + default_copyright = lazy(_default_copyright, six.text_type) return { 'footer_logo' : get_brand_logos()['icon_black'], ## leave as is, defined above. Can be changed to something custom if needed. From 04bb3e0bfcc6c0f8c50ab9ac33c0ef3b825e3ba7 Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Wed, 7 Aug 2019 21:08:00 +0300 Subject: [PATCH 2/2] translate(): Fix when no default, and only string is provided --- lms/templates/theme-variables.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lms/templates/theme-variables.html b/lms/templates/theme-variables.html index e39f589e..a831c3c5 100644 --- a/lms/templates/theme-variables.html +++ b/lms/templates/theme-variables.html @@ -7,6 +7,7 @@ <%! from django.utils.encoding import force_text %> <%! from django.utils import translation %> <%! from django.utils.translation import ugettext, ugettext_lazy as _ %> +<%! from django.utils.functional import Promise %> <%! from django.utils import six %> <%! from django.utils.functional import lazy %> <%! from datetime import date %> @@ -20,13 +21,15 @@ fallback_language = get_value('LANGUAGE_CODE', 'en') if not translations_object: + if not default: + raise Exception('translate: Please provide either the AMC-provided translation or the default fallback.') return default - if not isinstance(translations_object, dict): + if isinstance(translations_object, (basestring, Promise)): translations_object = {fallback_language: translations_object} default_text = default if default else force_text(translations_object.get(fallback_language, '')) - return force_text(translations_object.get(current_language)) or default_text + return force_text(translations_object.get(current_language, '')) or default_text %>