# Singlish to Sinhala Converter (v 1.3.5)

A real-time Singlish (Romanized Sinhala) to Sinhala Unicode converter for web input fields.

## Features

- Convert Singlish text to Sinhala as you type
- Works with all input fields, textareas, and contenteditable elements
- Toggle conversion on/off with a floating button
- Adjustable typing speed (Slow, Moderate, Fast) via settings in the toggle
- Remembers user preferences (enabled state and typing speed) via localStorage
- Comprehensive character mapping covering all Sinhala characters
- Adapts to dynamically added input elements
- Multiple export formats (ES Module, CommonJS, UMD)

## Installation

```bash
npm install singlish-to-sinhala
```

## Usage

### Basic Usage

```javascript
// ES Modules
import singlishToSinhala from 'singlish-to-sinhala';

// Initialize with default options
const sinhala = singlishToSinhala();

// Or with custom options
const sinhalaCustom = singlishToSinhala({
  autoAddToggle: true,
  togglePosition: 'top-right',
  startEnabled: true
});
```

### In HTML (via CDN)

```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/singlish-to-sinhala/dist/sinhala-toggle.css">
<script src="https://cdn.jsdelivr.net/npm/singlish-to-sinhala/dist/singlish-to-sinhala.min.js"></script>
<script>
  // Initialize
  const sinhala = SinglishToSinhala();
</script>
```

### API Reference

The library returns an API object with the following methods:

```javascript
// Enable Singlish to Sinhala conversion
sinhala.enable();

// Disable conversion
sinhala.disable();

// Check if conversion is enabled
const isEnabled = sinhala.isEnabled();

// Toggle conversion on/off
sinhala.toggle();

// Set the typing speed
// Speed can be 'slow', 'moderate', or 'fast'
sinhala.setTypingSpeed('fast');

// Get the current typing speed
const currentSpeed = sinhala.getTypingSpeed(); // Returns 'slow', 'moderate', or 'fast'
```

## Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| autoAddToggle | boolean | true | Automatically add the toggle button |
| togglePosition | string | 'bottom-right' | Position of toggle ('top-right', 'top-left', 'bottom-right', 'bottom-left') |
| startEnabled | boolean | false | Start with conversion enabled |

## Writing Singlish

Type Singlish text in any input field, and it will be converted to Sinhala in real-time. Here are some examples:

- `mama` → `මම`
- `oyaata kohomada` → `ඔයාට කොහොමද`
- `aayuboewan lankawa` → `ආයුබෝවන් ලංකාව`

## Browser Support

Supported in all modern browsers:

- Chrome
- Firefox
- Safari
- Edge

## License

MIT