Skip to content

format_timedelta() for minutes=1 and hours=1 with narrow format and pt_BR locale returns an empty string #892

Closed
@jun66j5

Description

@jun66j5

Overview Description

format_timedelta() for minutes=1 and hours=1 with narrow format and pt_BR locale returns an empty string.

Steps to Reproduce

>>> import babel
>>> babel.__version__
'2.10.3'
>>> from datetime import timedelta
>>> from babel import dates
>>> dates.format_timedelta(timedelta(seconds=1), format='narrow', locale='pt_BR')
'1 s'
>>> dates.format_timedelta(timedelta(minutes=1), format='narrow', locale='pt_BR')
''
>>> dates.format_timedelta(timedelta(hours=1), format='narrow', locale='pt_BR')
''
>>> dates.format_timedelta(timedelta(days=1), format='narrow', locale='pt_BR')
'1 dia'
>>> dates.format_timedelta(timedelta(days=30), format='narrow', locale='pt_BR')
'1 mês'
>>> dates.format_timedelta(timedelta(days=365), format='narrow', locale='pt_BR')
'1 ano'

Actual Results

See "Steps to Reproduce"

Expected Results

Probably, 1 hora and 1 min.

Reproducibility

Always.

Additional Information

In common/main/pt.xml file:

  • duration-hour has only displayName element
  • duration-minute is missing
                <unitLength type="narrow">
                        ...
                        <unit type="duration-day">
                                <displayName>dia</displayName>
                                <unitPattern count="one">{0} dia</unitPattern>
                                <unitPattern count="other">{0} dias</unitPattern>
                                <perUnitPattern>{0}/dia</perUnitPattern>
                        </unit>
                        <unit type="duration-hour">
                                <displayName>hora</displayName>
                        </unit>
                        <unit type="duration-second">
                                <displayName>seg</displayName>
                                <unitPattern count="one">{0} s</unitPattern>
                                <unitPattern count="other">{0} s</unitPattern>
                                <perUnitPattern>{0}/seg</perUnitPattern>
                        </unit>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions