mirror of
https://github.com/bblaz/num2words.git
synced 2025-12-06 06:42:25 +00:00
Merge branch 'master' into master
This commit is contained in:
45
.github/workflows/ci.yml
vendored
Normal file
45
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
name: CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [3.6, 3.7, 3.8, 3.9, '3.10']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install tox tox-gh-actions coveralls
|
||||
pip install -r requirements-test.txt
|
||||
- name: Test with tox
|
||||
run: |
|
||||
tox
|
||||
- name: Upload coverage data to coveralls.io
|
||||
run: coveralls --service=github
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
COVERALLS_FLAG_NAME: ${{ matrix.python-version }}
|
||||
COVERALLS_PARALLEL: true
|
||||
|
||||
coveralls:
|
||||
name: Indicate completion to coveralls.io
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
container: python:3-slim
|
||||
steps:
|
||||
- name: Finished
|
||||
run: |
|
||||
pip3 install --upgrade coveralls
|
||||
coveralls --service=github --finish
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
20
.travis.yml
20
.travis.yml
@@ -1,20 +0,0 @@
|
||||
sudo: false
|
||||
language: python
|
||||
python:
|
||||
- "2.7"
|
||||
- "3.4"
|
||||
- "3.5"
|
||||
- "3.6"
|
||||
matrix:
|
||||
include:
|
||||
- { python: 3.6, env: TOXENV=flake8 }
|
||||
- { python: 3.6, env: TOXENV=isort }
|
||||
# Py37 requires xenial distrubution and sudo
|
||||
# See travis-ci/travis-ci#9069
|
||||
- { python: 3.7, dist: xenial, sudo: true }
|
||||
|
||||
install:
|
||||
- pip install tox-travis
|
||||
- pip install coveralls
|
||||
script: tox
|
||||
after_success: if [ -e .coverage ]; then coveralls; fi
|
||||
28
CHANGES.rst
28
CHANGES.rst
@@ -1,6 +1,34 @@
|
||||
Changelog
|
||||
=========
|
||||
|
||||
Version 0.5.11 -- 2022/08/03
|
||||
----------------------------
|
||||
|
||||
* Add KZT and UAH currencies to lang RU (#264)
|
||||
* Add es_NI currency (#276)
|
||||
* Update .gitignore to add .eggs/ directory (#280)
|
||||
* Fix Hebrew support (#289)
|
||||
* Update test_tr.py to increase coverage (#298)
|
||||
* Add ordinal 12,345 to ES test suite to increase coverage (#287)
|
||||
* Add simple tests for lang_DK.py (#286)
|
||||
* Add testcase for lang_EN.py (#288)
|
||||
* Add more tests to base.py (#283)
|
||||
* Fixed misspelling of 21 (cardinal and ordinal number) in IT language (#270)
|
||||
* Romanian issues 259 (#260)
|
||||
* Adding Language Support for Telugu / Bug Fix in Kannada (#263)
|
||||
* Add support of Kazakh language (KZ) (#306)
|
||||
* Update README.rst (#307)
|
||||
* Added support for Hungarian language (#310)
|
||||
* [UPD] Readme file (#363)
|
||||
* [ADD] num2words: add traslation to spanish of several currencies (#356)
|
||||
* added swedish language including test cases (#352)
|
||||
* Remove dupplicated line in lang_PT_BR (#355)
|
||||
* Fix ordinal_num output for Dutch (NL) (#369)
|
||||
* Polishordinals (#367)
|
||||
* [tr] return Turkish 0 ordinal and cardinal (#347)
|
||||
* Improve Ukrainian support and minor fixes in CZ, KZ, LT, LV, PL, RU, SR languages (#400)
|
||||
* feat: ci: replace travis by github workflows (#448)
|
||||
* [ES] Added missing accents ("dieciséis", "dólar", "dólares", "veintiún"), improved currency gender handling, fixed pound cent names (#443)
|
||||
|
||||
Version 0.5.10 -- 2019/05/12
|
||||
----------------------------
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
num2words library - Convert numbers to words in multiple languages
|
||||
==========================================================
|
||||
==================================================================
|
||||
|
||||
.. image:: https://img.shields.io/pypi/v/num2words.svg
|
||||
:target: https://pypi.python.org/pypi/num2words
|
||||
@@ -51,7 +51,7 @@ Command line::
|
||||
$ num2words 24,120.10 -l es
|
||||
veinticuatro mil ciento veinte punto uno
|
||||
$num2words 2.14 -l es --to currency
|
||||
dos euros con catorce centimos
|
||||
dos euros con catorce céntimos
|
||||
|
||||
In code there's only one function to use::
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ Examples:
|
||||
veinticuatro mil ciento veinte punto uno
|
||||
|
||||
$num2words 2.14 -l es --to currency
|
||||
dos euros con catorce centimos
|
||||
dos euros con catorce céntimos
|
||||
"""
|
||||
|
||||
from __future__ import print_function, unicode_literals
|
||||
@@ -55,7 +55,7 @@ import sys
|
||||
from docopt import docopt
|
||||
import num2words
|
||||
|
||||
__version__ = "0.5.10"
|
||||
__version__ = "0.5.11"
|
||||
__license__ = "LGPL"
|
||||
|
||||
|
||||
|
||||
@@ -21,13 +21,14 @@ import math
|
||||
|
||||
from .lang_EU import Num2Word_EU
|
||||
|
||||
GENERIC_DOLLARS = ('dolar', 'dólares')
|
||||
GENERIC_DOLLARS = ('dólar', 'dólares')
|
||||
GENERIC_CENTS = ('centavo', 'centavos')
|
||||
CURRENCIES_UNA = ('SLL', 'SEK', 'NOK', 'CZK', 'DKK', 'ISK',
|
||||
'SKK', 'GBP', 'CYP', 'EGP', 'FKP', 'GIP',
|
||||
'LBP', 'SDG', 'SHP', 'SSP', 'SYP', 'INR',
|
||||
'IDR', 'LKR', 'MUR', 'NPR', 'PKR', 'SCR',
|
||||
'ESP')
|
||||
'ESP', 'TRY', 'ITL')
|
||||
CENTS_UNA = ('EGP', 'JOD', 'LBP', 'SDG', 'SSP', 'SYP')
|
||||
|
||||
|
||||
class Num2Word_ES(Num2Word_EU):
|
||||
@@ -39,7 +40,7 @@ class Num2Word_ES(Num2Word_EU):
|
||||
'CRC': (('colón', 'colones'), GENERIC_CENTS),
|
||||
'AUD': (GENERIC_DOLLARS, GENERIC_CENTS),
|
||||
'CAD': (GENERIC_DOLLARS, GENERIC_CENTS),
|
||||
'GBP': (('libra', 'libras'), ('penny', 'pence')),
|
||||
'GBP': (('libra', 'libras'), ('penique', 'peniques')),
|
||||
'RUB': (('rublo', 'rublos'), ('kopeyka', 'kopeykas')),
|
||||
'SEK': (('corona', 'coronas'), ('öre', 'öre')),
|
||||
'NOK': (('corona', 'coronas'), ('øre', 'øre')),
|
||||
@@ -101,7 +102,7 @@ class Num2Word_ES(Num2Word_EU):
|
||||
'ERN': (('nakfa', 'nakfas'), ('céntimo', 'céntimos')),
|
||||
'ETB': (('birr', 'birrs'), ('céntimo', 'céntimos')),
|
||||
'FJD': (GENERIC_DOLLARS, GENERIC_CENTS),
|
||||
'FKP': (('libra', 'libras'), ('penny', 'peniques')),
|
||||
'FKP': (('libra', 'libras'), ('penique', 'peniques')),
|
||||
'GEL': (('lari', 'laris'), ('tetri', 'tetris')),
|
||||
'GHS': (('cedi', 'cedis'), ('pesewa', 'pesewas')),
|
||||
'GIP': (('libra', 'libras'), ('penique', 'peniques')),
|
||||
@@ -170,7 +171,7 @@ class Num2Word_ES(Num2Word_EU):
|
||||
'SCR': (('rupia', 'rupias'), ('céntimo', 'céntimos')),
|
||||
'SDG': (('libra', 'libras'), ('piastra', 'piastras')),
|
||||
'SGD': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
'SHP': (('libra', 'libras'), ('penny', 'peniques')),
|
||||
'SHP': (('libra', 'libras'), ('penique', 'peniques')),
|
||||
'SKK': (('corona', 'coronas'), ('halier', 'haliers')),
|
||||
'SLL': (('leona', 'leonas'), ('céntimo', 'céntimos')),
|
||||
'SRD': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
@@ -184,7 +185,7 @@ class Num2Word_ES(Num2Word_EU):
|
||||
'TND': (('dinar', 'dinares'), ('milésimo', 'milésimos')),
|
||||
'TOP': (('paanga', 'paangas'), ('céntimo', 'céntimos')),
|
||||
'TTD': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
'TWD': (('nuevo dólar', 'nuevos dolares'), ('céntimo', 'céntimos')),
|
||||
'TWD': (('nuevo dólar', 'nuevos dólares'), ('céntimo', 'céntimos')),
|
||||
'TZS': (('chelín', 'chelines'), ('céntimo', 'céntimos')),
|
||||
'UAG': (('hryvnia', 'hryvnias'), ('kopiyka', 'kopiykas')),
|
||||
'UGX': (('chelín', 'chelines'), ('céntimo', 'céntimos')),
|
||||
@@ -216,9 +217,13 @@ class Num2Word_ES(Num2Word_EU):
|
||||
self.high_numwords = self.gen_high_numwords([], [], lows)
|
||||
self.negword = "menos "
|
||||
self.pointword = "punto"
|
||||
self.errmsg_nonnum = "Solo números pueden ser convertidos a palabras."
|
||||
self.errmsg_nonnum = "type(%s) no es [long, int, float]"
|
||||
self.errmsg_floatord = "El float %s no puede ser tratado como un" \
|
||||
" ordinal."
|
||||
self.errmsg_negord = "El número negativo %s no puede ser tratado" \
|
||||
" como un ordinal."
|
||||
self.errmsg_toobig = (
|
||||
"Numero muy grande para ser convertido a palabras."
|
||||
"abs(%s) deber ser inferior a %s."
|
||||
)
|
||||
self.gender_stem = "o"
|
||||
self.exclude_title = ["y", "menos", "punto"]
|
||||
@@ -230,7 +235,7 @@ class Num2Word_ES(Num2Word_EU):
|
||||
"veintiséis", "veinticinco", "veinticuatro",
|
||||
"veintitrés", "veintidós", "veintiuno",
|
||||
"veinte", "diecinueve", "dieciocho", "diecisiete",
|
||||
"dieciseis", "quince", "catorce", "trece", "doce",
|
||||
"dieciséis", "quince", "catorce", "trece", "doce",
|
||||
"once", "diez", "nueve", "ocho", "siete", "seis",
|
||||
"cinco", "cuatro", "tres", "dos", "uno", "cero"]
|
||||
self.ords = {1: "primer",
|
||||
@@ -352,15 +357,52 @@ class Num2Word_ES(Num2Word_EU):
|
||||
result = super(Num2Word_ES, self).to_currency(
|
||||
val, currency=currency, cents=cents, separator=separator,
|
||||
adjective=adjective)
|
||||
# Handle exception, in spanish is "un euro" and not "uno euro"
|
||||
# except in this currencies: leona, corona,
|
||||
# libra, rupia, lempira, peseta, is 'una'
|
||||
# but only when it's first word, otherwise
|
||||
# it's replaced in others words like 'veintiun'
|
||||
# Handle exception: In Spanish it's "un euro" and not "uno euro",
|
||||
# except in these currencies, where it's "una": leona, corona,
|
||||
# libra, lira, rupia, lempira, peseta.
|
||||
# The same goes for "veintiuna", "treinta y una"...
|
||||
# Also, this needs to be handled separately for "dollars" and
|
||||
# "cents".
|
||||
# All "cents" are masculine except for: piastra.
|
||||
# Source: https://www.rae.es/dpd/una (section 2.2)
|
||||
|
||||
# split "dollars" part from "cents" part
|
||||
list_result = result.split(separator + " ")
|
||||
|
||||
# "DOLLARS" PART (list_result[0])
|
||||
|
||||
# Feminine currencies ("una libra", "trescientas libras"...)
|
||||
if currency in CURRENCIES_UNA:
|
||||
list_result = result.split(" ")
|
||||
if list_result[0] == "uno":
|
||||
|
||||
# "una libra", "veintiuna libras", "treinta y una libras"...
|
||||
list_result[0] = list_result[0].replace("uno", "una")
|
||||
result = " ".join(list_result)
|
||||
result = result.replace("uno", "un")
|
||||
|
||||
# "doscientas libras", "trescientas libras"...
|
||||
list_result[0] = list_result[0].replace("cientos", "cientas")
|
||||
|
||||
# Masc.: Correct orthography for the specific case of "veintiún":
|
||||
list_result[0] = list_result[0].replace("veintiuno", "veintiún")
|
||||
|
||||
# Masculine currencies: general case ("un euro", "treinta y un
|
||||
# euros"...):
|
||||
list_result[0] = list_result[0].replace("uno", "un")
|
||||
|
||||
# "CENTS" PART (list_result[1])
|
||||
|
||||
# Feminine "cents" ("una piastra", "veintiuna piastras"...)
|
||||
if currency in CENTS_UNA:
|
||||
|
||||
# "una piastra", "veintiuna piastras", "treinta y una piastras"...
|
||||
list_result[1] = list_result[1].replace("uno", "una")
|
||||
|
||||
# Masc.: Correct orthography for the specific case of "veintiún":
|
||||
list_result[1] = list_result[1].replace("veintiuno", "veintiún")
|
||||
|
||||
# Masculine "cents": general case ("un centavo", "treinta y un
|
||||
# centavos"...):
|
||||
list_result[1] = list_result[1].replace("uno", "un")
|
||||
|
||||
# join back "dollars" part with "cents" part
|
||||
result = (separator + " ").join(list_result)
|
||||
|
||||
return result
|
||||
|
||||
@@ -93,7 +93,7 @@ class Num2Word_KO(Num2Word_Base):
|
||||
|
||||
def to_ordinal(self, value):
|
||||
self.verify_ordinal(value)
|
||||
if(value == 1):
|
||||
if value == 1:
|
||||
return "첫 번째"
|
||||
outwords = self.to_cardinal(value).split(" ")
|
||||
lastwords = outwords[-1].split("백")
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
tox
|
||||
flake8
|
||||
flake8-copyright
|
||||
isort
|
||||
|
||||
10
setup.py
10
setup.py
@@ -27,8 +27,11 @@ CLASSIFIERS = [
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: GNU Library or Lesser General Public License '
|
||||
'(LGPL)',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Programming Language :: Python :: 3.8',
|
||||
'Programming Language :: Python :: 3.9',
|
||||
'Programming Language :: Python :: 3.10',
|
||||
'Topic :: Software Development :: Internationalization',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules',
|
||||
'Topic :: Software Development :: Localization',
|
||||
@@ -61,11 +64,12 @@ setup(
|
||||
version=find_version("bin/num2words"),
|
||||
description='Modules to convert numbers to words. Easily extensible.',
|
||||
long_description=LONG_DESC,
|
||||
long_description_content_type="text/markdown",
|
||||
license='LGPL',
|
||||
author='Taro Ogawa <tso at users sourceforge net>',
|
||||
author_email='tos@users.sourceforge.net',
|
||||
maintainer='Savoir-faire Linux inc.',
|
||||
maintainer_email='istvan.szalai@savoirfairelinux.com',
|
||||
maintainer_email='support@savoirfairelinux.com',
|
||||
keywords=' number word numbers words convert conversion i18n '
|
||||
'localisation localization internationalisation '
|
||||
'internationalization',
|
||||
|
||||
@@ -58,3 +58,8 @@ class Num2WordBaseTest(TestCase):
|
||||
self.base.title("one"),
|
||||
"One"
|
||||
)
|
||||
self.base.exclude_title.append('one')
|
||||
self.assertEqual(
|
||||
self.base.title("one"),
|
||||
"one"
|
||||
)
|
||||
|
||||
390
tests/test_es.py
390
tests/test_es.py
File diff suppressed because it is too large
Load Diff
19
tox.ini
19
tox.ini
@@ -1,8 +1,17 @@
|
||||
[tox]
|
||||
envlist = flake8,isort,py27,py34,py35,py36,py37
|
||||
envlist = py36,py37,py38,py39,py310,flake8,isort
|
||||
|
||||
[gh-actions]
|
||||
python =
|
||||
3.6: py36
|
||||
3.7: py37
|
||||
3.8: py38
|
||||
3.9: py39
|
||||
3.10: isort, flake8, py310
|
||||
|
||||
|
||||
[testenv]
|
||||
passenv = TRAVIS TRAVIS_*
|
||||
passenv = GITHUB_*
|
||||
deps =
|
||||
coverage
|
||||
delegator.py
|
||||
@@ -25,8 +34,4 @@ deps =
|
||||
isort
|
||||
delegator.py
|
||||
commands =
|
||||
isort --check-only --recursive --diff num2words tests
|
||||
|
||||
[testenv:py27]
|
||||
setenv =
|
||||
PYTHONIOENCODING = UTF-8
|
||||
isort --check-only --float-to-top --diff num2words tests
|
||||
|
||||
Reference in New Issue
Block a user