nepali

1.0.2 • Public • Published

nepali

A Comprehensive NPM Package for Nepali Province and Cities

Table of Contents

Introduction

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.

Installation

You can install nepali via npm:

npm install nepali

Usage

Importing province functions

import {
    getAllProvinces,
    getProvinceDetails,
    getCapital,
    getDistricts,
    getCities,
    getZipcode,
    getAllMetropolitanCities,
    getAllSubMetropolitanCities
} from 'nepali/povince';

Example usage for provinces and cities

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;

Importing the date functions

import { 
    getCurrentNepaliDate, 
    getCurrentNepaliDay, 
    getCurrentNepaliMonth, 
    getCurrentNepaliYear, 
    getCurrentNepaliDayOfWeek,
    convertADToNepaliDate,
    formatNepaliDate 
} from 'nepali/dates';

Example Usage for 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;

License

This project is licensed under the MIT License - see the LICENSE file for details.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.212latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.212
1.0.10
1.0.00

Package Sidebar

Install

npm i nepali

Weekly Downloads

12

Version

1.0.2

License

MIT

Unpacked Size

32.4 kB

Total Files

10

Last publish

Collaborators

  • anish-gyawali