@tm11/mmgeo
Version:
A comprehensive package providing states, districts, and townships data for Myanmar in both English and Myanmar languages.
139 lines (100 loc) • 3.25 kB
Markdown
**@tm11/mmgeo** is a lightweight and comprehensive NPM package that provides geographic data for Myanmar, including states, districts, and townships. The data is available in both English and Myanmar languages, making it perfect for localization purposes in Myanmar-based applications.
- Complete geographic data for Myanmar (states, districts, and townships)
- Bilingual support (English and Myanmar languages)
- TypeScript support with full type definitions
- Simple and intuitive API
- Lightweight package with minimal dependencies
- Easy language switching functionality
## Installation
You can install this package using NPM:
```bash
npm install @tm11/mmgeo
```
Or with Yarn:
```bash
yarn add @tm11/mmgeo
```
[](https://www.npmjs.com/package/@tm11/mmgeo) [](https://www.npmjs.com/package/@tm11/mmgeo)
## Quick Start
```typescript
import { initialize, getStates } from '@tm11/mmgeo';
// Initialize with English language (default)
initialize({ language: 'en' });
// Get all states
const states = getStates();
console.log(states[0].en); // "Kachin State"
// Switch to Myanmar language
initialize({ language: 'mm' });
console.log(states[0].mm); // Myanmar name
```
```typescript
interface State {
en: string; // English name
mm: string; // Myanmar name
lat: number; // Latitude
lng: number; // Longitude
capital: string; // Capital city
districts: District[];
}
interface District {
en: string; // English name
mm: string; // Myanmar name
townships: Township[];
}
interface Township {
en: string; // English name
mm: string; // Myanmar name
}
```
Initialize the package with configuration options.
```typescript
interface ConfigOptions {
language: 'en' | 'mm'; // Language setting
}
```
Example:
```typescript
import { initialize } from '@tm11/mmgeo';
// Set language to Myanmar
initialize({ language: 'mm' });
```
Returns an array of all states in Myanmar.
Returns districts for a specific state.
Returns townships for a specific district.
```typescript
import { initialize, getStates } from '@tm11/mmgeo';
// Initialize in English
initialize({ language: 'en' });
// Get all states
const states = getStates();
console.log(states[0].en); // "Kachin State"
```
```typescript
import { initialize, getStates } from '@tm11/mmgeo';
// Start with English
initialize({ language: 'en' });
const statesEn = getStates();
console.log(statesEn[0].en); // "Kachin State"
// Switch to Myanmar
initialize({ language: 'mm' });
const statesMm = getStates();
console.log(statesMm[0].mm); // Myanmar name
```
Contributions are welcome! Please feel free to submit a Pull Request.
This package is licensed under the ISC License. See the [LICENSE](LICENSE) file for more information.