# PACKAGE: @nofinite/locale
Lightweight localization, country lookups, dialing codes, and flag utilities.
You are using @nofinite/locale for localization, currencies, and country lookups.
---
### Document: locale/installation/page.mdx
# Installation & Setup
Complete guide to installing and using **Nofinite Locale** in Node.js, modern web runtimes, and frontend frameworks.
---
## 1. Package Installation
Install `@nofinite/locale` using your preferred package manager:
```bash
# pnpm
pnpm add @nofinite/locale
# npm
npm install @nofinite/locale
# yarn
yarn add @nofinite/locale
# bun
bun add @nofinite/locale
```
> [!NOTE]
> **Zero Runtime Dependencies:** `@nofinite/locale` has **0 external runtime dependencies**. It executes natively on any JavaScript engine (Node.js `>= 18`, Cloudflare Workers, Deno, Bun, and all modern browsers).
---
## 2. Flag Stylesheet (Optional)
If your application renders SVG country flags, import the lightweight flag stylesheet:
```ts
import '@nofinite/locale/style';
```
Or in your HTML via CDN:
```html
```
---
## 3. Verify Installation
### In Node.js / TypeScript / Vanilla DOM
```ts
import { getCountryByCode, getCountryByDialCode, countries } from '@nofinite/locale';
// Lookup metadata for a country by ISO-2 code
const country = getCountryByCode('US');
console.log(country);
// { name: 'United States', iso2: 'US', dialCode: '+1' }
// Total countries in catalog
console.log(`Loaded ${countries.length} countries.`);
```
### In Plain HTML via CDN
```html
```
---
## Next Steps
- Explore the [Country Lookup API](/locale/usage/country-lookup) for searching and filtering country data.
- Learn how to render [SVG Flags](/locale/usage/flags) using optimized CSS classes.
---
### Document: locale/llms/page.mdx
# LLMs.txt Documentation
How to get tools like Cursor, Windsurf, GitHub Copilot, ChatGPT, and Claude to understand `@nofinite/locale`.
> [!TIP]
> Looking for unified ecosystem presets or multi-package rules? Visit our central [AI Agents Hub](/ai).
We support **LLMs.txt** files for making `@nofinite/locale` country and localization utilities directly available to large language models.
---
## Directory Overview
The following machine-readable context files are available:
- [`/locale/llms.txt`](/locale/llms.txt): The main LLMs index for `@nofinite/locale`.
- [`/locale/llms-full.txt`](/locale/llms-full.txt): Complete context bundle containing ISO country lookups, dialing codes, and SVG flags.
- [`/llms.txt`](/llms.txt): Ecosystem index covering all 8 `@nofinite` libraries.
- [`/llms-full.txt`](/llms-full.txt): The unified ecosystem bundle.
---
## Usage with Cursor & Windsurf
```markdown
# Locale Rules for AI Assistants
1. Package Imports: Import country utilities and metadata from `@nofinite/locale` (zero dependencies, framework-agnostic).
2. Flag Stylesheet: Import `@nofinite/locale/style` and use `.nf-flag` and `.nf-flag-{iso}` classes (pure CSS/SVG).
3. Use ISO-3166-1 alpha-2 codes (e.g. `US`, `GB`, `IN`, `DE`) for standardized country lookups and flags.
```
---
### Document: locale/page.mdx
Dial Code: {activeCountry.dialCode}
)} ); } ``` --- ## API Summary | Export | Type | Description | | :--- | :--- | :--- | | [`countries`](/locale/usage/country-lookup) | `Country[]` | Array of all countries with name, ISO2, and dialCode | | [`getCountryByCode(iso)`](/locale/usage/country-lookup) | `(iso: string) => Country \| undefined` | Resolves country metadata by ISO-2 code | | [`getCountryByDialCode(code)`](/locale/usage/country-lookup) | `(dialCode: string) => Country \| undefined` | Resolves country metadata by phone dial code | | [`@nofinite/locale/style`](/locale/usage/flags) | Stylesheet | Optimized SVG flag sprites and utility classes | --- ## Next Steps - Follow the [Installation Guide](/locale/installation) to install and configure the package. - Explore [Country Lookup](/locale/usage/country-lookup) for country filtering and search recipes. - Explore [SVG Flags](/locale/usage/flags) for flag sizing, styling, and form integration. --- ### Document: locale/releases/page.mdx # Locale Releases **Latest version:** `v1.0.0` (25 December 2025) --- ## Summary Initial stable release of **Locale**. **Locale** is a lightweight TypeScript library providing standardized country metadata, flags, and international dialing codes for web applications. --- ## Included - Country metadata (name, ISO code, dial code) - Type-safe country lookup utilities - CSS-based SVG flag assets and utility classes - Support for modern frameworks and plain HTML usage - Dual distribution (ESM & CJS) with optional CDN inclusion --- ## Notes - Establishes the public API surface for locale data usage. - Designed for integration in both library and application contexts. - No breaking changes prior to this release. --- ### Document: locale/usage/country-lookup/page.mdx # Country Lookup Nofinite Locale provides simple helper functions to retrieve country information. ## Lookup by ISO Code or Dial Code ### JavaScript / TypeScript ```ts import { getCountryByCode, getCountryByDialCode } from '@nofinite/locale'; // Lookup by ISO-2 code (case-insensitive) const india = getCountryByCode('IN'); // Lookup by dial code const indiaAlt = getCountryByDialCode('+91'); // or const indiaAlt2 = getCountryByDialCode('91'); console.log(india); ``` **Returned object structure:** ```ts { name: "India", iso2: "IN", dialCode: "+91" } ``` ### HTML (CDN) ```html ``` --- ### Document: locale/usage/flags/page.mdx # SVG Flag Icons **Nofinite Locale** provides lightweight, CSS-driven SVG flag icons for 240+ international countries and territories. The stylesheet bundles vectorized country flag sprites that scale cleanly, eliminating the need to serve hundreds of loose PNGs or make external network requests. --- ## 1. Import Styles ### In JavaScript / TypeScript Entry ```ts import '@nofinite/locale/style'; ``` ### In Plain HTML / CDN ```html ``` --- ## 2. CSS Flag Classes | Class | Description | | :--- | :--- | | `.nf-flag` | Base flag container (required) | | `.nf-flag-{iso}` | Target country by lowercase ISO-2 code (e.g. `nf-flag-us`, `nf-flag-in`, `nf-flag-de`) | | `.square` | Optional modifier for square (1:1) aspect ratio | --- ## 3. Usage in Vanilla HTML (Core First) ### Standard 4:3 Flag ```html ``` ### Square 1:1 Flag ```html ``` ### Embedded in Buttons & Form Controls ```html ``` --- ## 4. Usage in React ```tsx 'use client'; import React from 'react'; import '@nofinite/locale/style'; interface FlagProps { iso: string; square?: boolean; className?: string; } export function Flag({ iso, square = false, className = '' }: FlagProps) { const normalized = iso.toLowerCase(); const squareClass = square ? 'square' : ''; return ( ); } // Example usage export function LanguageSelector() { return ( ); } ``` ---