1.0.2 • Published 7 months ago

smart-locale-formatter v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

Smart Locale Formatter

A lightweight and powerful utility for locale-aware formatting of dates, numbers, and currencies.

Features

  • Automatically detect the user's locale.
  • Format dates, numbers, and currencies for specific locales.
  • Support for fallback locale in case of unsupported formatting.

Installation

npm install smart-locale-formatter

Usage

Detect Locale

import { detectLocale } from 'smart-locale-formatter';

const locale = detectLocale();
console.log(locale); // Output: en-US or system-detected locale

Format Date

import { formatDate } from 'smart-locale-formatter';

const formattedDate = formatDate(new Date('2023-01-02'), 'en-US');
console.log(formattedDate); // Output: 1/2/2023

Format Number

import { formatNumber } from 'smart-locale-formatter';

const formattedNumber = formatNumber(1234567.89, 'de-DE');
console.log(formattedNumber); // Output: 1.234.567,89

Format Currency

import { formatCurrency } from 'smart-locale-formatter';

const formattedCurrency = formatCurrency(1000.5, 'USD', 'en-US');
console.log(formattedCurrency); // Output: $1,000.50

Git Workflow

Clone the Repository

git clone https://github.com/rathoraashish/smart-locale-formatter.git

Create a Feature Branch

git checkout -b feature/your-feature

Commit Changes

git add .
git commit -m "Add a meaningful commit message"

Push to Remote

git push origin feature/your-feature

License

This project is licensed under the MIT License.

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago