Projet

Général

Profil

0001-django4-replaced-ugettext-calls-with-corresponding-g.patch

A. Berriot, 31 août 2022 17:41

Télécharger (11,1 ko)

Voir les différences:

Subject: [PATCH 1/4] django4: replaced ugettext* calls with corresponding
 gettext* calls (#68593)

 .../commands/send_email_notifications.py      |  2 +-
 chrono/agendas/management/commands/utils.py   |  2 +-
 .../migrations/0069_translate_holidays.py     |  2 +-
 chrono/agendas/models.py                      | 10 +++----
 chrono/api/serializers.py                     |  2 +-
 chrono/api/views.py                           |  2 +-
 chrono/manager/forms.py                       |  2 +-
 chrono/manager/views.py                       | 26 +++++++++----------
 chrono/utils/misc.py                          |  2 +-
 9 files changed, 25 insertions(+), 25 deletions(-)
chrono/agendas/management/commands/send_email_notifications.py
23 23
from django.db.transaction import atomic
24 24
from django.template.loader import render_to_string
25 25
from django.utils import timezone, translation
26
from django.utils.translation import ugettext_lazy as _
26
from django.utils.translation import gettext_lazy as _
27 27

  
28 28
from chrono.agendas.models import Agenda
29 29

  
chrono/agendas/management/commands/utils.py
6 6
from django.template import Context, Template, TemplateSyntaxError, VariableDoesNotExist
7 7
from django.template.loader import render_to_string
8 8
from django.utils import timezone
9
from django.utils.translation import ugettext_lazy as _
9
from django.utils.translation import gettext_lazy as _
10 10
from requests import RequestException
11 11

  
12 12
from chrono.utils.requests_wrapper import requests
chrono/agendas/migrations/0069_translate_holidays.py
3 3
from django.conf import settings
4 4
from django.db import migrations
5 5
from django.utils import translation
6
from django.utils.translation import ugettext as _
6
from django.utils.translation import gettext as _
7 7

  
8 8

  
9 9
def translate_holidays_exceptions(apps, schema_editor):
chrono/agendas/models.py
51 51
from django.utils.safestring import mark_safe
52 52
from django.utils.text import slugify
53 53
from django.utils.timezone import is_aware, localtime, make_aware, make_naive, now, utc
54
from django.utils.translation import pgettext_lazy, ugettext
55
from django.utils.translation import ugettext_lazy as _
56
from django.utils.translation import ungettext
54
from django.utils.translation import gettext
55
from django.utils.translation import gettext_lazy as _
56
from django.utils.translation import ngettext, pgettext_lazy
57 57

  
58 58
from chrono.interval import Interval, IntervalSet
59 59
from chrono.utils.date import get_weekday_index
......
2386 2386
        if self.ics_filename is not None:
2387 2387
            return self.ics_filename
2388 2388
        if self.settings_label is not None:
2389
            return ugettext(self.settings_label)
2389
            return gettext(self.settings_label)
2390 2390
        return self.ics_url
2391 2391

  
2392 2392
    def duplicate(self, desk_target=None):
......
3052 3052

  
3053 3053
    def display_info(self):
3054 3054
        def get_message(days, by_email_or_sms):
3055
            return ungettext(
3055
            return ngettext(
3056 3056
                'Users will be reminded of their booking %(by_email_or_sms)s, one day in advance.',
3057 3057
                'Users will be reminded of their booking %(by_email_or_sms)s, %(days)s days in advance.',
3058 3058
                days,
chrono/api/serializers.py
4 4
from django.contrib.auth.models import Group
5 5
from django.db import models, transaction
6 6
from django.db.models import ExpressionWrapper, F
7
from django.utils.translation import ugettext_lazy as _
7
from django.utils.translation import gettext_lazy as _
8 8
from rest_framework import serializers
9 9
from rest_framework.exceptions import ValidationError
10 10

  
chrono/api/views.py
34 34
from django.utils.formats import date_format
35 35
from django.utils.timezone import localtime, make_aware, now
36 36
from django.utils.translation import gettext
37
from django.utils.translation import gettext_lazy as _
37 38
from django.utils.translation import gettext_noop as N_
38 39
from django.utils.translation import pgettext
39
from django.utils.translation import ugettext_lazy as _
40 40
from django_filters import rest_framework as filters
41 41
from rest_framework import permissions
42 42
from rest_framework.exceptions import ValidationError
chrono/manager/forms.py
36 36
from django.utils.encoding import force_text
37 37
from django.utils.formats import date_format
38 38
from django.utils.timezone import localtime, make_aware, now
39
from django.utils.translation import ugettext_lazy as _
39
from django.utils.translation import gettext_lazy as _
40 40

  
41 41
from chrono.agendas.models import (
42 42
    WEEK_CHOICES,
chrono/manager/views.py
43 43
from django.utils.formats import date_format
44 44
from django.utils.html import format_html
45 45
from django.utils.timezone import localtime, make_aware, make_naive, now
46
from django.utils.translation import ugettext_lazy as _
47
from django.utils.translation import ungettext
46
from django.utils.translation import gettext_lazy as _
47
from django.utils.translation import ngettext
48 48
from django.views.generic import (
49 49
    CreateView,
50 50
    DayArchiveView,
......
811 811
        import_messages = {
812 812
            'agendas': {
813 813
                'create_noop': _('No agenda created.'),
814
                'create': lambda x: ungettext(
814
                'create': lambda x: ngettext(
815 815
                    'An agenda has been created.',
816 816
                    '%(count)d agendas have been created.',
817 817
                    x,
818 818
                ),
819 819
                'update_noop': _('No agenda updated.'),
820
                'update': lambda x: ungettext(
820
                'update': lambda x: ngettext(
821 821
                    'An agenda has been updated.',
822 822
                    '%(count)d agendas have been updated.',
823 823
                    x,
......
825 825
            },
826 826
            'unavailability_calendars': {
827 827
                'create_noop': _('No unavailability calendar created.'),
828
                'create': lambda x: ungettext(
828
                'create': lambda x: ngettext(
829 829
                    'An unavailability calendar has been created.',
830 830
                    '%(count)d unavailability calendars have been created.',
831 831
                    x,
832 832
                ),
833 833
                'update_noop': _('No unavailability calendar updated.'),
834
                'update': lambda x: ungettext(
834
                'update': lambda x: ngettext(
835 835
                    'An unavailability calendar has been updated.',
836 836
                    '%(count)d unavailability calendars have been updated.',
837 837
                    x,
......
839 839
            },
840 840
            'events_types': {
841 841
                'create_noop': _('No events type created.'),
842
                'create': lambda x: ungettext(
842
                'create': lambda x: ngettext(
843 843
                    'An events type has been created.',
844 844
                    '%(count)d events types have been created.',
845 845
                    x,
846 846
                ),
847 847
                'update_noop': _('No events type updated.'),
848
                'update': lambda x: ungettext(
848
                'update': lambda x: ngettext(
849 849
                    'An events type has been updated.',
850 850
                    '%(count)d events types have been updated.',
851 851
                    x,
......
853 853
            },
854 854
            'resources': {
855 855
                'create_noop': _('No resource created.'),
856
                'create': lambda x: ungettext(
856
                'create': lambda x: ngettext(
857 857
                    'A resource has been created.',
858 858
                    '%(count)d resources have been created.',
859 859
                    x,
860 860
                ),
861 861
                'update_noop': _('No resource updated.'),
862
                'update': lambda x: ungettext(
862
                'update': lambda x: ngettext(
863 863
                    'A resource has been updated.',
864 864
                    '%(count)d resources have been updated.',
865 865
                    x,
......
867 867
            },
868 868
            'categories': {
869 869
                'create_noop': _('No category created.'),
870
                'create': lambda x: ungettext(
870
                'create': lambda x: ngettext(
871 871
                    'A category has been created.',
872 872
                    '%(count)d categories have been created.',
873 873
                    x,
874 874
                ),
875 875
                'update_noop': _('No category updated.'),
876
                'update': lambda x: ungettext(
876
                'update': lambda x: ngettext(
877 877
                    'A category has been updated.',
878 878
                    '%(count)d categories have been updated.',
879 879
                    x,
......
2869 2869
    def form_valid(self, form):
2870 2870
        result = super().form_valid(form)
2871 2871
        all_desks = form.cleaned_data.get('all_desks')
2872
        message = ungettext(
2872
        message = ngettext(
2873 2873
            'Exception added.',
2874 2874
            'Exceptions added.',
2875 2875
            len(form.exceptions) if all_desks else 1,
chrono/utils/misc.py
17 17
import copy
18 18

  
19 19
from django.core.exceptions import FieldDoesNotExist, ValidationError
20
from django.utils.translation import ugettext_lazy as _
20
from django.utils.translation import gettext_lazy as _
21 21

  
22 22

  
23 23
class ICSError(Exception):
24
-