Skip to content

Commit

Permalink
Merge pull request #90 from appsembler/omar/fix-500-error-i18n
Browse files Browse the repository at this point in the history
Fix a 500 error in i18n default_copyright
  • Loading branch information
OmarIthawi authored Aug 7, 2019
2 parents 05ba3b5 + 04bb3e0 commit e0b0c03
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lms/templates/theme-variables.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand All @@ -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
%>


Expand Down Expand Up @@ -140,13 +143,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.
Expand Down

0 comments on commit e0b0c03

Please sign in to comment.