Skip to content

Commit

Permalink
Merge a15cdeb into 2b761a1
Browse files Browse the repository at this point in the history
  • Loading branch information
msouff committed Mar 14, 2021
2 parents 2b761a1 + a15cdeb commit 11f160a
Show file tree
Hide file tree
Showing 34 changed files with 1,074 additions and 258 deletions.
15 changes: 8 additions & 7 deletions tethys_apps/templates/tethys_apps/app_base.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{% load static tethys_gizmos terms_tags analytical%}
{% load static tethys_gizmos terms_tags analytical i18n %}
<!DOCTYPE html>

{# Allows custom attributes to be added to the html tag #}
{% block htmltag %}
<!--[if IE 7]> <html lang="en" class="ie ie7"> <![endif]-->
<!--[if IE 8]> <html lang="en" class="ie ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en" > <!--<![endif]-->
{% get_current_language as LANGUAGE_CODE %}
<!--[if IE 7]> <html lang="{{ LANGUAGE_CODE }}" class="ie ie7"> <![endif]-->
<!--[if IE 8]> <html lang="{{ LANGUAGE_CODE }}" class="ie ie8"> <![endif]-->
<!--[if IE 9]> <html lang="{{ LANGUAGE_CODE }}" class="ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="{{ LANGUAGE_CODE }}" > <!--<![endif]-->
{% endblock %}

{# Allows custom attributes to be added to the head tag #}
Expand Down Expand Up @@ -150,7 +151,7 @@
{% block login_button_override %}
{% if not request.user.is_authenticated %}
<div class="header-button login-button">
<a href="javascript:void(0);" onclick="TETHYS_APP_BASE.exit_app('{% url 'accounts:login' %}?next={{request.path}}');"data-toggle="tooltip" data-placement="bottom" title="Log In">Log In</a>
<a href="javascript:void(0);" onclick="TETHYS_APP_BASE.exit_app('{% url 'accounts:login' %}?next={{request.path}}');"data-toggle="tooltip" data-placement="bottom" title="Log In">{% trans "Log In" %}</a>
</div>
{% endif %}
{% endblock %}
Expand Down Expand Up @@ -189,7 +190,7 @@
<div class="alert {% if message.tags %}{{ message.tags }}{% endif %} alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
<span class="sr-only">{% trans "Close" %}</span>
</button>
{{ message }}
</div>
Expand Down
8 changes: 4 additions & 4 deletions tethys_apps/templates/tethys_apps/app_library.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

{% extends "page.html" %}

{% load static tags site_settings %}
{% load static tags site_settings i18n %}

{% block title %}- Apps Library{% endblock %}

Expand All @@ -22,7 +22,7 @@
{% block primary_content %}
<div class="tethys-secondary-header narrow clearfix" style="background-color: {{ site_globals.secondary_color|default:'#1b95dc' }};">
<div class="secondary-title-wrapper">
<span class="secondary-title">{% if site_globals.apps_library_title %}{{ site_globals.apps_library_title }}{% else %}Apps Library{% endif %}</span>
<span class="secondary-title">{% if site_globals.apps_library_title %}{{ site_globals.apps_library_title }}{% else %}{% trans "Apps Library" %}{% endif %}</span>
</div>
</div>
<div class="app-library-wrapper clearfix">
Expand All @@ -34,7 +34,7 @@
<ul class="list-inline filter">

{% if apps|get_tags_from_apps %}
<li><a href="#" data-filter="*" class="tag-button active" >All </a></li>
<li><a href="#" data-filter="*" class="tag-button active" >{% trans "All" %} </a></li>
{% for tag in apps|get_tags_from_apps%}
{% if tag %}
<li><a href="#" data-filter=".{{ tag }}" class="tag-button">{{ tag }}</a></li>
Expand Down Expand Up @@ -92,7 +92,7 @@
{% endfor %}
</div>
{% else %}
<h2 class="no-apps-loaded-message">There are no apps loaded.</h2>
<h2 class="no-apps-loaded-message">{% trans "There are no apps loaded." %}</h2>
{% endif %}
</div>
<div id="app-library-curtain"></div>
Expand Down
41 changes: 21 additions & 20 deletions tethys_config/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
********************************************************************************
"""
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from .models import SettingsCategory, Setting


Expand Down Expand Up @@ -96,15 +97,15 @@ def setting_defaults(category):

if category.name == 'General Settings':
category.setting_set.create(name="Site Title",
content="Tethys Portal",
content=_("Tethys Portal"),
date_modified=now)

category.setting_set.create(name="Favicon",
content="/tethys_portal/images/default_favicon.png",
date_modified=now)

category.setting_set.create(name="Brand Text",
content="Tethys Portal",
content=_("Tethys Portal"),
date_modified=now)

category.setting_set.create(name="Brand Image",
Expand All @@ -124,7 +125,7 @@ def setting_defaults(category):
date_modified=now)

category.setting_set.create(name="Apps Library Title",
content="Apps Library",
content=_("Apps Library"),
date_modified=now)

category.setting_set.create(name="Primary Color",
Expand Down Expand Up @@ -156,66 +157,66 @@ def setting_defaults(category):
date_modified=now)

category.setting_set.create(name="Footer Copyright",
content="Copyright © 2019 Your Organization",
content=_("Copyright © 2019 Your Organization"),
date_modified=now)

elif category.name == 'Home Page':
category.setting_set.create(name="Hero Text",
content="Welcome to Tethys Portal,\nthe hub for your apps.",
content=_("Welcome to Tethys Portal,\nthe hub for your apps."),
date_modified=now)

category.setting_set.create(name="Blurb Text",
content="Tethys Portal is designed to be customizable, so that you can host "
"apps for your\norganization. You can change everything on this page "
"from the Home Page settings.",
content=_("Tethys Portal is designed to be customizable, so that you can host "
"apps for your\norganization. You can change everything on this page "
"from the Home Page settings."),
date_modified=now)

category.setting_set.create(name="Feature 1 Heading",
content="Feature 1",
content=_("Feature 1"),
date_modified=now)

category.setting_set.create(name="Feature 1 Body",
content="Use these features to brag about all of the things users can do with "
"your instance of Tethys Portal.",
content=_("Use these features to brag about all of the things users can do with "
"your instance of Tethys Portal."),
date_modified=now)

category.setting_set.create(name="Feature 1 Image",
content="/tethys_portal/images/placeholder.gif",
date_modified=now)

category.setting_set.create(name="Feature 2 Heading",
content="Feature 2",
content=_("Feature 2"),
date_modified=now)

category.setting_set.create(name="Feature 2 Body",
content="Describe the apps and tools that your Tethys Portal provides and add "
"custom pictures to each feature as a finishing touch.",
content=_("Describe the apps and tools that your Tethys Portal provides and add "
"custom pictures to each feature as a finishing touch."),
date_modified=now)

category.setting_set.create(name="Feature 2 Image",
content="/tethys_portal/images/placeholder.gif",
date_modified=now)

category.setting_set.create(name="Feature 3 Heading",
content="Feature 3",
content=_("Feature 3"),
date_modified=now)

category.setting_set.create(name="Feature 3 Body",
content="You can change the color theme and branding of your Tethys Portal in a "
"jiffy. Visit the Site Admin settings from the user menu and select "
"General Settings.",
content=_("You can change the color theme and branding of your Tethys Portal in a "
"jiffy. Visit the Site Admin settings from the user menu and select "
"General Settings."),
date_modified=now)

category.setting_set.create(name="Feature 3 Image",
content="/tethys_portal/images/placeholder.gif",
date_modified=now)

category.setting_set.create(name="Call to Action",
content="Ready to get started?",
content=_("Ready to get started?"),
date_modified=now)

category.setting_set.create(name="Call to Action Button",
content="Start Using Tethys!",
content=_("Start Using Tethys!"),
date_modified=now)

elif category.name == 'Custom Styles':
Expand Down
61 changes: 61 additions & 0 deletions tethys_locale/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
***************************
Tethys Platform Translation
***************************

Tethys uses the `Django Translation <https://docs.djangoproject.com/en/2.2/topics/i18n/translation/>`_ to provide translation support.

Follow the steps below to add a new translation:
================================================

1. Add the new language code to tethys_portal/settings.py
---------------------------------------------------------

::

...

LANGUAGES = [
('en', _('English')),
('es', _('Spanish')),
]

...

Language codes can be found `here <https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-LANGUAGE_CODE>`_.

2. Go to tethys home and run the following commands:
----------------------------------------------------

::

$ conda activate tethys
$ python tethys_portal/manage.py makemessages -l <LANGUAGE_CODE>

A .po file with the new language will be created at <TETHYS_HOME>/tethys_locale.

3. Navigate to the .po file and populate the file with translations.
--------------------------------------------------------------------

``#:/path/to/file:line`` shows the location of the text, ``msgid`` is the original text, ``msgstr`` is where the translation for that text should go.

::

...

#: tethys_portal/templates/admin/base.html:69
msgid "Home"
msgstr "Inicio"

...

.. note::

Translation block with a ``fuzzy`` key, require revision. Remove the ``fuzzy`` key after confirming it looks the way it should (e.g. not a duplicate).

4. Compile the .mo file:
------------------------

::

$ conda activate tethys
$ python tethys_portal/manage.py complilemessages
Binary file added tethys_locale/es/LC_MESSAGES/django.mo
Binary file not shown.

0 comments on commit 11f160a

Please sign in to comment.