diff --git a/README.rst b/README.rst index 7e0bc1f2..6df77fd7 100644 --- a/README.rst +++ b/README.rst @@ -90,6 +90,7 @@ Besides the numerical argument, there are two main optional arguments, ``to:`` a * ``en_GB`` (English - Great Britain) * ``en_IN`` (English - India) * ``en_NG`` (English - Nigeria) +* ``en_NP`` (English - Nepal) * ``es`` (Spanish) * ``es_CO`` (Spanish - Colombia) * ``es_CR`` (Spanish - Costa Rica) @@ -163,4 +164,4 @@ added Lithuanian support, but didn't take over maintenance of the project. I am thus basing myself on Marius Grigaitis' improvements and re-publishing ``pynum2word`` as ``num2words``. -Virgil Dupras, Savoir-faire Linux \ No newline at end of file +Virgil Dupras, Savoir-faire Linux diff --git a/num2words/__init__.py b/num2words/__init__.py index 882aa229..314f3925 100644 --- a/num2words/__init__.py +++ b/num2words/__init__.py @@ -17,8 +17,9 @@ from __future__ import unicode_literals + from . import (lang_AM, lang_AR, lang_AZ, lang_BE, lang_BN, lang_CA, lang_CE, - lang_CS, lang_CY, lang_DA, lang_DE, lang_EN, lang_EN_IN, + lang_CS, lang_CY, lang_DA, lang_DE, lang_EN, lang_EN_IN, lang_EN_NP, lang_EN_NG, lang_EO, lang_ES, lang_ES_CO, lang_ES_CR, lang_ES_GT, lang_ES_NI, lang_ES_VE, lang_FA, lang_FI, lang_FR, lang_FR_BE, lang_FR_CH, lang_FR_DZ, lang_HE, lang_HU, lang_ID, @@ -40,6 +41,7 @@ 'en': lang_EN.Num2Word_EN(), 'en_IN': lang_EN_IN.Num2Word_EN_IN(), 'en_NG': lang_EN_NG.Num2Word_EN_NG(), + 'en_NP': lang_EN_NP.Num2Word_EN_NP(), 'fa': lang_FA.Num2Word_FA(), 'fr': lang_FR.Num2Word_FR(), 'fr_CH': lang_FR_CH.Num2Word_FR_CH(), diff --git a/num2words/lang_EN_NP.py b/num2words/lang_EN_NP.py new file mode 100644 index 00000000..0eedd054 --- /dev/null +++ b/num2words/lang_EN_NP.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2003, Taro Ogawa. All Rights Reserved. +# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved. + +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301 USA + +# for Nepalese Number System +# Added support for Nepali Numbering System by Ajira Group, Nepal support@ajiragroup.com + + +from __future__ import unicode_literals + +from .lang_EN import Num2Word_EN + + +class Num2Word_EN_NP(Num2Word_EN): + def set_high_numwords(self, high): + self.cards[10 ** 17] = "shankha" + self.cards[10 ** 15] = "padam" + self.cards[10 ** 13] = "neel" + self.cards[10 ** 11] = "kharba" + self.cards[10 ** 9] = "arba" + self.cards[10 ** 7] = "crore" + self.cards[10 ** 5] = "lakh" diff --git a/tests/test_en_np.py b/tests/test_en_np.py new file mode 100644 index 00000000..1794f6c2 --- /dev/null +++ b/tests/test_en_np.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2003, Taro Ogawa. All Rights Reserved. +# Copyright (c) 2013, Savoir-faire Linux inc. All Rights Reserved. + +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301 USA + +from unittest import TestCase + +from num2words import num2words + + +class Num2WordsENINTest(TestCase): + def test_cardinal(self): + self.assertEqual(num2words(1e5, lang="en_NP"), "one lakh") + self.assertEqual(num2words(1e6, lang="en_NP"), "ten lakh") + self.assertEqual(num2words(1e7, lang="en_NP"), "one crore") + self.assertEqual(num2words(1e8, lang="en_NP"), "ten crore") + self.assertEqual(num2words(1e9, lang="en_NP"), "one arba") + self.assertEqual(num2words(1e10, lang="en_NP"), "ten arba") + self.assertEqual(num2words(1e11, lang="en_NP"), "one kharba") + self.assertEqual(num2words(1e12, lang="en_NP"), "ten kharba") + self.assertEqual(num2words(1e13, lang="en_NP"), "one neel") + self.assertEqual(num2words(1e14, lang="en_NP"), "ten neel") + self.assertEqual(num2words(1e15, lang="en_NP"), "one padam") + self.assertEqual(num2words(1e16, lang="en_NP"), "ten padam") + self.assertEqual(num2words(1e17, lang="en_NP"), "one shankha") + self.assertEqual(num2words(1e18, lang="en_NP"), "ten shankha") +