Skip to content

Add Nepali language support (ne, en_NE) with Devanagari script and test coverage#652

Open
sparshrestha wants to merge 2 commits intosavoirfairelinux:masterfrom
sparshrestha:feat/add-nepali-language-support
Open

Add Nepali language support (ne, en_NE) with Devanagari script and test coverage#652
sparshrestha wants to merge 2 commits intosavoirfairelinux:masterfrom
sparshrestha:feat/add-nepali-language-support

Conversation

@sparshrestha
Copy link
Copy Markdown

@sparshrestha sparshrestha commented Feb 4, 2026

This pull request adds new language support for both the Nepali numbering system (in Devanagari script) and the English (Nepal) words.

Changes proposed in this pull request:

  • lang_NE.py - Native Nepali (ne) with Devanagari script output

    • Cardinal numbers (0-99 direct lookup, larger numbers via composition)
    • Ordinal numbers with Nepali suffixes (पहिलो, दोस्रो, तेस्रो, etc.)
    • Nepali numbering system: लाख (10^5), करोड (10^7), अर्ब (10^9), खर्ब (10^11)
    • Currency support: NPR (रुपैयाँ/पैसा), USD, EUR
    • Negative numbers with माइनस prefix
  • lang_EN_NE.py - English (Nepal) variant (en_NE)

    • English words with Nepali/South Asian numbering system
    • Extends additional scale: shankha (10^17), padam (10^15), neel (10^13)

Testing:

  • tests/test_ne.py - Devanagari tests

    • Direct cardinal lookup (1-99) with proper Nepali numerals
    • Scale words: हजार, लाख, करोड, अर्ब, खर्ब
    • Complex multi-scale numbers (999,999,999,999)
    • Ordinal conversions, currency conversions with fractional parts
    • Negative numbers, string inputs, float truncation
    • 99999 - उनान्सय हजार नौ सय उनान्सय
  • tests/test_en_ne.py - English (Nepal) variant tests

    • Powers of 10 from lakh (10^5) to shankha (10^17)
    • 12345678 - one crore, twenty-three lakh, forty-five thousand, six hundred and seventy-eight

Nepali (ne) Features:

  • Full Devanagari numeral vocabulary (शून्य to उनान्सय for 0-99)
  • Proper compound word formation without hyphens (एक सय, दुई लाख)
  • Currency precision handling with is_int_with_cents=False

English Nepal (en_NE) Features:

  • Inherits from Num2Word_EN base with modified scale dictionary
  • Maintains English cardinal/ordinal rules with Nepali grouping

Status

  • READY
  • HOLD
  • WIP (Work-In-Progress)

How to verify this change

Run tests locally:

# Test Nepali (Devanagari)
python -m pytest tests/test_ne.py -v

# Test English (Nepal)
python -m pytest tests/test_en_ne.py -v

# Verify code formatting
tox -e isort

Additional notes

If applicable, explain the rationale behind your change.

The dual implementation (ne for native Devanagari, en_NE for English with Nepali numbering) addresses both official documentation needs and business communication contexts where English text follows Nepali's lakh/crore conventions. This closes a critical gap in South Asian language support, enabling proper localization of accounting software (eg: Frappe ERPNext), banking applications, and government e-governance systems serving Nepal's market.

Integration with Frappe Framework:

The Frappe Framework already implements Nepali number system formatting for display purposes (see frappe/public/js/frappe/utils/number_systems.js) with abbreviations like Kh (Kharba), Ar (Arba), Cr (Crore), and L (Lakh).

However, the critical in_words() function in frappe/utils/data.py cannot convert Nepali numbers to words because num2words lacks ne or en_NE locale support.

This PR directly addresses it. Once merged, ERPNext and Frappe-based applications can properly generate invoices, purchase orders, and payment vouchers with Nepali word representations. The implementation follows Frappe's existing pattern where get_number_system('Nepal') returns the Nepali system, but extends it to actual word conversion rather than just display formatting.

Also, extends to #548
References:
Nepali numbers (नेपाली गणना)
Numbers in Nepali language - Wikipedia

@sparshrestha sparshrestha marked this pull request as ready for review February 4, 2026 07:56
@sparshrestha
Copy link
Copy Markdown
Author

sparshrestha commented Feb 5, 2026

@savoirfairelinux @mrodriguezg1991
Please review this PR.

@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 98.088% (-0.1%) from 98.189%
when pulling 03eed40 on sparshrestha:feat/add-nepali-language-support
into 07814cb on savoirfairelinux:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants