Self hosted FLOSS fitness/workout, nutrition and weight tracker
Add setting with available languages for the angular app
Roland Geiderf71b036d1d1a
diff --git a/wger/settings_global.py b/wger/settings_global.pyindex c432a393e..e21c08ad7 100644--- a/wger/settings_global.py+++ b/wger/settings_global.py@@ -210,6 +210,12 @@ LANGUAGE_CODE = 'en'# All translation files are in one placeLOCALE_PATHS = (os.path.join(SITE_ROOT, 'locale'), )+# Available locales for angular app+LANGUAGES_ANGULAR = (+ 'en',+ 'de',+)+# Primary keys are AutoFieldsDEFAULT_AUTO_FIELD = 'django.db.models.AutoField'diff --git a/wger/utils/context_processor.py b/wger/utils/context_processor.pyindex c6ebf0a82..8ff1e5cb0 100644--- a/wger/utils/context_processor.py+++ b/wger/utils/context_processor.py@@ -47,6 +47,9 @@ def processor(request):# Available application languages'languages': settings.LANGUAGES,+ # Available application languages for angular app+ 'languages_angular': settings.LANGUAGES_ANGULAR,+# The current path'request_full_path': full_path,diff --git a/wger/weight/templates/overview.html b/wger/weight/templates/overview.htmlindex ed016d03c..2d87300fa 100644--- a/wger/weight/templates/overview.html+++ b/wger/weight/templates/overview.html@@ -10,6 +10,21 @@{# Header #}{# #}{% block header %}+ <!--+ <link rel="stylesheet" type="text/css" href="{% static 'angular/en/styles.css' %}">+ -->++ <script src="{% static 'angular/en/runtime.js' %}" defer></script>+ <script src="{% static 'angular/en/polyfills.js' %}" defer></script>++ {# Manually load the appropriate language if it's available #}+ {% if language.short_name in languages_angular %}+ {% with 'angular/'|add:language.short_name|add:"/main.js" as test %}+ <script src="{% static test %}" defer></script>+ {% endwith %}+ {% else %}+ <script src="{% static 'angular/en/main.js' %}" defer></script>+ {% endif %}{% endblock %}@@ -18,83 +33,11 @@{# Content #}{# #}{% block content %}-<div id="current-username" data-current-username="{{ owner_user.username }}"></div>-{% if not min_date %}-<p>- {% translate "There is no chart here because there are no weight entries." %}- {% translate "Use link to add one." %}-</p>-{% endif %}--<div id="weight_diagram"></div>-<br>-<input id="height" placeholder="{% translate "height in cm" %}" type="number">-<input id="enable_bmi" type="button" value="BMI">--<div class="btn-group modify-time-period-controls float-right" role="group" aria-label="..." style="padding-bottom: 1em;">- <button type="button" class="btn btn-light" data-time_period="90">{% translate "Last 3 months" %}</button>- <button type="button" class="btn btn-light" data-time_period="365">{% translate "Last 12 months" %}</button>- <button type="button" class="btn btn-light active" data-time_period="all">{% translate "No filter" %}</button>-</div>+<app-root></app-root>-{% if is_owner %}-{% if last_five_weight_entries_details %}-<table class="table">- <tr>- <th>{% translate 'Date' %}</th>- <th>{% translate 'Weight' %}</th>- <th>{% translate 'Change' context "Noun, not verb" %}</th>- <th>{% translate 'Days' %}</th>- </tr>- {% for entry_detail in last_five_weight_entries_details %}- <tr>- <td>{{ entry_detail.0.date }}</td>- <td>{{ entry_detail.0.weight }}</td>- <!-- weight diff and day diff below -->- <td>- {% if entry_detail.1 > 0 %}- +- {% endif %}- {% if entry_detail.1 %}- {{ entry_detail.1 }}- {% else %}- -/-- {% endif %}- </td>- <td>- {% if entry_detail.2 %}- {{ entry_detail.2 }}- {% else %}- -/-- {% endif %}- </td>- <td>- <div class="btn-group" role="group" >- <div class="btn-group" role="group">- <button id="btnGroupWorkout" type="button" class="btn btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">- </button>- <div class="dropdown-menu dropdown-menu-right" aria-labelledby="btnGroupWorkout">- <a href="{% url 'weight:edit' entry_detail.0.id %}" class="dropdown-item wger-modal-dialog">- <span class="{% fa_class 'edit' %}"></span>- {% translate "Edit weight" %}- </a>- <div class="dropdown-divider"></div>- <a href="{% url 'weight:delete' entry_detail.0.id %}" class="dropdown-item wger-modal-dialog">- <span class="{% fa_class 'trash' %}"></span>- {% translate "Delete" %}- </a>- </div>- </div>- </div>- </td>- </tr>- {% endfor %}-</table>-{% endif %}-{% endif %}{% endblock %}