From 35d36d946272bed06a3d7c7cd4e5b71b613e7a4f Mon Sep 17 00:00:00 2001 From: Mike Hansen Date: Mon, 23 Sep 2019 08:31:21 -0700 Subject: [PATCH] Refs #30585 -- Updated project templates and tests to use (block)translate tags. --- django/contrib/admin/templates/admin/404.html | 6 +- django/contrib/admin/templates/admin/500.html | 10 +- .../admin/templates/admin/actions.html | 6 +- .../admin/templates/admin/app_index.html | 2 +- .../templates/admin/auth/user/add_form.html | 4 +- .../admin/auth/user/change_password.html | 10 +- .../contrib/admin/templates/admin/base.html | 12 +- .../admin/templates/admin/change_form.html | 6 +- .../admin/change_form_object_tools.html | 4 +- .../admin/templates/admin/change_list.html | 6 +- .../admin/change_list_object_tools.html | 2 +- .../templates/admin/change_list_results.html | 6 +- .../templates/admin/delete_confirmation.html | 16 +- .../admin/delete_selected_confirmation.html | 16 +- .../templates/admin/edit_inline/stacked.html | 4 +- .../templates/admin/edit_inline/tabular.html | 6 +- .../contrib/admin/templates/admin/filter.html | 2 +- .../admin/includes/object_delete_summary.html | 2 +- .../contrib/admin/templates/admin/index.html | 18 +- .../admin/templates/admin/invalid_setup.html | 4 +- .../contrib/admin/templates/admin/login.html | 10 +- .../admin/templates/admin/object_history.html | 12 +- .../admin/templates/admin/pagination.html | 4 +- .../admin/templates/admin/popup_response.html | 2 +- .../admin/templates/admin/search_form.html | 4 +- .../admin/templates/admin/submit_line.html | 12 +- .../admin/widgets/related_widget_wrapper.html | 12 +- .../templates/registration/logged_out.html | 6 +- .../registration/password_change_done.html | 8 +- .../registration/password_change_form.html | 12 +- .../registration/password_reset_complete.html | 8 +- .../registration/password_reset_confirm.html | 14 +- .../registration/password_reset_done.html | 8 +- .../registration/password_reset_email.html | 10 +- .../registration/password_reset_form.html | 10 +- .../templates/admin_doc/bookmarklets.html | 16 +- .../admindocs/templates/admin_doc/index.html | 28 +- .../templates/admin_doc/missing_docutils.html | 12 +- .../templates/admin_doc/model_detail.html | 26 +- .../templates/admin_doc/model_index.html | 12 +- .../templates/admin_doc/template_detail.html | 16 +- .../admin_doc/template_filter_index.html | 12 +- .../admin_doc/template_tag_index.html | 12 +- .../templates/admin_doc/view_detail.html | 14 +- .../templates/admin_doc/view_index.html | 22 +- .../registration/password_reset_subject.txt | 2 +- .../gis/templates/gis/admin/openlayers.html | 4 +- .../contrib/gis/templates/gis/openlayers.html | 4 +- django/template/defaulttags.py | 4 +- django/templatetags/i18n.py | 30 +-- django/views/static.py | 4 +- django/views/templates/default_urlconf.html | 20 +- .../admin/admin_views/article/actions.html | 2 +- .../article/change_form_object_tools.html | 2 +- .../article/change_list_object_tools.html | 2 +- .../article/change_list_results.html | 6 +- .../admin_views/article/date_hierarchy.html | 2 +- .../admin/admin_views/article/pagination.html | 4 +- .../admin_views/article/search_form.html | 4 +- .../admin_views/article/submit_line.html | 2 +- tests/i18n/commands/ignore_dir/ignored.html | 2 +- tests/i18n/commands/templates/comments.thtml | 20 +- tests/i18n/commands/templates/plural.djtpl | 2 +- .../commands/templates/subdir/ignored.html | 2 +- .../templates/template_with_error.tpl | 4 +- tests/i18n/commands/templates/test.html | 81 +++--- .../i18n/commands/templates/xxx_ignored.html | 2 +- .../sampleproject/templates/percents.html | 16 +- tests/i18n/sampleproject/update_catalogs.py | 3 +- tests/i18n/test_extraction.py | 38 +-- tests/i18n/test_percents.py | 44 ++-- .../syntax_tests/i18n/test_blocktranslate.py | 249 ++++++++++-------- .../syntax_tests/i18n/test_translate.py | 78 +++--- .../syntax_tests/test_invalid_string.py | 2 +- 74 files changed, 547 insertions(+), 532 deletions(-) diff --git a/django/contrib/admin/templates/admin/404.html b/django/contrib/admin/templates/admin/404.html index 57b6d33780..19f07492cb 100644 --- a/django/contrib/admin/templates/admin/404.html +++ b/django/contrib/admin/templates/admin/404.html @@ -1,12 +1,12 @@ {% extends "admin/base_site.html" %} {% load i18n %} -{% block title %}{% trans 'Page not found' %}{% endblock %} +{% block title %}{% translate 'Page not found' %}{% endblock %} {% block content %} -

{% trans 'Page not found' %}

+

{% translate 'Page not found' %}

-

{% trans 'We’re sorry, but the requested page could not be found.' %}

+

{% translate 'We’re sorry, but the requested page could not be found.' %}

{% endblock %} diff --git a/django/contrib/admin/templates/admin/500.html b/django/contrib/admin/templates/admin/500.html index 89a6f65b38..b5ac5c3b6c 100644 --- a/django/contrib/admin/templates/admin/500.html +++ b/django/contrib/admin/templates/admin/500.html @@ -3,15 +3,15 @@ {% block breadcrumbs %} {% endblock %} -{% block title %}{% trans 'Server error (500)' %}{% endblock %} +{% block title %}{% translate 'Server error (500)' %}{% endblock %} {% block content %} -

{% trans 'Server Error (500)' %}

-

{% trans 'There’s been an error. It’s been reported to the site administrators via email and should be fixed shortly. Thanks for your patience.' %}

+

{% translate 'Server Error (500)' %}

+

{% translate 'There’s been an error. It’s been reported to the site administrators via email and should be fixed shortly. Thanks for your patience.' %}

{% endblock %} diff --git a/django/contrib/admin/templates/admin/actions.html b/django/contrib/admin/templates/admin/actions.html index ef2232e13f..b912d37396 100644 --- a/django/contrib/admin/templates/admin/actions.html +++ b/django/contrib/admin/templates/admin/actions.html @@ -5,7 +5,7 @@ {% for field in action_form %}{% if field.label %}{% endif %}{% endfor %} {% endblock %} {% block actions-submit %} - + {% endblock %} {% block actions-counter %} {% if actions_selection_counter %} @@ -13,9 +13,9 @@ {% if cl.result_count != cl.result_list|length %} {{ selection_note_all }} - {% blocktrans with cl.result_count as total_count %}Select all {{ total_count }} {{ module_name }}{% endblocktrans %} + {% blocktranslate with cl.result_count as total_count %}Select all {{ total_count }} {{ module_name }}{% endblocktranslate %} - {% trans "Clear selection" %} + {% translate "Clear selection" %} {% endif %} {% endif %} {% endblock %} diff --git a/django/contrib/admin/templates/admin/app_index.html b/django/contrib/admin/templates/admin/app_index.html index 6868b497dd..886bf6ca00 100644 --- a/django/contrib/admin/templates/admin/app_index.html +++ b/django/contrib/admin/templates/admin/app_index.html @@ -6,7 +6,7 @@ {% if not is_popup %} {% block breadcrumbs %} diff --git a/django/contrib/admin/templates/admin/base.html b/django/contrib/admin/templates/admin/base.html index 2cf5137070..8d6425ad04 100644 --- a/django/contrib/admin/templates/admin/base.html +++ b/django/contrib/admin/templates/admin/base.html @@ -32,23 +32,23 @@ {% if has_permission %}
{% block welcome-msg %} - {% trans 'Welcome,' %} + {% translate 'Welcome,' %} {% firstof user.get_short_name user.get_username %}. {% endblock %} {% block userlinks %} {% if site_url %} - {% trans 'View site' %} / + {% translate 'View site' %} / {% endif %} {% if user.is_active and user.is_staff %} {% url 'django-admindocs-docroot' as docsroot %} {% if docsroot %} - {% trans 'Documentation' %} / + {% translate 'Documentation' %} / {% endif %} {% endif %} {% if user.has_usable_password %} - {% trans 'Change password' %} / + {% translate 'Change password' %} / {% endif %} - {% trans 'Log out' %} + {% translate 'Log out' %} {% endblock %}
{% endif %} @@ -58,7 +58,7 @@ {% block breadcrumbs %} {% endblock %} diff --git a/django/contrib/admin/templates/admin/change_form.html b/django/contrib/admin/templates/admin/change_form.html index f99936d21f..f1f317806d 100644 --- a/django/contrib/admin/templates/admin/change_form.html +++ b/django/contrib/admin/templates/admin/change_form.html @@ -15,10 +15,10 @@ {% if not is_popup %} {% block breadcrumbs %} {% endblock %} {% endif %} @@ -40,7 +40,7 @@ {% if save_on_top %}{% block submit_buttons_top %}{% submit_row %}{% endblock %}{% endif %} {% if errors %}

- {% if errors|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %} + {% if errors|length == 1 %}{% translate "Please correct the error below." %}{% else %}{% translate "Please correct the errors below." %}{% endif %}

{{ adminform.form.non_field_errors }} {% endif %} diff --git a/django/contrib/admin/templates/admin/change_form_object_tools.html b/django/contrib/admin/templates/admin/change_form_object_tools.html index 32487493a2..067ae83761 100644 --- a/django/contrib/admin/templates/admin/change_form_object_tools.html +++ b/django/contrib/admin/templates/admin/change_form_object_tools.html @@ -2,7 +2,7 @@ {% block object-tools-items %}
  • {% url opts|admin_urlname:'history' original.pk|admin_urlquote as history_url %} - {% trans "History" %} + {% translate "History" %}
  • -{% if has_absolute_url %}
  • {% trans "View on site" %}
  • {% endif %} +{% if has_absolute_url %}
  • {% translate "View on site" %}
  • {% endif %} {% endblock %} diff --git a/django/contrib/admin/templates/admin/change_list.html b/django/contrib/admin/templates/admin/change_list.html index e0dc285924..8b275362af 100644 --- a/django/contrib/admin/templates/admin/change_list.html +++ b/django/contrib/admin/templates/admin/change_list.html @@ -28,7 +28,7 @@ {% if not is_popup %} {% block breadcrumbs %} @@ -48,7 +48,7 @@ {% endblock %} {% if cl.formset and cl.formset.errors %}

    - {% if cl.formset.total_error_count == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %} + {% if cl.formset.total_error_count == 1 %}{% translate "Please correct the error below." %}{% else %}{% translate "Please correct the errors below." %}{% endif %}

    {{ cl.formset.non_form_errors }} {% endif %} @@ -59,7 +59,7 @@ {% block filters %} {% if cl.has_filters %}
    -

    {% trans 'Filter' %}

    +

    {% translate 'Filter' %}

    {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
    {% endif %} diff --git a/django/contrib/admin/templates/admin/change_list_object_tools.html b/django/contrib/admin/templates/admin/change_list_object_tools.html index 5d6d458276..11cc6fa4ba 100644 --- a/django/contrib/admin/templates/admin/change_list_object_tools.html +++ b/django/contrib/admin/templates/admin/change_list_object_tools.html @@ -5,7 +5,7 @@
  • {% url cl.opts|admin_urlname:'add' as add_url %} - {% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %} + {% blocktranslate with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktranslate %}
  • {% endif %} diff --git a/django/contrib/admin/templates/admin/change_list_results.html b/django/contrib/admin/templates/admin/change_list_results.html index 9b97b5b4f7..a4a2618e04 100644 --- a/django/contrib/admin/templates/admin/change_list_results.html +++ b/django/contrib/admin/templates/admin/change_list_results.html @@ -14,9 +14,9 @@ {% if header.sortable %} {% if header.sort_priority > 0 %}
    - - {% if num_sorted_fields > 1 %}{{ header.sort_priority }}{% endif %} - + + {% if num_sorted_fields > 1 %}{{ header.sort_priority }}{% endif %} +
    {% endif %} {% endif %} diff --git a/django/contrib/admin/templates/admin/delete_confirmation.html b/django/contrib/admin/templates/admin/delete_confirmation.html index 4a1c065cb2..bfece58ada 100644 --- a/django/contrib/admin/templates/admin/delete_confirmation.html +++ b/django/contrib/admin/templates/admin/delete_confirmation.html @@ -11,41 +11,41 @@ {% block breadcrumbs %} {% endblock %} {% block content %} {% if perms_lacking %} -

    {% blocktrans with escaped_object=object %}Deleting the {{ object_name }} '{{ escaped_object }}' would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:{% endblocktrans %}

    +

    {% blocktranslate with escaped_object=object %}Deleting the {{ object_name }} '{{ escaped_object }}' would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:{% endblocktranslate %}

    {% elif protected %} -

    {% blocktrans with escaped_object=object %}Deleting the {{ object_name }} '{{ escaped_object }}' would require deleting the following protected related objects:{% endblocktrans %}

    +

    {% blocktranslate with escaped_object=object %}Deleting the {{ object_name }} '{{ escaped_object }}' would require deleting the following protected related objects:{% endblocktranslate %}

    {% else %} -

    {% blocktrans with escaped_object=object %}Are you sure you want to delete the {{ object_name }} "{{ escaped_object }}"? All of the following related items will be deleted:{% endblocktrans %}

    +

    {% blocktranslate with escaped_object=object %}Are you sure you want to delete the {{ object_name }} "{{ escaped_object }}"? All of the following related items will be deleted:{% endblocktranslate %}

    {% include "admin/includes/object_delete_summary.html" %} -

    {% trans "Objects" %}

    +

    {% translate "Objects" %}

    {% csrf_token %}
    {% if is_popup %}{% endif %} {% if to_field %}{% endif %} - - {% trans "No, take me back" %} + + {% translate "No, take me back" %}
    {% endif %} diff --git a/django/contrib/admin/templates/admin/delete_selected_confirmation.html b/django/contrib/admin/templates/admin/delete_selected_confirmation.html index bab4cd31c2..346d280738 100644 --- a/django/contrib/admin/templates/admin/delete_selected_confirmation.html +++ b/django/contrib/admin/templates/admin/delete_selected_confirmation.html @@ -11,32 +11,32 @@ {% block breadcrumbs %} {% endblock %} {% block content %} {% if perms_lacking %} -

    {% blocktrans %}Deleting the selected {{ objects_name }} would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:{% endblocktrans %}

    +

    {% blocktranslate %}Deleting the selected {{ objects_name }} would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:{% endblocktranslate %}

    {% elif protected %} -

    {% blocktrans %}Deleting the selected {{ objects_name }} would require deleting the following protected related objects:{% endblocktrans %}

    +

    {% blocktranslate %}Deleting the selected {{ objects_name }} would require deleting the following protected related objects:{% endblocktranslate %}

    {% else %} -

    {% blocktrans %}Are you sure you want to delete the selected {{ objects_name }}? All of the following objects and their related items will be deleted:{% endblocktrans %}

    +

    {% blocktranslate %}Are you sure you want to delete the selected {{ objects_name }}? All of the following objects and their related items will be deleted:{% endblocktranslate %}

    {% include "admin/includes/object_delete_summary.html" %} -

    {% trans "Objects" %}

    +

    {% translate "Objects" %}

    {% for deletable_object in deletable_objects %} {% endfor %} @@ -47,8 +47,8 @@ {% endfor %} - - {% trans "No, take me back" %} + + {% translate "No, take me back" %} {% endif %} diff --git a/django/contrib/admin/templates/admin/edit_inline/stacked.html b/django/contrib/admin/templates/admin/edit_inline/stacked.html index d9c27b1578..0fe7a0c0a2 100644 --- a/django/contrib/admin/templates/admin/edit_inline/stacked.html +++ b/django/contrib/admin/templates/admin/edit_inline/stacked.html @@ -9,9 +9,9 @@ {{ inline_admin_formset.formset.non_form_errors }} {% for inline_admin_form in inline_admin_formset %}
    -

    {{ inline_admin_formset.opts.verbose_name|capfirst }}: {% if inline_admin_form.original %}{{ inline_admin_form.original }}{% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %} {% if inline_admin_formset.has_change_permission %}{% trans "Change" %}{% else %}{% trans "View" %}{% endif %}{% endif %} +

    {{ inline_admin_formset.opts.verbose_name|capfirst }}: {% if inline_admin_form.original %}{{ inline_admin_form.original }}{% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %} {% if inline_admin_formset.has_change_permission %}{% translate "Change" %}{% else %}{% translate "View" %}{% endif %}{% endif %} {% else %}#{{ forloop.counter }}{% endif %} - {% if inline_admin_form.show_url %}{% trans "View on site" %}{% endif %} + {% if inline_admin_form.show_url %}{% translate "View on site" %}{% endif %} {% if inline_admin_formset.formset.can_delete and inline_admin_formset.has_delete_permission and inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }} {{ inline_admin_form.deletion_field.label_tag }}{% endif %}

    {% if inline_admin_form.form.non_field_errors %}{{ inline_admin_form.form.non_field_errors }}{% endif %} diff --git a/django/contrib/admin/templates/admin/edit_inline/tabular.html b/django/contrib/admin/templates/admin/edit_inline/tabular.html index 261592af6e..94f97d94b6 100644 --- a/django/contrib/admin/templates/admin/edit_inline/tabular.html +++ b/django/contrib/admin/templates/admin/edit_inline/tabular.html @@ -17,7 +17,7 @@ {% endif %} {% endfor %} - {% if inline_admin_formset.formset.can_delete and inline_admin_formset.has_delete_permission %}{% trans "Delete?" %}{% endif %} + {% if inline_admin_formset.formset.can_delete and inline_admin_formset.has_delete_permission %}{% translate "Delete?" %}{% endif %} @@ -31,9 +31,9 @@ {% if inline_admin_form.original or inline_admin_form.show_url %}

    {% if inline_admin_form.original %} {{ inline_admin_form.original }} - {% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %}{% if inline_admin_formset.has_change_permission %}{% trans "Change" %}{% else %}{% trans "View" %}{% endif %}{% endif %} + {% if inline_admin_form.model_admin.show_change_link and inline_admin_form.model_admin.has_registered_model %}{% if inline_admin_formset.has_change_permission %}{% translate "Change" %}{% else %}{% translate "View" %}{% endif %}{% endif %} {% endif %} - {% if inline_admin_form.show_url %}{% trans "View on site" %}{% endif %} + {% if inline_admin_form.show_url %}{% translate "View on site" %}{% endif %}

    {% endif %} {% if inline_admin_form.needs_explicit_pk_field %}{{ inline_admin_form.pk_field.field }}{% endif %} {% if inline_admin_form.fk_field %}{{ inline_admin_form.fk_field.field }}{% endif %} diff --git a/django/contrib/admin/templates/admin/filter.html b/django/contrib/admin/templates/admin/filter.html index cd88652a62..35dc553bd8 100644 --- a/django/contrib/admin/templates/admin/filter.html +++ b/django/contrib/admin/templates/admin/filter.html @@ -1,5 +1,5 @@ {% load i18n %} -

    {% blocktrans with filter_title=title %} By {{ filter_title }} {% endblocktrans %}

    +

    {% blocktranslate with filter_title=title %} By {{ filter_title }} {% endblocktranslate %}

      {% for choice in choices %} diff --git a/django/contrib/admin/templates/admin/includes/object_delete_summary.html b/django/contrib/admin/templates/admin/includes/object_delete_summary.html index 6a8bf6542a..9ad97db2fc 100644 --- a/django/contrib/admin/templates/admin/includes/object_delete_summary.html +++ b/django/contrib/admin/templates/admin/includes/object_delete_summary.html @@ -1,5 +1,5 @@ {% load i18n %} -

      {% trans "Summary" %}

      +

      {% translate "Summary" %}

        {% for model_name, object_count in model_count %}
      • {{ model_name|capfirst }}: {{ object_count }}
      • diff --git a/django/contrib/admin/templates/admin/index.html b/django/contrib/admin/templates/admin/index.html index 746cdcdf60..221ddf2a0a 100644 --- a/django/contrib/admin/templates/admin/index.html +++ b/django/contrib/admin/templates/admin/index.html @@ -17,7 +17,7 @@
        {% for model in app.models %} @@ -28,16 +28,16 @@ {% endif %} {% if model.add_url %} - + {% else %} {% endif %} {% if model.admin_url %} {% if model.view_only %} - + {% else %} - + {% endif %} {% else %} @@ -48,7 +48,7 @@ {% endfor %} {% else %} -

        {% trans 'You don’t have permission to view or edit anything.' %}

        +

        {% translate 'You don’t have permission to view or edit anything.' %}

        {% endif %} {% endblock %} @@ -56,12 +56,12 @@ {% block sidebar %}
        - {{ app.name }} + {{ app.name }}
        {% trans 'Add' %}{% translate 'Add' %} {% trans 'View' %}{% translate 'View' %}{% trans 'Change' %}{% translate 'Change' %} 
        - - - + + + @@ -35,7 +35,7 @@
        {% trans 'Date/time' %}{% trans 'User' %}{% trans 'Action' %}{% translate 'Date/time' %}{% translate 'User' %}{% translate 'Action' %}
        {% else %} -

        {% trans 'This object doesn’t have a change history. It probably wasn’t added via this admin site.' %}

        +

        {% translate 'This object doesn’t have a change history. It probably wasn’t added via this admin site.' %}

        {% endif %}

    diff --git a/django/contrib/admin/templates/admin/pagination.html b/django/contrib/admin/templates/admin/pagination.html index bef843a444..d0ae8ba067 100644 --- a/django/contrib/admin/templates/admin/pagination.html +++ b/django/contrib/admin/templates/admin/pagination.html @@ -7,6 +7,6 @@ {% endfor %} {% endif %} {{ cl.result_count }} {% if cl.result_count == 1 %}{{ cl.opts.verbose_name }}{% else %}{{ cl.opts.verbose_name_plural }}{% endif %} -{% if show_all_url %}  {% trans 'Show all' %}{% endif %} -{% if cl.formset and cl.result_count %}{% endif %} +{% if show_all_url %}  {% translate 'Show all' %}{% endif %} +{% if cl.formset and cl.result_count %}{% endif %}

    diff --git a/django/contrib/admin/templates/admin/popup_response.html b/django/contrib/admin/templates/admin/popup_response.html index 509a81a7c2..57a1ae3661 100644 --- a/django/contrib/admin/templates/admin/popup_response.html +++ b/django/contrib/admin/templates/admin/popup_response.html @@ -1,6 +1,6 @@ {% load i18n static %} - {% trans 'Popup closing…' %} + {% translate 'Popup closing…' %}
    {% if editable %} -{% trans "Delete all Features" %} +{% translate "Delete all Features" %} {% endif %} -{% if display_wkt %}

    {% trans "WKT debugging window:" %}

    {% endif %} +{% if display_wkt %}

    {% translate "WKT debugging window:" %}

    {% endif %} diff --git a/django/contrib/gis/templates/gis/openlayers.html b/django/contrib/gis/templates/gis/openlayers.html index 88288a3cb7..90ecf1b44b 100644 --- a/django/contrib/gis/templates/gis/openlayers.html +++ b/django/contrib/gis/templates/gis/openlayers.html @@ -9,8 +9,8 @@
    - {% if not disabled %}{% trans "Delete all Features" %}{% endif %} - {% if display_raw %}

    {% trans "Debugging window (serialized value)" %}

    {% endif %} + {% if not disabled %}{% translate "Delete all Features" %}{% endif %} + {% if display_raw %}

    {% translate "Debugging window (serialized value)" %}

    {% endif %}