Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a 500 error in i18n default_copyright #90

Merged
merged 2 commits into from
Aug 7, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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