Skip to main content

Humanize functions for Portuguese.

Project description

PyPI Python Version License

Read the documentation at https://humanizer-portugues.readthedocs.io/ Tests Codecov

pre-commit Black

Features

  • This lib contains various humanization methods such as transforming a time difference in a human-readable duration “três minutos atrás” (three minutes ago) or in a phrase.

Requirements

  • It works in Python 3.7 and 3.8.

Installation

You can install Humanizer Portugues via pip from PyPI:

$ pip install humanizer-portugues

Usage

Import the lib with:

import humanizer_portugues

Humanization filesizes:

humanizer_portugues.natural_size(1000000)
"1.0 MB"

humanizer_portugues.natural_size(1000000, binary=True)
"976.6 KiB"

humanizer_portugues.natural_size(1000000, gnu=True)
"976.6K"

Humanization of lists:

humanizer_portugues.natural_list(["Cláudio", "Maria"], ",")
"Cláudio, Maria"

humanizer_portugues.natural_list(["Cláudio", "Maria"], ",", "e")
"Cláudio e Maria"

humanizer_portugues.natural_list(["Cláudio", "Maria", "José"], ";", "ou")
"Cláudio; Maria ou José"

Humanization of integers:

humanizer_portugues.ap_number(4)
"quatro"

humanizer_portugues.ap_number(41)
"41"

humanizer_portugues.int_comma(12345)
"12,345"

humanizer_portugues.int_word(123455913)
"123.5 milhão"

humanizer_portugues.int_word(12345591313)
"12.3 bilhão"

Humanization of floating point numbers:

humanizer_portugues.fractional(1/3)
"1/3"

humanizer_portugues.fractional(1.5)
"1 1/2"

humanizer_portugues.fractional(0.3)
"3/10"

humanizer_portugues.fractional(0.333)
"333/1000"

humanizer_portugues.fractional(1)
"1"

Humanization of dates and time:

import datetime

humanizer_portugues.natural_clock(datetime.time(0, 30, 0))
"zero hora e trinta minutos"

humanizer_portugues.natural_clock(datetime.time(0, 30, 0), formal=False)
"meia noite e meia"

humanizer_portugues.natural_date(datetime.date(2007, 6, 5))
"5 de junho de 2007"

humanizer_portugues.natural_day(datetime.datetime.now())
"hoje"

humanizer_portugues.natural_day(datetime.datetime.now() - datetime.timedelta(days=1))
"ontem"

humanizer_portugues.natural_day(datetime.date(2007, 6, 5))
"5 de junho"

humanizer_portugues.natural_delta(datetime.timedelta(seconds=1001))
"16 minutos"

humanizer_portugues.natural_period(datetime.time(5, 30, 0).hour)
"manhã"

humanizer_portugues.natural_time(datetime.datetime.now() - datetime.timedelta(seconds=1))
"há um segundo"

humanizer_portugues.natural_time(datetime.datetime.now() - datetime.timedelta(seconds=3600))
"há uma hora"

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the MIT license, Humanizer Portugues is free and open source software.

Credits

This lib is based on original humanize, with updates for python3, translation fixes for portuguese, changes in return format and the addition of list humanizing. Localization (i18n) was also removed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for humanizer-portugues, version 2.4.0
Filename, size File type Python version Upload date Hashes
Filename, size humanizer_portugues-2.4.0-py3-none-any.whl (10.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size humanizer-portugues-2.4.0.tar.gz (11.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page