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.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import User
from django.utils.translation import gettext_lazy as _
from babybuddy import models
class SettingsInline(admin.StackedInline):
model = models.Settings
verbose_name_plural = 'Settings'
verbose_name = _('Settings')
verbose_name_plural = _('Settings')
can_delete = False
fieldsets = (
('Dashboard', {
(_('Dashboard'), {
'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.dispatch import receiver
from django.utils.timezone import timedelta
from django.utils.translation import gettext_lazy as _
from rest_framework.authtoken.models import Token
@ -11,22 +12,22 @@ from rest_framework.authtoken.models import Token
class Settings(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
dashboard_refresh_rate = models.DurationField(
verbose_name='Refresh rate',
help_text='This setting will only be used when a browser does not '
'support refresh on focus.',
verbose_name=_('Refresh rate'),
help_text=_('This setting will only be used when a browser does not '
'support refresh on focus.'),
blank=True,
null=True,
default=timedelta(minutes=1),
choices=[
(None, 'disabled'),
(timedelta(minutes=1), '1 min.'),
(timedelta(minutes=2), '2 min.'),
(timedelta(minutes=3), '3 min.'),
(timedelta(minutes=4), '4 min.'),
(timedelta(minutes=5), '5 min.'),
(timedelta(minutes=10), '10 min.'),
(timedelta(minutes=15), '15 min.'),
(timedelta(minutes=30), '30 min.'),
(None, _('disabled')),
(timedelta(minutes=1), _('1 min.')),
(timedelta(minutes=2), _('2 min.')),
(timedelta(minutes=3), _('3 min.')),
(timedelta(minutes=4), _('4 min.')),
(timedelta(minutes=5), _('5 min.')),
(timedelta(minutes=10), _('10 min.')),
(timedelta(minutes=15), _('15 min.')),
(timedelta(minutes=30), _('30 min.')),
])
def __str__(self):

View File

@ -1,15 +1,15 @@
{% 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 %}
<li class="breadcrumb-item active" aria-current="page">Permission Denied</li>
<li class="breadcrumb-item active" aria-current="page">{% trans "Permission Denied" %}</li>
{% endblock %}
{% block content %}
<div class="alert alert-danger" role="alert">
You do not have permission to access this resource. Contact a site
administrator for assistance.
{% blocktrans %}You do not have permission to access this resource.
Contact a site administrator for assistance.{% endblocktrans %}
</div>
{% endblock %}

View File

@ -1,4 +1,4 @@
{% load static %}
{% load i18n static %}
<!DOCTYPE html>
<html lang="en">
@ -31,7 +31,7 @@
{% block breadcrumb_nav %}
<nav aria-label="breadcrumb" role="navigation">
<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 %}
</ol>
</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 %}">
<div class="form-group form-row">
@ -15,8 +15,8 @@
</div>
{% endfor %}
<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>
<a href="{{ request.path }}" class="btn btn-sm btn-error">Reset</a>
<button type="submit" class="btn btn-sm btn-primary mr-2">{% trans "Filter" %}</button>
<a href="{{ request.path }}" class="btn btn-sm btn-error">{% trans "Reset" %}</a>
</div>
</div>
<input type="hidden" name="filtered" value="1"/>
@ -29,6 +29,6 @@
role="button"
aria-expanded="false"
aria-controls="filter_form">
Filters
{% trans "Filters" %}
</a>
</p>

View File

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

View File

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

View File

@ -1,5 +1,5 @@
{% extends 'babybuddy/base.html' %}
{% load babybuddy_tags static timers %}
{% load babybuddy_tags i18n static timers %}
{% block nav %}
<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">
{% if perms.core.add_diaperchange %}
<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>
{% endif %}
{% if perms.core.add_feeding %}
<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>
{% endif %}
{% if perms.core.add_note %}
<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>
{% endif %}
{% if perms.core.add_sleep %}
<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>
{% endif %}
{% if perms.core.add_tummytime %}
<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>
{% endif %}
{% if perms.core.add_weight %}
<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>
{% endif %}
</div>
@ -66,7 +72,8 @@
<ul class="navbar-nav mr-auto">
<li class="nav-item{% if request.path == '/' %} active{% endif %}">
<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>
</li>
@ -76,40 +83,51 @@
href="#"
data-toggle="dropdown"
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">
{% if perms.core.view_child %}
<a class="dropdown-item{% if request.path == '/children/' %} active{% endif %}"
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>
{% endif %}
{% if perms.core.add_child %}
<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 %}
{% if perms.core.view_note %}
<a class="dropdown-item{% if request.path == '/notes/' %} active{% endif %}"
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>
{% endif %}
{% if perms.core.add_note %}
<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 %}
{% if perms.core.view_weight %}
<a class="dropdown-item{% if request.path == '/weight/' %} active{% endif %}"
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>
{% endif %}
{% if perms.core.add_weight %}
<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 %}
</div>
@ -121,43 +139,61 @@
href="#"
data-toggle="dropdown"
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">
{% if perms.core.view_diaperchange %}
<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 %}
{% if perms.core.add_diaperchange %}
<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 %}
{% if perms.core.view_feeding %}
<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 %}
{% if perms.core.add_diaperchange %}
<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 %}
{% if perms.core.view_sleep %}
<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 %}
{% if perms.core.add_sleep %}
<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 %}
{% if perms.core.view_tummytime %}
<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 %}
{% if perms.core.add_tummytime %}
<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 %}
</div>
@ -179,29 +215,29 @@
aria-expanded="false"><i class="icon icon-user" aria-hidden="true"></i> {{ request.user }}
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="nav-user-menu-link">
<h6 class="dropdown-header">User</h6>
<a href="{% url 'babybuddy:user-settings' %}" class="dropdown-item">Settings</a>
<a href="{% url 'babybuddy:user-password' %}" class="dropdown-item">Password</a>
<a href="{% url 'babybuddy:logout' %}" class="dropdown-item">Logout</a>
<h6 class="dropdown-header">Site</h6>
<h6 class="dropdown-header">{% trans "User" %}</h6>
<a href="{% url 'babybuddy:user-settings' %}" class="dropdown-item">{% trans "Settings" %}</a>
<a href="{% url 'babybuddy:user-password' %}" class="dropdown-item">{% trans "Password" %}</a>
<a href="{% url 'babybuddy:logout' %}" class="dropdown-item">{% trans "Logout" %}</a>
<h6 class="dropdown-header">{% trans "Site" %}</h6>
<a href="{% url 'api:api-root' %}"
class="dropdown-item"
target="_blank">API Browser</a>
target="_blank">{% trans "API Browser" %}</a>
{% 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' %}"
class="dropdown-item"
target="_blank">Backend Admin</a>
target="_blank">{% trans "Backend Admin" %}</a>
{% endif %}
<h6 class="dropdown-header">Support</h6>
<h6 class="dropdown-header">{% trans "Support" %}</h6>
<a href="https://github.com/cdubz/babybuddy"
class="dropdown-item"
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"
class="dropdown-item"
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>
</div>
</li>

View File

@ -1,4 +1,4 @@
{% load babybuddy_tags %}
{% load i18n babybuddy_tags %}
{% if is_paginated %}
<nav aria-label="Page navigation">
@ -8,7 +8,7 @@
<li class="page-item">
<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>
<span class="sr-only">Previous</span>
<span class="sr-only">{% trans "Previous" %}</span>
</a>
</li>
{% endif %}
@ -25,7 +25,7 @@
<li class="page-item">
<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>
<span class="sr-only">Next</span>
<span class="sr-only">{% trans "Next" %}</span>
</a>
</li>
{% endif %}

View File

@ -1,19 +1,19 @@
{% extends 'babybuddy/page.html' %}
{% load widget_tweaks %}
{% load i18n widget_tweaks %}
{% block title %}Delete User{% endblock %}
{% block title %}{% trans "Delete User" %}{% endblock %}
{% 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 active" aria-current="page">Delete</li>
<li class="breadcrumb-item active" aria-current="page">{% trans "Delete" %}</li>
{% endblock %}
{% block content %}
<form role="form" method="post">
{% 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" />
<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>
{% endblock %}

View File

@ -1,28 +1,29 @@
{% extends 'babybuddy/page.html' %}
{% load i18n %}
{% block title %}
{% if object %}
{{ object }}
{% else %}
Create User
{% trans "Create User" %}
{% endif %}
{% endblock %}
{% 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 %}
<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 %}
<li class="breadcrumb-item active" aria-current="page">Create User</li>
<li class="breadcrumb-item active" aria-current="page">{% trans "Create User" %}</li>
{% endif %}
{% endblock %}
{% block content %}
{% if object %}
<h1>Update <span class="text-info">{{ object }}</span></h1>
{% blocktrans %}<h1>Update <span class="text-info">{{ object }}</span></h1>{% endblocktrans %}
{% else %}
<h1>Create User</h1>
<h1>{% trans "Create User" %}</h1>
{% endif %}
{% include 'babybuddy/form.html' %}
{% endblock %}

View File

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

View File

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

View File

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

View File

@ -1,18 +1,18 @@
{% extends 'babybuddy/page.html' %}
{% load widget_tweaks %}
{% load i18n widget_tweaks %}
{% block title %}Welcome!{% endblock %}
{% block title %}{% trans "Welcome!" %}{% endblock %}
{% block breadcrumbs %}
<li class="breadcrumb-item active" aria-current="page">Welcome!</li>
<li class="breadcrumb-item active" aria-current="page">{% trans "Welcome!" %}</li>
{% endblock %}
{% block content %}
<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">
Learn about and predict baby's needs without (<em>as much</em>)
guess work by using Baby Buddy to track &mdash;
{% blocktrans %}Learn about and predict baby's needs without
(<em>as much</em>) guess work by using Baby Buddy to track &mdash;{% endblocktrans %}
</p>
<hr class="my-4">
<div class="card-deck">
@ -21,7 +21,7 @@
<i class="icon icon-2x icon-diaperchange" aria-hidden="true"></i>
</div>
<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 class="card card-feeding">
@ -29,7 +29,7 @@
<i class="icon icon-2x icon-feeding" aria-hidden="true"></i>
</div>
<div class="card-body">
<h3 class="card-title text-center">Feedings</h3>
<h3 class="card-title text-center">{% trans "Feedings" %}</h3>
</div>
</div>
<div class="card card-sleep">
@ -37,7 +37,7 @@
<i class="icon icon-2x icon-sleep" aria-hidden="true"></i>
</div>
<div class="card-body">
<h3 class="card-title text-center">Sleep</h3>
<h3 class="card-title text-center">{% trans "Sleep" %}</h3>
</div>
</div>
<div class="card card-tummytime">
@ -45,23 +45,23 @@
<i class="icon icon-2x icon-tummytime" aria-hidden="true"></i>
</div>
<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>
<hr class="my-4">
<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
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
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 class="text-center">
{% if perms.core.add_child %}
<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>
{% endif %}
</p>

View File

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

View File

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

View File

@ -1,7 +1,7 @@
{% 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 %}
<form method="post">
@ -9,13 +9,13 @@
{% if form.errors %}
<div class="alert alert-danger">
<p class="mb-0"><strong>Oh snap!</strong> The two passwords
did not match. Please try again.</p>
{% blocktrans %}<p class="mb-0"><strong>Oh snap!</strong> The
two passwords did not match. Please try again.</p>{% endblocktrans %}
</div>
{% endif %}
<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>
<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' %}
</div>
<label class="sr-only" for="password2-input-group">
{{ form.new_password2.label }}
</label>
@ -40,7 +39,7 @@
</div>
<button class="btn btn-primary w-100 fade-in" type="submit" name="reset">
Reset Password
{% trans "Reset Password" %}
</button>
</form>

View File

@ -1,15 +1,16 @@
{% extends "registration/base.html" %}
{% load i18n %}
{% block title %}Reset Email Sent{% endblock %}
{% block title %}{% trans "Reset Email Sent" %}{% endblock %}
{% block content %}
<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
should receive them shortly.</p>
<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
folder.</p>
folder.</p>{% endblocktrans %}
</div>
{% endblock %}

View File

@ -1,13 +1,13 @@
{% 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 %}
<div class="text-center mb-4">
<p class="mb-0">Enter your account email address in the form below. If
the address is valid, you will receive instructions for resetting your
password.</p>
{% blocktrans %}<p class="mb-0">Enter your account email address in the
form below. If the address is valid, you will receive instructions for
resetting your password.</p>{% endblocktrans %}
</div>
<form method="post">
@ -24,7 +24,7 @@
</div>
<button class="btn btn-primary w-100 fade-in" type="submit" name="reset">
Reset Password
{% trans "Reset Password" %}
</button>
</form>

View File

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