From d447f456ba1676afdb631debc012729c72557bc5 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Fri, 30 Jan 2026 18:29:26 +0545 Subject: [PATCH] feat: add English datepicker support and comprehensive documentation improvements This commit adds English language support to the datepicker widget and includes major documentation enhancements with proper attribution. New Features: - add English language option to nepali-datepicker widget (language: 'english') - datepicker now respects en=True field parameter for English month/day names - automatic language detection based on DEFAULT_LANGUAGE setting Documentation: - add Credits section acknowledging nepali package and nepali-datepicker library - improve FAQ formatting with proper spacing between questions Bug Fixes: - fix datepicker language selection logic to properly prioritize English mode - correct nepali package attribution to opensource-nepal/py-nepali - update nepali-datepicker GitHub link to correct repository Technical Details: - datepicker initialization now checks data-en attribute - language priority: explicit ne=true > explicit en=true > default (English) - English mode displays transliterated BS month names and Arabic numerals --- README.md | 20 +++++++++++++++---- .../js/nepali-datepicker-init.js | 11 ++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b629222..7000e38 100644 --- a/README.md +++ b/README.md @@ -169,11 +169,16 @@ Just like standard Django fields, pass `null=True, blank=True` to any `django-ne No. The `YYYY-MM-DD` format is hardcoded to ensure database-level sorting and indexing work consistently. However, you can change the **display** format via global settings or template filters. -**Q: How do I get Devanagari (local script) digits in my API?** +**Q: Can I use Devanagari output?** + +Yes. Pass `ne=True` to fields, forms, or serializers. + +**Q: Can I display the datepicker in English?** + +Yes. By default, if you pass `en=True` (or if `DEFAULT_LANGUAGE` is set to `"en"`), the datepicker will display month and day names in English instead of Devanagari script. -In your Serializer field or Model field, pass `ne=True`. ```python -birth_date = NepaliDateField(ne=True) +birth_date = NepaliDateField(en=True) # English month/day names in picker ``` **Q: Is the location data up to date?** @@ -204,6 +209,13 @@ We welcome contributions and feedback from the community. --- -## 📄 License +## 🙏 Credits + +This library is built on top of excellent open-source projects: + +- **[nepali](https://github.com/opensource-nepal/py-nepali)** by [@opensource-nepal](https://github.com/opensource-nepal) - Provides the core `nepalidate`, `nepalidatetime` objects and regional location data (Provinces, Districts, Municipalities). +- **[Nepali Datepicker](https://nepalidatepicker.sajanmaharjan.com.np/)** by [Sajan Maharjan](https://github.com/sajanm/nepali-date-picker) - Powers the beautiful BS date picker widget in the Django Admin. + +--- MIT License. Designed for the local Django ecosystem. diff --git a/django_nepkit/static/django_nepkit/js/nepali-datepicker-init.js b/django_nepkit/static/django_nepkit/js/nepali-datepicker-init.js index 20ab299..a49063f 100644 --- a/django_nepkit/static/django_nepkit/js/nepali-datepicker-init.js +++ b/django_nepkit/static/django_nepkit/js/nepali-datepicker-init.js @@ -54,9 +54,16 @@ closeOnDateSelect: true }; - // Use Devanagari if data-ne attribute is present - if (el.dataset.ne === 'true') { + // Determine language based on data attributes + var useNepali = el.dataset.ne === 'true'; + var useEnglish = el.dataset.en === 'true'; + + if (useNepali) { + // Devanagari digits and Nepali month/day names options.unicodeDate = true; + } else if (useEnglish || (!useNepali && !el.dataset.ne)) { + // English month/day names and digits + options.language = 'english'; } // Nepali Datepicker v5 exposes `element.NepaliDatePicker(options)`