A Comprehensive NPM Package for Nepali Province and Cities
nepali
is an npm package that provides comprehensive functionality for accessing information about Nepali provinces, cities, and related data as well as utilities for working with Nepali dates. This package facilitates easy conversion between English and Nepali names for provinces, cities, and other geographical entities within Nepal. It also includes functions to work with Nepali dates.
You can install nepali
via npm:
npm install nepali
import {
getAllProvinces,
getProvinceDetails,
getCapital,
getDistricts,
getCities,
getZipcode,
getAllMetropolitanCities,
getAllSubMetropolitanCities
} from 'nepali/povince';
Get all Province
, Metropolitan Cities
and Sub-Metropolitan Cities
names in Nepali
import React from 'react';
import {
getAllProvinces,
getProvinceDetails,
getCapital,
getDistricts,
getCities,
getZipcode,
getAllMetropolitanCities,
getAllSubMetropolitanCities
} from 'nepali/province';
const NepalProvince = () => {
// Scenario 0: Get all province names in Nepali
const allProvincesNepali = getAllProvinces();
// Scenario 1: Get province details in Nepali
const provinceDetailsNepali = getProvinceDetails("Koshi Pradesh");
// Scenario 2: Get cities in Nepali for Koshi Pradesh
const citiesProvince1Nepali = getCities("Koshi Pradesh");
// Scenario 3: Get capital in Nepali for Koshi Pradesh
const capitalProvince1Nepali = getCapital("Koshi Pradesh");
// Scenario 4: Get districts in Nepali for Koshi Pradesh
const districtsProvince1Nepali = getDistricts("Koshi Pradesh");
// Scenario 5: Get zip codes in Nepali for Biratnagar
const zipCodeBiratnagarNepali = getZipcode("Biratnagar");
// Check if zipCodeBiratnagarNepali is an array
const isArray = Array.isArray(zipCodeBiratnagarNepali);
// Scenario 7: Get all Metropolitan Cities
const allMetropolitanCities = getAllMetropolitanCities();
// Scenario 8: Get all Sub-Metropolitan Cities
const allSubMetropolitanCities = getAllSubMetropolitanCities();
return (
<div>
<h1>Scenario 0: All Province Names in Nepali</h1>
<ul>
{allProvincesNepali.map((province, index) => (
<li key={index}>{province.name}</li>
))}
</ul>
<h1>Scenario 1: Province Details in Nepali</h1>
{provinceDetailsNepali && (
<div>
<p>Province Name: {provinceDetailsNepali.name}</p>
<p>Capital: {provinceDetailsNepali.capital}</p>
<p>Cities: {provinceDetailsNepali.cities.map((city, index) => (
<span key={index}>{city.name} ({city.zipCode}), </span>
))}</p>
<p>Districts: {provinceDetailsNepali.districts.join(', ')}</p>
</div>
)}
<h1>Scenario 2: Cities in Nepali for Koshi Pradesh</h1>
<ul>
{citiesProvince1Nepali.map((city, index) => (
<li key={index}>{city.name} - {city.zipCode} ({city.type})</li>
))}
</ul>
<h1>Scenario 3: Capital in Nepali for Koshi Pradesh</h1>
<p>{capitalProvince1Nepali}</p>
<h1>Scenario 4: Districts in Nepali for Koshi Pradesh</h1>
<ul>
{districtsProvince1Nepali.map((district, index) => (
<li key={index}>{district}</li>
))}
</ul>
<h1>Scenario 5: Zip Codes in Nepali for Biratnagar</h1>
<ul>
{isArray ? (
zipCodeBiratnagarNepali.map((zipcode, index) => (
<li key={index}>
{zipcode.name} - {zipcode.zipCode} ({zipcode.type})
</li>
))
) : (
<li>{zipCodeBiratnagarNepali}</li>
)}
</ul>
<h1>Scenario 7: All Metropolitan Cities</h1>
<ul>
{allMetropolitanCities.map((city, index) => (
<li key={index}>{city.name} - {city.zipCode}</li>
))}
</ul>
<h1>Scenario 8: All Sub-Metropolitan Cities</h1>
<ul>
{allSubMetropolitanCities.map((city, index) => (
<li key={index}>{city.name} - {city.zipCode}</li>
))}
</ul>
</div>
);
};
export default NepalProvince;
import {
getCurrentNepaliDate,
getCurrentNepaliDay,
getCurrentNepaliMonth,
getCurrentNepaliYear,
getCurrentNepaliDayOfWeek,
convertADToNepaliDate,
formatNepaliDate
} from 'nepali/dates';
import {
getCurrentNepaliDate,
getCurrentNepaliDay,
getCurrentNepaliMonth,
getCurrentNepaliYear,
getCurrentNepaliDayOfWeek,
convertADToNepaliDate,
formatNepaliDate
} from 'nepali/dates';
const NepaliDateComponent = () => {
return (
<div>
<h1>Current Nepali Date</h1>
<p>{getCurrentNepaliDate()}</p>
<h2>Nepali Date Details</h2>
<p>Day: {getCurrentNepaliDay()}</p>
<p>Month: {getCurrentNepaliMonth()}</p>
<p>Year: {getCurrentNepaliYear()}</p>
<p>Day of the Week: {getCurrentNepaliDayOfWeek()}</p>
<h2>Formatted Nepali Date</h2>
<p>{formatNepaliDate(convertADToNepaliDate(1997, 10, 5), 'YYYY-MM-DD')}</p>
</div>
);
};
export default NepaliDateComponent;
This project is licensed under the MIT License - see the LICENSE file for details.