Add translateable strings support in babybuddy app.

This commit is contained in:
Christopher C. Wells 2019-04-13 21:50:35 -07:00
parent ad1cc1ee94
commit c36451fc8e
21 changed files with 193 additions and 149 deletions

View File

@ -2,16 +2,18 @@
from django.contrib import admin from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.utils.translation import gettext_lazy as _
from babybuddy import models from babybuddy import models
class SettingsInline(admin.StackedInline): class SettingsInline(admin.StackedInline):
model = models.Settings model = models.Settings
verbose_name_plural = 'Settings' verbose_name = _('Settings')
verbose_name_plural = _('Settings')
can_delete = False can_delete = False
fieldsets = ( fieldsets = (
('Dashboard', { (_('Dashboard'), {
'fields': ('dashboard_refresh_rate',) 'fields': ('dashboard_refresh_rate',)
}), }),
) )

View File

@ -4,6 +4,7 @@ from django.db import models
from django.db.models.signals import post_save from django.db.models.signals import post_save
from django.dispatch import receiver from django.dispatch import receiver
from django.utils.timezone import timedelta from django.utils.timezone import timedelta
from django.utils.translation import gettext_lazy as _
from rest_framework.authtoken.models import Token from rest_framework.authtoken.models import Token
@ -11,22 +12,22 @@ from rest_framework.authtoken.models import Token
class Settings(models.Model): class Settings(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE) user = models.OneToOneField(User, on_delete=models.CASCADE)
dashboard_refresh_rate = models.DurationField( dashboard_refresh_rate = models.DurationField(
verbose_name='Refresh rate', verbose_name=_('Refresh rate'),
help_text='This setting will only be used when a browser does not ' help_text=_('This setting will only be used when a browser does not '
'support refresh on focus.', 'support refresh on focus.'),
blank=True, blank=True,
null=True, null=True,
default=timedelta(minutes=1), default=timedelta(minutes=1),
choices=[ choices=[
(None, 'disabled'), (None, _('disabled')),
(timedelta(minutes=1), '1 min.'), (timedelta(minutes=1), _('1 min.')),
(timedelta(minutes=2), '2 min.'), (timedelta(minutes=2), _('2 min.')),
(timedelta(minutes=3), '3 min.'), (timedelta(minutes=3), _('3 min.')),
(timedelta(minutes=4), '4 min.'), (timedelta(minutes=4), _('4 min.')),
(timedelta(minutes=5), '5 min.'), (timedelta(minutes=5), _('5 min.')),
(timedelta(minutes=10), '10 min.'), (timedelta(minutes=10), _('10 min.')),
(timedelta(minutes=15), '15 min.'), (timedelta(minutes=15), _('15 min.')),
(timedelta(minutes=30), '30 min.'), (timedelta(minutes=30), _('30 min.')),
]) ])
def __str__(self): def __str__(self):

View File

@ -1,15 +1,15 @@
{% extends 'babybuddy/page.html' %} {% extends 'babybuddy/page.html' %}
{% load widget_tweaks %} {% load i18n widget_tweaks %}
{% block title %}403 Permission Denied{% endblock %} {% block title %}403 {% trans "Permission Denied" %}{% endblock %}
{% block breadcrumbs %} {% block breadcrumbs %}
<li class="breadcrumb-item active" aria-current="page">Permission Denied</li> <li class="breadcrumb-item active" aria-current="page">{% trans "Permission Denied" %}</li>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
You do not have permission to access this resource. Contact a site {% blocktrans %}You do not have permission to access this resource.
administrator for assistance. Contact a site administrator for assistance.{% endblocktrans %}
</div> </div>
{% endblock %} {% endblock %}

View File

@ -1,4 +1,4 @@
{% load static %} {% load i18n static %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
@ -31,7 +31,7 @@
{% block breadcrumb_nav %} {% block breadcrumb_nav %}
<nav aria-label="breadcrumb" role="navigation"> <nav aria-label="breadcrumb" role="navigation">
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/">Home</a></li> <li class="breadcrumb-item"><a href="/">{% trans "Home" %}</a></li>
{% block breadcrumbs %}{% endblock %} {% block breadcrumbs %}{% endblock %}
</ol> </ol>
</nav> </nav>

View File

@ -1,4 +1,4 @@
{% load widget_tweaks %} {% load i18n widget_tweaks %}
<form id="filter_form" role="form" action="" method="get" class="collapse{% if request.GET.filtered %} show{% endif %}"> <form id="filter_form" role="form" action="" method="get" class="collapse{% if request.GET.filtered %} show{% endif %}">
<div class="form-group form-row"> <div class="form-group form-row">
@ -15,8 +15,8 @@
</div> </div>
{% endfor %} {% endfor %}
<div class="col-xs-12 col-sm-auto mt-3 mt-sm-0"> <div class="col-xs-12 col-sm-auto mt-3 mt-sm-0">
<button type="submit" class="btn btn-sm btn-primary mr-2">Filter</button> <button type="submit" class="btn btn-sm btn-primary mr-2">{% trans "Filter" %}</button>
<a href="{{ request.path }}" class="btn btn-sm btn-error">Reset</a> <a href="{{ request.path }}" class="btn btn-sm btn-error">{% trans "Reset" %}</a>
</div> </div>
</div> </div>
<input type="hidden" name="filtered" value="1"/> <input type="hidden" name="filtered" value="1"/>
@ -29,6 +29,6 @@
role="button" role="button"
aria-expanded="false" aria-expanded="false"
aria-controls="filter_form"> aria-controls="filter_form">
Filters {% trans "Filters" %}
</a> </a>
</p> </p>

View File

@ -1,4 +1,4 @@
{% load widget_tweaks %} {% load i18n widget_tweaks %}
<div class="container-fluid"> <div class="container-fluid">
<form role="form" method="post" enctype="multipart/form-data"> <form role="form" method="post" enctype="multipart/form-data">
@ -8,6 +8,6 @@
{% include 'babybuddy/form_field.html' %} {% include 'babybuddy/form_field.html' %}
</div> </div>
{% endfor %} {% endfor %}
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">{% trans "Submit" %}</button>
</form> </form>
</div> </div>

View File

@ -1,3 +1,5 @@
{% load i18n %}
{% block messages %} {% block messages %}
{% if messages %} {% if messages %}
{% for message in messages %} {% for message in messages %}
@ -13,12 +15,12 @@
{% if form.non_field_errors %} {% if form.non_field_errors %}
{% for error in form.non_field_errors %} {% for error in form.non_field_errors %}
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
<strong>Error:</strong> {{ error }} {% blocktrans %}<strong>Error:</strong> {{ error }}{% endblocktrans %}
</div> </div>
{% endfor %} {% endfor %}
{% elif form.errors %} {% elif form.errors %}
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
<strong>Error:</strong> Some fields have errors. See below for details. {% blocktrans %}<strong>Error:</strong> Some fields have errors. See below for details. {% endblocktrans %}
</div> </div>
{% endif %} {% endif %}
{% endif %} {% endif %}

View File

@ -1,5 +1,5 @@
{% extends 'babybuddy/base.html' %} {% extends 'babybuddy/base.html' %}
{% load babybuddy_tags static timers %} {% load babybuddy_tags i18n static timers %}
{% block nav %} {% block nav %}
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top"> <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
@ -23,32 +23,38 @@
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="nav-quick-add-link"> <div class="dropdown-menu dropdown-menu-right" aria-labelledby="nav-quick-add-link">
{% if perms.core.add_diaperchange %} {% if perms.core.add_diaperchange %}
<a class="dropdown-item p-2" href="{% url 'core:diaperchange-add' %}"> <a class="dropdown-item p-2" href="{% url 'core:diaperchange-add' %}">
<i class="icon icon-diaperchange" aria-hidden="true"></i> Diaper Change <i class="icon icon-diaperchange" aria-hidden="true"></i>
{% trans "Diaper Change" %}
</a> </a>
{% endif %} {% endif %}
{% if perms.core.add_feeding %} {% if perms.core.add_feeding %}
<a class="dropdown-item p-2" href="{% url 'core:feeding-add' %}"> <a class="dropdown-item p-2" href="{% url 'core:feeding-add' %}">
<i class="icon icon-feeding" aria-hidden="true"></i> Feeding <i class="icon icon-feeding" aria-hidden="true"></i>
{% trans "Feeding" %}
</a> </a>
{% endif %} {% endif %}
{% if perms.core.add_note %} {% if perms.core.add_note %}
<a class="dropdown-item p-2" href="{% url 'core:note-add' %}"> <a class="dropdown-item p-2" href="{% url 'core:note-add' %}">
<i class="icon icon-note" aria-hidden="true"></i> Note <i class="icon icon-note" aria-hidden="true"></i>
{% trans "Note" %}
</a> </a>
{% endif %} {% endif %}
{% if perms.core.add_sleep %} {% if perms.core.add_sleep %}
<a class="dropdown-item p-2" href="{% url 'core:sleep-add' %}"> <a class="dropdown-item p-2" href="{% url 'core:sleep-add' %}">
<i class="icon icon-sleep" aria-hidden="true"></i> Sleep <i class="icon icon-sleep" aria-hidden="true"></i>
{% trans "Sleep" %}
</a> </a>
{% endif %} {% endif %}
{% if perms.core.add_tummytime %} {% if perms.core.add_tummytime %}
<a class="dropdown-item p-2" href="{% url 'core:tummytime-add' %}"> <a class="dropdown-item p-2" href="{% url 'core:tummytime-add' %}">
<i class="icon icon-tummytime" aria-hidden="true"></i> Tummy Time <i class="icon icon-tummytime" aria-hidden="true"></i>
{% trans "Tummy Time" %}
</a> </a>
{% endif %} {% endif %}
{% if perms.core.add_weight %} {% if perms.core.add_weight %}
<a class="dropdown-item p-2" href="{% url 'core:weight-add' %}"> <a class="dropdown-item p-2" href="{% url 'core:weight-add' %}">
<i class="icon icon-weight" aria-hidden="true"></i> Weight <i class="icon icon-weight" aria-hidden="true"></i>
{% trans "Weight" %}
</a> </a>
{% endif %} {% endif %}
</div> </div>
@ -66,7 +72,8 @@
<ul class="navbar-nav mr-auto"> <ul class="navbar-nav mr-auto">
<li class="nav-item{% if request.path == '/' %} active{% endif %}"> <li class="nav-item{% if request.path == '/' %} active{% endif %}">
<a class="nav-link" href="{% url 'dashboard:dashboard' %}"> <a class="nav-link" href="{% url 'dashboard:dashboard' %}">
<i class="icon icon-dashboard" aria-hidden="true"></i> Dashboard <i class="icon icon-dashboard" aria-hidden="true"></i>
{% trans "Dashboard" %}
</a> </a>
</li> </li>
@ -76,40 +83,51 @@
href="#" href="#"
data-toggle="dropdown" data-toggle="dropdown"
aria-haspopup="true" aria-haspopup="true"
aria-expanded="false"><i class="icon icon-child" aria-hidden="true"></i> Children</a> aria-expanded="false"><i class="icon icon-child" aria-hidden="true"></i>
{% trans "Children" %}
</a>
<div class="dropdown-menu" aria-labelledby="nav-children-menu-link"> <div class="dropdown-menu" aria-labelledby="nav-children-menu-link">
{% if perms.core.view_child %} {% if perms.core.view_child %}
<a class="dropdown-item{% if request.path == '/children/' %} active{% endif %}" <a class="dropdown-item{% if request.path == '/children/' %} active{% endif %}"
href="{% url 'core:child-list' %}"> href="{% url 'core:child-list' %}">
<i class="icon icon-child" aria-hidden="true"></i> Children <i class="icon icon-child" aria-hidden="true"></i>
{% trans "Children" %}
</a> </a>
{% endif %} {% endif %}
{% if perms.core.add_child %} {% if perms.core.add_child %}
<a class="dropdown-item pl-5{% if request.path == '/children/add/' %} active{% endif %}" <a class="dropdown-item pl-5{% if request.path == '/children/add/' %} active{% endif %}"
href="{% url 'core:child-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Child</a> href="{% url 'core:child-add' %}"><i class="icon icon-add" aria-hidden="true"></i>
{% trans "Child" %}
</a>
{% endif %} {% endif %}
{% if perms.core.view_note %} {% if perms.core.view_note %}
<a class="dropdown-item{% if request.path == '/notes/' %} active{% endif %}" <a class="dropdown-item{% if request.path == '/notes/' %} active{% endif %}"
href="{% url 'core:note-list' %}"> href="{% url 'core:note-list' %}">
<i class="icon icon-note" aria-hidden="true"></i> Notes <i class="icon icon-note" aria-hidden="true"></i>
{% trans "Notes" %}
</a> </a>
{% endif %} {% endif %}
{% if perms.core.add_note %} {% if perms.core.add_note %}
<a class="dropdown-item pl-5{% if request.path == '/notes/add/' %} active{% endif %}" <a class="dropdown-item pl-5{% if request.path == '/notes/add/' %} active{% endif %}"
href="{% url 'core:note-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Note</a> href="{% url 'core:note-add' %}"><i class="icon icon-add" aria-hidden="true"></i>
{% trans "Note" %}
</a>
{% endif %} {% endif %}
{% if perms.core.view_weight %} {% if perms.core.view_weight %}
<a class="dropdown-item{% if request.path == '/weight/' %} active{% endif %}" <a class="dropdown-item{% if request.path == '/weight/' %} active{% endif %}"
href="{% url 'core:weight-list' %}"> href="{% url 'core:weight-list' %}">
<i class="icon icon-weight" aria-hidden="true"></i> Weight <i class="icon icon-weight" aria-hidden="true"></i>
{% trans "Weight" %}
</a> </a>
{% endif %} {% endif %}
{% if perms.core.add_weight %} {% if perms.core.add_weight %}
<a class="dropdown-item pl-5{% if request.path == '/weight/add/' %} active{% endif %}" <a class="dropdown-item pl-5{% if request.path == '/weight/add/' %} active{% endif %}"
href="{% url 'core:weight-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Weight entry</a> href="{% url 'core:weight-add' %}"><i class="icon icon-add" aria-hidden="true"></i>
{% trans "Weight entry" %}
</a>
{% endif %} {% endif %}
</div> </div>
@ -121,43 +139,61 @@
href="#" href="#"
data-toggle="dropdown" data-toggle="dropdown"
aria-haspopup="true" aria-haspopup="true"
aria-expanded="false"><i class="icon icon-activities" aria-hidden="true"></i> Activities</a> aria-expanded="false"><i class="icon icon-activities" aria-hidden="true"></i>
{% trans "Activities" %}
</a>
<div class="dropdown-menu" aria-labelledby="nav-activity-menu-link"> <div class="dropdown-menu" aria-labelledby="nav-activity-menu-link">
{% if perms.core.view_diaperchange %} {% if perms.core.view_diaperchange %}
<a class="dropdown-item{% if request.path == '/changes/' %} active{% endif %}" <a class="dropdown-item{% if request.path == '/changes/' %} active{% endif %}"
href="{% url 'core:diaperchange-list' %}"><i class="icon icon-diaperchange" aria-hidden="true"></i> Changes</a> href="{% url 'core:diaperchange-list' %}"><i class="icon icon-diaperchange" aria-hidden="true"></i>
{% trans "Changes" %}
</a>
{% endif %} {% endif %}
{% if perms.core.add_diaperchange %} {% if perms.core.add_diaperchange %}
<a class="dropdown-item pl-5{% if request.path == '/changes/add/' %} active{% endif %}" <a class="dropdown-item pl-5{% if request.path == '/changes/add/' %} active{% endif %}"
href="{% url 'core:diaperchange-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Change</a> href="{% url 'core:diaperchange-add' %}"><i class="icon icon-add" aria-hidden="true"></i>
{% trans "Change" %}
</a>
{% endif %} {% endif %}
{% if perms.core.view_feeding %} {% if perms.core.view_feeding %}
<a class="dropdown-item{% if request.path == '/feedings/' %} active{% endif %}" <a class="dropdown-item{% if request.path == '/feedings/' %} active{% endif %}"
href="{% url 'core:feeding-list' %}"><i class="icon icon-feeding" aria-hidden="true"></i> Feedings</a> href="{% url 'core:feeding-list' %}"><i class="icon icon-feeding" aria-hidden="true"></i>
{% trans "Feedings" %}
</a>
{% endif %} {% endif %}
{% if perms.core.add_diaperchange %} {% if perms.core.add_diaperchange %}
<a class="dropdown-item pl-5{% if request.path == '/feedings/add/' %} active{% endif %}" <a class="dropdown-item pl-5{% if request.path == '/feedings/add/' %} active{% endif %}"
href="{% url 'core:feeding-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Feeding</a> href="{% url 'core:feeding-add' %}"><i class="icon icon-add" aria-hidden="true"></i>
{% trans "Feeding" %}
</a>
{% endif %} {% endif %}
{% if perms.core.view_sleep %} {% if perms.core.view_sleep %}
<a class="dropdown-item{% if request.path == '/sleep/' %} active{% endif %}" <a class="dropdown-item{% if request.path == '/sleep/' %} active{% endif %}"
href="{% url 'core:sleep-list' %}"><i class="icon icon-sleep" aria-hidden="true"></i> Sleep</a> href="{% url 'core:sleep-list' %}"><i class="icon icon-sleep" aria-hidden="true"></i>
{% trans "Sleep" %}
</a>
{% endif %} {% endif %}
{% if perms.core.add_sleep %} {% if perms.core.add_sleep %}
<a class="dropdown-item pl-5{% if request.path == '/sleep/add/' %} active{% endif %}" <a class="dropdown-item pl-5{% if request.path == '/sleep/add/' %} active{% endif %}"
href="{% url 'core:sleep-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Sleep entry</a> href="{% url 'core:sleep-add' %}"><i class="icon icon-add" aria-hidden="true"></i>
{% trans "Sleep entry" %}
</a>
{% endif %} {% endif %}
{% if perms.core.view_tummytime %} {% if perms.core.view_tummytime %}
<a class="dropdown-item{% if request.path == '/tummy-time/' %} active{% endif %}" <a class="dropdown-item{% if request.path == '/tummy-time/' %} active{% endif %}"
href="{% url 'core:tummytime-list' %}"><i class="icon icon-tummytime" aria-hidden="true"></i> Tummy Time</a> href="{% url 'core:tummytime-list' %}"><i class="icon icon-tummytime" aria-hidden="true"></i>
{% trans "Tummy Time" %}
</a>
{% endif %} {% endif %}
{% if perms.core.add_tummytime %} {% if perms.core.add_tummytime %}
<a class="dropdown-item pl-5{% if request.path == '/tummy-time/add/' %} active{% endif %}" <a class="dropdown-item pl-5{% if request.path == '/tummy-time/add/' %} active{% endif %}"
href="{% url 'core:tummytime-add' %}"><i class="icon icon-add" aria-hidden="true"></i> Tummy Time entry</a> href="{% url 'core:tummytime-add' %}"><i class="icon icon-add" aria-hidden="true"></i>
{% trans "Tummy Time entry" %}
</a>
{% endif %} {% endif %}
</div> </div>
@ -179,29 +215,29 @@
aria-expanded="false"><i class="icon icon-user" aria-hidden="true"></i> {{ request.user }} aria-expanded="false"><i class="icon icon-user" aria-hidden="true"></i> {{ request.user }}
</a> </a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="nav-user-menu-link"> <div class="dropdown-menu dropdown-menu-right" aria-labelledby="nav-user-menu-link">
<h6 class="dropdown-header">User</h6> <h6 class="dropdown-header">{% trans "User" %}</h6>
<a href="{% url 'babybuddy:user-settings' %}" class="dropdown-item">Settings</a> <a href="{% url 'babybuddy:user-settings' %}" class="dropdown-item">{% trans "Settings" %}</a>
<a href="{% url 'babybuddy:user-password' %}" class="dropdown-item">Password</a> <a href="{% url 'babybuddy:user-password' %}" class="dropdown-item">{% trans "Password" %}</a>
<a href="{% url 'babybuddy:logout' %}" class="dropdown-item">Logout</a> <a href="{% url 'babybuddy:logout' %}" class="dropdown-item">{% trans "Logout" %}</a>
<h6 class="dropdown-header">Site</h6> <h6 class="dropdown-header">{% trans "Site" %}</h6>
<a href="{% url 'api:api-root' %}" <a href="{% url 'api:api-root' %}"
class="dropdown-item" class="dropdown-item"
target="_blank">API Browser</a> target="_blank">{% trans "API Browser" %}</a>
{% if request.user.is_staff %} {% if request.user.is_staff %}
<a href="{% url 'babybuddy:user-list' %}" class="dropdown-item">Users</a> <a href="{% url 'babybuddy:user-list' %}" class="dropdown-item">{% trans "Users" %}</a>
<a href="{% url 'admin:index' %}" <a href="{% url 'admin:index' %}"
class="dropdown-item" class="dropdown-item"
target="_blank">Backend Admin</a> target="_blank">{% trans "Backend Admin" %}</a>
{% endif %} {% endif %}
<h6 class="dropdown-header">Support</h6> <h6 class="dropdown-header">{% trans "Support" %}</h6>
<a href="https://github.com/cdubz/babybuddy" <a href="https://github.com/cdubz/babybuddy"
class="dropdown-item" class="dropdown-item"
target="_blank"> target="_blank">
<i class="icon icon-source" aria-hidden="true"></i> Source Code</a> <i class="icon icon-source" aria-hidden="true"></i> {% trans "Source Code" %}</a>
<a href="https://gitter.im/babybuddy/Lobby" <a href="https://gitter.im/babybuddy/Lobby"
class="dropdown-item" class="dropdown-item"
target="_blank"> target="_blank">
<i class="icon icon-chat" aria-hidden="true"></i> Chat / Support</a> <i class="icon icon-chat" aria-hidden="true"></i> {% trans "Chat / Support" %}</a>
<h6 class="dropdown-header">v{% version_string %}</h6> <h6 class="dropdown-header">v{% version_string %}</h6>
</div> </div>
</li> </li>

View File

@ -1,4 +1,4 @@
{% load babybuddy_tags %} {% load i18n babybuddy_tags %}
{% if is_paginated %} {% if is_paginated %}
<nav aria-label="Page navigation"> <nav aria-label="Page navigation">
@ -8,7 +8,7 @@
<li class="page-item"> <li class="page-item">
<a class="page-link" href="{% relative_url 'page' page_obj.previous_page_number %}" aria-label="Previous"> <a class="page-link" href="{% relative_url 'page' page_obj.previous_page_number %}" aria-label="Previous">
<i class="icon icon-chevron-left" aria-hidden="true"></i> <i class="icon icon-chevron-left" aria-hidden="true"></i>
<span class="sr-only">Previous</span> <span class="sr-only">{% trans "Previous" %}</span>
</a> </a>
</li> </li>
{% endif %} {% endif %}
@ -25,7 +25,7 @@
<li class="page-item"> <li class="page-item">
<a class="page-link" href="{% relative_url 'page' page_obj.next_page_number %}" aria-label="Next"> <a class="page-link" href="{% relative_url 'page' page_obj.next_page_number %}" aria-label="Next">
<i class="icon icon-chevron-right" aria-hidden="true"></i> <i class="icon icon-chevron-right" aria-hidden="true"></i>
<span class="sr-only">Next</span> <span class="sr-only">{% trans "Next" %}</span>
</a> </a>
</li> </li>
{% endif %} {% endif %}

View File

@ -1,19 +1,19 @@
{% extends 'babybuddy/page.html' %} {% extends 'babybuddy/page.html' %}
{% load widget_tweaks %} {% load i18n widget_tweaks %}
{% block title %}Delete User{% endblock %} {% block title %}{% trans "Delete User" %}{% endblock %}
{% block breadcrumbs %} {% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'babybuddy:user-list' %}">Users</a></li> <li class="breadcrumb-item"><a href="{% url 'babybuddy:user-list' %}">{% trans "Users" %}</a></li>
<li class="breadcrumb-item">{{ object }}</li> <li class="breadcrumb-item">{{ object }}</li>
<li class="breadcrumb-item active" aria-current="page">Delete</li> <li class="breadcrumb-item active" aria-current="page">{% trans "Delete" %}</li>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<form role="form" method="post"> <form role="form" method="post">
{% csrf_token %} {% csrf_token %}
<h1>Are you sure you want to delete <span class="text-info">{{ object }}</span>?</h1> {% blocktrans %}<h1>Are you sure you want to delete <span class="text-info">{{ object }}</span>?</h1>{% endblocktrans %}
<input type="submit" value="Delete" class="btn btn-danger" /> <input type="submit" value="Delete" class="btn btn-danger" />
<a href="{% url 'babybuddy:user-list' %}" class="btn btn-default">Cancel</a> <a href="{% url 'babybuddy:user-list' %}" class="btn btn-default">{% trans "Cancel" %}</a>
</form> </form>
{% endblock %} {% endblock %}

View File

@ -1,28 +1,29 @@
{% extends 'babybuddy/page.html' %} {% extends 'babybuddy/page.html' %}
{% load i18n %}
{% block title %} {% block title %}
{% if object %} {% if object %}
{{ object }} {{ object }}
{% else %} {% else %}
Create User {% trans "Create User" %}
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block breadcrumbs %} {% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'babybuddy:user-list' %}">Users</a></li> <li class="breadcrumb-item"><a href="{% url 'babybuddy:user-list' %}">{% trans "Users" %}</a></li>
{% if object %} {% if object %}
<li class="breadcrumb-item font-weight-bold">{{ object }}</li> <li class="breadcrumb-item font-weight-bold">{{ object }}</li>
<li class="breadcrumb-item active" aria-current="page">Update</li> <li class="breadcrumb-item active" aria-current="page">{% trans "Update" %}</li>
{% else %} {% else %}
<li class="breadcrumb-item active" aria-current="page">Create User</li> <li class="breadcrumb-item active" aria-current="page">{% trans "Create User" %}</li>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% if object %} {% if object %}
<h1>Update <span class="text-info">{{ object }}</span></h1> {% blocktrans %}<h1>Update <span class="text-info">{{ object }}</span></h1>{% endblocktrans %}
{% else %} {% else %}
<h1>Create User</h1> <h1>{% trans "Create User" %}</h1>
{% endif %} {% endif %}
{% include 'babybuddy/form.html' %} {% include 'babybuddy/form.html' %}
{% endblock %} {% endblock %}

View File

@ -1,10 +1,10 @@
{% extends 'babybuddy/page.html' %} {% extends 'babybuddy/page.html' %}
{% load bootstrap widget_tweaks %} {% load bootstrap i18n widget_tweaks %}
{% block title %}Users{% endblock %} {% block title %}{% trans "Users" %}{% endblock %}
{% block breadcrumbs %} {% block breadcrumbs %}
<li class="breadcrumb-item active" aria-current="page">Users</li> <li class="breadcrumb-item active" aria-current="page">{% trans "Users" %}</li>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
@ -14,13 +14,13 @@
<table class="table table-striped table-hover user-list"> <table class="table table-striped table-hover user-list">
<thead class="thead-inverse"> <thead class="thead-inverse">
<tr> <tr>
<th>User</th> <th>{% trans "User" %}</th>
<th>First Name</th> <th>{% trans "First Name" %}</th>
<th>Last Name</th> <th>{% trans "Last Name" %}</th>
<th>Email</th> <th>{% trans "Email" %}</th>
<th>Staff</th> <th>{% trans "Staff" %}</th>
<th>Active</th> <th>{% trans "Active" %}</th>
<th class="text-center">Actions</th> <th class="text-center">{% trans "Actions" %}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -52,7 +52,7 @@
</tr> </tr>
{% empty %} {% empty %}
<tr> <tr>
<th colspan="4">No users found.</th> <th colspan="4">{% trans "No users found." %}</th>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
@ -62,7 +62,7 @@
{% if perms.admin.add_user %} {% if perms.admin.add_user %}
<a href="{% url 'babybuddy:user-add' %}" class="btn btn-sm btn-success"> <a href="{% url 'babybuddy:user-add' %}" class="btn btn-sm btn-success">
<i class="icon icon-add" aria-hidden="true"></i> Create User <i class="icon icon-add" aria-hidden="true"></i> {% trans "Create User" %}
</a> </a>
{% endif %} {% endif %}

View File

@ -1,14 +1,14 @@
{% extends 'babybuddy/page.html' %} {% extends 'babybuddy/page.html' %}
{% load widget_tweaks %} {% load i18n widget_tweaks %}
{% block title %}Change Password{% endblock %} {% block title %}{% trans "Change Password" %}{% endblock %}
{% block breadcrumbs %} {% block breadcrumbs %}
<li class="breadcrumb-item">User</li> <li class="breadcrumb-item">{% trans "User" %}</li>
<li class="breadcrumb-item active">Change Password</li> <li class="breadcrumb-item active">{% trans "Change Password" %}</li>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<h1>Change Password</h1> <h1>{% trans "Change Password" %}</h1>
{% include 'babybuddy/form.html' %} {% include 'babybuddy/form.html' %}
{% endblock %} {% endblock %}

View File

@ -1,31 +1,31 @@
{% extends 'babybuddy/page.html' %} {% extends 'babybuddy/page.html' %}
{% load i18n widget_tweaks %} {% load i18n widget_tweaks %}
{% block title %}User Settings{% endblock %} {% block title %}{% trans "User Settings" %}{% endblock %}
{% block breadcrumbs %} {% block breadcrumbs %}
<li class="breadcrumb-item">User</li> <li class="breadcrumb-item">{% trans "User" %}</li>
<li class="breadcrumb-item active">Settings</li> <li class="breadcrumb-item active">{% trans "Settings" %}</li>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<h1>User Settings</h1> <h1>{% trans "User Settings" %}</h1>
<div class="container-fluid"> <div class="container-fluid">
<form role="form" method="post"> <form role="form" method="post">
{% csrf_token %} {% csrf_token %}
{% if form.non_field_errors %} {% if form.non_field_errors %}
{% for error in form.non_field_errors %} {% for error in form.non_field_errors %}
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
<strong>Error:</strong> {{ error }} {% blocktrans %}<strong>Error:</strong> {{ error }}{% endblocktrans %}
</div> </div>
{% endfor %} {% endfor %}
{% elif form.errors %} {% elif form.errors %}
<div class="alert alert-danger" role="alert"> <div class="alert alert-danger" role="alert">
<strong>Error:</strong> Some fields have errors. See below for details. {% blocktrans %}<strong>Error:</strong> Some fields have errors. See below for details.{% endblocktrans %}
</div> </div>
{% endif %} {% endif %}
<fieldset> <fieldset>
<legend>User Profile</legend> <legend>{% trans "User Profile" %}</legend>
<div class="form-group row"> <div class="form-group row">
{% with form_user.first_name as field %} {% with form_user.first_name as field %}
{% include 'babybuddy/form_field.html' %} {% include 'babybuddy/form_field.html' %}
@ -43,7 +43,7 @@
</div> </div>
<div class="form-group row"> <div class="form-group row">
<label for="id_language" class="col-sm-2 col-form-label"> <label for="id_language" class="col-sm-2 col-form-label">
Language {% trans "Language" %}
</label> </label>
<div class="col-sm-10"> <div class="col-sm-10">
<select name="language"> <select name="language">
@ -60,7 +60,7 @@
</div> </div>
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend>Dashboard</legend> <legend>{% trans "Dashboard" %}</legend>
<div class="form-group row"> <div class="form-group row">
{% with form_settings.dashboard_refresh_rate as field %} {% with form_settings.dashboard_refresh_rate as field %}
{% include 'babybuddy/form_field.html' %} {% include 'babybuddy/form_field.html' %}
@ -68,16 +68,16 @@
</div> </div>
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend>API</legend> <legend>{% trans "API" %}</legend>
<div class="form-group row"> <div class="form-group row">
<label for="id_email" class="col-sm-2 col-form-label">Key</label> <label for="id_email" class="col-sm-2 col-form-label">{% trans "Key" %}</label>
<div class="col-sm-10"> <div class="col-sm-10">
<samp>{{ user.settings.api_key }}</samp> <samp>{{ user.settings.api_key }}</samp>
<a class="btn btn-xs btn-danger" href="{% url 'babybuddy:user-reset-api-key' %}">Regenerate</a> <a class="btn btn-xs btn-danger" href="{% url 'babybuddy:user-reset-api-key' %}">{% trans "Regenerate" %}</a>
</div> </div>
</div> </div>
</fieldset> </fieldset>
<button type="submit" class="btn btn-primary">Submit</button> <button type="submit" class="btn btn-primary">{% trans "Submit" %}</button>
</form> </form>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -1,18 +1,18 @@
{% extends 'babybuddy/page.html' %} {% extends 'babybuddy/page.html' %}
{% load widget_tweaks %} {% load i18n widget_tweaks %}
{% block title %}Welcome!{% endblock %} {% block title %}{% trans "Welcome!" %}{% endblock %}
{% block breadcrumbs %} {% block breadcrumbs %}
<li class="breadcrumb-item active" aria-current="page">Welcome!</li> <li class="breadcrumb-item active" aria-current="page">{% trans "Welcome!" %}</li>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="jumbotron"> <div class="jumbotron">
<h1 class="display-3">Welcome to Baby Buddy!</h1> <h1 class="display-3">{% trans "Welcome to Baby Buddy!" %}</h1>
<p class="lead"> <p class="lead">
Learn about and predict baby's needs without (<em>as much</em>) {% blocktrans %}Learn about and predict baby's needs without
guess work by using Baby Buddy to track &mdash; (<em>as much</em>) guess work by using Baby Buddy to track &mdash;{% endblocktrans %}
</p> </p>
<hr class="my-4"> <hr class="my-4">
<div class="card-deck"> <div class="card-deck">
@ -21,7 +21,7 @@
<i class="icon icon-2x icon-diaperchange" aria-hidden="true"></i> <i class="icon icon-2x icon-diaperchange" aria-hidden="true"></i>
</div> </div>
<div class="card-body"> <div class="card-body">
<h3 class="card-title text-center">Diaper Changes</h3> <h3 class="card-title text-center">{% trans "Diaper Changes" %}</h3>
</div> </div>
</div> </div>
<div class="card card-feeding"> <div class="card card-feeding">
@ -29,7 +29,7 @@
<i class="icon icon-2x icon-feeding" aria-hidden="true"></i> <i class="icon icon-2x icon-feeding" aria-hidden="true"></i>
</div> </div>
<div class="card-body"> <div class="card-body">
<h3 class="card-title text-center">Feedings</h3> <h3 class="card-title text-center">{% trans "Feedings" %}</h3>
</div> </div>
</div> </div>
<div class="card card-sleep"> <div class="card card-sleep">
@ -37,7 +37,7 @@
<i class="icon icon-2x icon-sleep" aria-hidden="true"></i> <i class="icon icon-2x icon-sleep" aria-hidden="true"></i>
</div> </div>
<div class="card-body"> <div class="card-body">
<h3 class="card-title text-center">Sleep</h3> <h3 class="card-title text-center">{% trans "Sleep" %}</h3>
</div> </div>
</div> </div>
<div class="card card-tummytime"> <div class="card card-tummytime">
@ -45,23 +45,23 @@
<i class="icon icon-2x icon-tummytime" aria-hidden="true"></i> <i class="icon icon-2x icon-tummytime" aria-hidden="true"></i>
</div> </div>
<div class="card-body"> <div class="card-body">
<h3 class="card-title text-center">Tummy Time</h3> <h3 class="card-title text-center">{% trans "Tummy Time" %}</h3>
</div> </div>
</div> </div>
</div> </div>
<hr class="my-4"> <hr class="my-4">
<p class="lead"> <p class="lead">
As the amount of entries grows, Baby Buddy will help {% blocktrans %}As the amount of entries grows, Baby Buddy will help
parents and caregivers to identify small patterns in baby's habits parents and caregivers to identify small patterns in baby's habits
using the dashboard and graphs. Baby Buddy is mobile-friendly and using the dashboard and graphs. Baby Buddy is mobile-friendly and
uses a dark theme to help weary moms and dads with 2AM feedings and uses a dark theme to help weary moms and dads with 2AM feedings and
changings. To get started, just click the button below to add your changings. To get started, just click the button below to add your
first (or second, third, etc.) child! first (or second, third, etc.) child!{% endblocktrans %}
</p> </p>
<p class="text-center"> <p class="text-center">
{% if perms.core.add_child %} {% if perms.core.add_child %}
<a href="{% url 'core:child-add' %}" class="btn btn-lg btn-success"> <a href="{% url 'core:child-add' %}" class="btn btn-lg btn-success">
<i class="icon icon-child" aria-hidden="true"></i> Add a Child <i class="icon icon-child" aria-hidden="true"></i> {% trans "Add a Child" %}
</a> </a>
{% endif %} {% endif %}
</p> </p>

View File

@ -1,5 +1,5 @@
{% extends "registration/base.html" %} {% extends "registration/base.html" %}
{% load static widget_tweaks %} {% load i18n static widget_tweaks %}
{% block title %}Login{% endblock %} {% block title %}Login{% endblock %}
{% block content %} {% block content %}
@ -29,12 +29,12 @@
</div> </div>
<button class="btn btn-primary w-100 fade-in" type="submit" name="login"> <button class="btn btn-primary w-100 fade-in" type="submit" name="login">
Login {% trans "Login" %}
</button> </button>
</form> </form>
<div class="bg-faded text-center px-4 py-3 rounded-bottom"> <div class="bg-faded text-center px-4 py-3 rounded-bottom">
<a href="{% url 'babybuddy:password_reset' %}" name="reset"> <a href="{% url 'babybuddy:password_reset' %}" name="reset">
Forgot your password?</a> {% trans "Forgot your password?" %}</a>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -1,11 +1,12 @@
{% extends "registration/base.html" %} {% extends "registration/base.html" %}
{% load i18n %}
{% block title %}Password Reset Successfully!{% endblock %} {% block title %}{% trans "Password Reset Successfully!" %}{% endblock %}
{% block content %} {% block content %}
<div class="text-center mb-0"> <div class="text-center mb-0">
<p>Your password has been set. You may go ahead and log in now.</p> <p>{% trans "Your password has been set. You may go ahead and log in now." %}</p>
<p class="mb-0"><a href="{{ login_url }}">Log in</a></p> <p class="mb-0"><a href="{{ login_url }}">{% trans "Log in" %}</a></p>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -1,7 +1,7 @@
{% extends "registration/base.html" %} {% extends "registration/base.html" %}
{% load static widget_tweaks %} {% load i18n static widget_tweaks %}
{% block title %}Password Reset{% endblock %} {% block title %}{% trans "Password Reset" %}{% endblock %}
{% block content %} {% block content %}
<form method="post"> <form method="post">
@ -9,13 +9,13 @@
{% if form.errors %} {% if form.errors %}
<div class="alert alert-danger"> <div class="alert alert-danger">
<p class="mb-0"><strong>Oh snap!</strong> The two passwords {% blocktrans %}<p class="mb-0"><strong>Oh snap!</strong> The
did not match. Please try again.</p> two passwords did not match. Please try again.</p>{% endblocktrans %}
</div> </div>
{% endif %} {% endif %}
<div class="text-center mb-4"> <div class="text-center mb-4">
<p class="mb-0">Enter your new password in each field below.</p> <p class="mb-0">{% trans "Enter your new password in each field below." %}</p>
</div> </div>
<label class="sr-only" for="password1-input-group"> <label class="sr-only" for="password1-input-group">
@ -28,7 +28,6 @@
{% render_field form.new_password1 name='new_password1' class+='form-control' id='password1-input-group' %} {% render_field form.new_password1 name='new_password1' class+='form-control' id='password1-input-group' %}
</div> </div>
<label class="sr-only" for="password2-input-group"> <label class="sr-only" for="password2-input-group">
{{ form.new_password2.label }} {{ form.new_password2.label }}
</label> </label>
@ -40,7 +39,7 @@
</div> </div>
<button class="btn btn-primary w-100 fade-in" type="submit" name="reset"> <button class="btn btn-primary w-100 fade-in" type="submit" name="reset">
Reset Password {% trans "Reset Password" %}
</button> </button>
</form> </form>

View File

@ -1,15 +1,16 @@
{% extends "registration/base.html" %} {% extends "registration/base.html" %}
{% load i18n %}
{% block title %}Reset Email Sent{% endblock %} {% block title %}{% trans "Reset Email Sent" %}{% endblock %}
{% block content %} {% block content %}
<div class="text-center mb-0"> <div class="text-center mb-0">
<p>We've emailed you instructions for setting your {% blocktrans %}<p>We've emailed you instructions for setting your
password, if an account exists with the email you entered. You password, if an account exists with the email you entered. You
should receive them shortly.</p> should receive them shortly.</p>
<p class="mb-0">If you don't receive an email, please make sure you've <p class="mb-0">If you don't receive an email, please make sure you've
entered the address you registered with, and check your spam entered the address you registered with, and check your spam
folder.</p> folder.</p>{% endblocktrans %}
</div> </div>
{% endblock %} {% endblock %}

View File

@ -1,13 +1,13 @@
{% extends "registration/base.html" %} {% extends "registration/base.html" %}
{% load static widget_tweaks %} {% load i18n static widget_tweaks %}
{% block title %}Forgot Password{% endblock %} {% block title %}{% trans "Forgot Password" %}{% endblock %}
{% block content %} {% block content %}
<div class="text-center mb-4"> <div class="text-center mb-4">
<p class="mb-0">Enter your account email address in the form below. If {% blocktrans %}<p class="mb-0">Enter your account email address in the
the address is valid, you will receive instructions for resetting your form below. If the address is valid, you will receive instructions for
password.</p> resetting your password.</p>{% endblocktrans %}
</div> </div>
<form method="post"> <form method="post">
@ -24,7 +24,7 @@
</div> </div>
<button class="btn btn-primary w-100 fade-in" type="submit" name="reset"> <button class="btn btn-primary w-100 fade-in" type="submit" name="reset">
Reset Password {% trans "Reset Password" %}
</button> </button>
</form> </form>

View File

@ -7,6 +7,7 @@ from django.contrib.auth.models import User
from django.contrib.messages.views import SuccessMessageMixin from django.contrib.messages.views import SuccessMessageMixin
from django.shortcuts import redirect, render from django.shortcuts import redirect, render
from django.urls import reverse, reverse_lazy from django.urls import reverse, reverse_lazy
from django.utils.translation import gettext as _
from django.views.generic import View from django.views.generic import View
from django.views.generic.base import TemplateView, RedirectView from django.views.generic.base import TemplateView, RedirectView
from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.views.generic.edit import CreateView, UpdateView, DeleteView
@ -51,7 +52,7 @@ class UserAdd(StaffOnlyMixin, PermissionRequired403Mixin, SuccessMessageMixin,
permission_required = ('admin.add_user',) permission_required = ('admin.add_user',)
form_class = forms.UserAddForm form_class = forms.UserAddForm
success_url = reverse_lazy('babybuddy:user-list') success_url = reverse_lazy('babybuddy:user-list')
success_message = 'User %(username)s added!' success_message = _('User %(username)s added!')
class UserUpdate(StaffOnlyMixin, PermissionRequired403Mixin, class UserUpdate(StaffOnlyMixin, PermissionRequired403Mixin,
@ -61,7 +62,7 @@ class UserUpdate(StaffOnlyMixin, PermissionRequired403Mixin,
permission_required = ('admin.change_user',) permission_required = ('admin.change_user',)
form_class = forms.UserUpdateForm form_class = forms.UserUpdateForm
success_url = reverse_lazy('babybuddy:user-list') success_url = reverse_lazy('babybuddy:user-list')
success_message = 'User %(username)s updated.' success_message = _('User %(username)s updated.')
class UserDelete(StaffOnlyMixin, PermissionRequired403Mixin, class UserDelete(StaffOnlyMixin, PermissionRequired403Mixin,
@ -94,7 +95,7 @@ class UserPassword(LoginRequiredMixin, View):
if form.is_valid(): if form.is_valid():
user = form.save() user = form.save()
update_session_auth_hash(request, user) update_session_auth_hash(request, user)
messages.success(request, 'Password updated.') messages.success(request, _('Password updated.'))
return render(request, self.template_name, {'form': form}) return render(request, self.template_name, {'form': form})
@ -104,7 +105,7 @@ class UserResetAPIKey(LoginRequiredMixin, View):
""" """
def get(self, request): def get(self, request):
request.user.settings.api_key(reset=True) request.user.settings.api_key(reset=True)
messages.success(request, 'User API key regenerated.') messages.success(request, _('User API key regenerated.'))
return redirect('babybuddy:user-settings') return redirect('babybuddy:user-settings')
@ -137,7 +138,7 @@ class UserSettings(LoginRequiredMixin, View):
user.settings = user_settings user.settings = user_settings
user.save() user.save()
set_language(request) set_language(request)
messages.success(request, 'Settings saved!') messages.success(request, _('Settings saved!'))
return redirect('babybuddy:user-settings') return redirect('babybuddy:user-settings')
return render(request, self.template_name, { return render(request, self.template_name, {
'user_form': form_user, 'user_form': form_user,