Skip to content

Commit

Permalink
Fix missing translations
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean Cochrane (Lead developer, DataMade) committed Apr 27, 2020
1 parent 940dc0b commit ca973b1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
3 changes: 2 additions & 1 deletion sfm_pc/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import ugettext as _
from complex_fields.models import ComplexFieldContainer


Expand Down Expand Up @@ -26,7 +27,7 @@ def get_verbose_field_name(cls, field_name):
the verbose name for Person.aliases would be 'Other names'.
"""
field_model = cls.get_field_model(field_name)
return field_model.field_name
return _(field_model.field_name)

@classmethod
def get_shortcode(cls, field_name):
Expand Down
31 changes: 31 additions & 0 deletions source/migrations/0038_add_verbose_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2020-04-27 16:02
from __future__ import unicode_literals

from django.db import migrations
import source.fields


class Migration(migrations.Migration):

dependencies = [
('source', '0037_source_metadata'),
]

operations = [
migrations.AlterField(
model_name='source',
name='publication',
field=source.fields.TextField(null=True, verbose_name='publication'),
),
migrations.AlterField(
model_name='source',
name='publication_country',
field=source.fields.CharField(max_length=1000, null=True, verbose_name='publication country'),
),
migrations.AlterField(
model_name='source',
name='title',
field=source.fields.TextField(verbose_name='title'),
),
]
27 changes: 16 additions & 11 deletions source/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,54 +37,59 @@ def get_spreadsheet_field_name(cls, field_name):

@classmethod
def get_verbose_field_name(cls, field_name):
return cls._meta.get_field(field_name).verbose_name.title()
return _(cls._meta.get_field(field_name).verbose_name).title()


@reversion.register(follow=['accesspoint_set'])
class Source(models.Model, GetSpreadsheetFieldNameMixin, VersionsMixin):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4)
title = source_fields.TextField(spreadsheet_field_name='source:title')
title = source_fields.TextField(verbose_name=_("title"), spreadsheet_field_name='source:title')
type = source_fields.CharField(max_length=1000, null=True, blank=True, spreadsheet_field_name='source:type')
author = source_fields.CharField(max_length=1000, null=True, blank=True, spreadsheet_field_name='source:author')
publication = source_fields.TextField(null=True, spreadsheet_field_name='source:publication_name')
publication_country = source_fields.CharField(max_length=1000, null=True, spreadsheet_field_name='source:publication_country')
publication = source_fields.TextField(null=True, verbose_name=_("publication"), spreadsheet_field_name='source:publication_name')
publication_country = source_fields.CharField(
max_length=1000,
verbose_name=_("publication country"),
null=True,
spreadsheet_field_name='source:publication_country'
)
# We store both date and timestamp fields for the following values because
# sometimes sources have partial dates and sometimes they have full
# timestamps. In practice, these fields should be treated as mutually
# exclusive, and the get_date() methods should be used to retrieve
# the canonical value.
published_date = source_fields.ApproximateDateField(
verbose_name="publication date",
verbose_name=_("publication date"),
blank=True,
default='',
spreadsheet_field_name='source:published_timestamp'
)
published_timestamp = source_fields.DateTimeField(
verbose_name="publication timestamp",
verbose_name=_("publication timestamp"),
blank=True,
null=True,
spreadsheet_field_name='source:published_timestamp'
)
created_date = source_fields.ApproximateDateField(
verbose_name="creation date",
verbose_name=_("creation date"),
blank=True,
default='',
spreadsheet_field_name='source:created_timestamp'
)
created_timestamp = source_fields.DateTimeField(
verbose_name="publication timestamp",
verbose_name=_("publication timestamp"),
blank=True,
null=True,
spreadsheet_field_name='source:created_timestamp'
)
uploaded_date = source_fields.ApproximateDateField(
verbose_name="upload date",
verbose_name=_("upload date"),
blank=True,
default='',
spreadsheet_field_name='source:uploaded_timestamp'
)
uploaded_timestamp = source_fields.DateTimeField(
verbose_name="publication timestamp",
verbose_name=_("publication timestamp"),
blank=True,
null=True,
spreadsheet_field_name='source:uploaded_timestamp'
Expand Down Expand Up @@ -164,7 +169,7 @@ class AccessPoint(models.Model, GetSpreadsheetFieldNameMixin, VersionsMixin):
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4)
type = source_fields.CharField(max_length=1000, null=True, blank=True, spreadsheet_field_name='source:access_point_type')
trigger = source_fields.CharField(max_length=255, null=True, blank=True, spreadsheet_field_name='source:access_point_trigger')
accessed_on = source_fields.DateField(null=True, verbose_name='access date', spreadsheet_field_name='source:accessed_timestamp')
accessed_on = source_fields.DateField(null=True, verbose_name=_("access date"), spreadsheet_field_name='source:accessed_timestamp')
archive_url = source_fields.URLField(max_length=1000, null=True, spreadsheet_field_name='source:archive_url')
source = models.ForeignKey(Source, null=True, to_field='uuid')

Expand Down
2 changes: 1 addition & 1 deletion templates/partials/pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<div class="col-sm-12">
<p>
<small>
<strong>Results per page:</strong>
<strong>{% trans "Results per page:" %}</strong>
{% for result_count in results_per_page %}
{% if hit_count >= result_count %}
{% if not forloop.first %}|{% endif %}
Expand Down

0 comments on commit ca973b1

Please sign in to comment.