thai-english-text-toggler
v1.0.2
Published
Library สำหรับสลับตัวอักษรภาษาไทยและอังกฤษสำหรับแก้ไขปัญหาลืมเปลี่ยนภาษาตอนพิมพ์
Downloads
4
Maintainers
Readme
Thai English Text Toggler
A JavaScript library for toggling between Thai and English text - perfect for fixing "forgot to change language" typing mistakes.
Installation
npm install thai-english-text-togglerUsage
Basic Usage
const { toggleThaiEnglishStringInput } = require('thai-english-text-toggler');
// Example 1: English to Thai
const englishText = 'l;ylfu';
console.log(toggleThaiEnglishStringInput(englishText)); // สวัสดี
// Example 2: Thai to English
const thaiText = 'าพีิ';
console.log(toggleThaiEnglishStringInput(thaiText)); // krub
// Example 3: Mixed text with context-aware conversion
const mixedText = ']n,gx]ujpo4kKk น้ ืน';
console.log(toggleThaiEnglishStringInput(mixedText)); // ลืมเปลี่ยนภาษา oh no
API Reference
toggleThaiEnglishStringInput(input)
Converts text between Thai and English keyboard layouts with smart context detection.
Parameters:
input(string): The text to toggle
Returns:
- (string): The converted text
Example:
toggleThaiEnglishStringInput('l;ylfu'); // Returns: สวัสดี
toggleThaiEnglishStringInput('สวัสดี'); // Returns: l;ylfuSupported Characters
- All Thai consonants (ก-ฮ)
- Thai vowels and tone markers
- Thai numbers (๐-๙)
- English letters (a-z, A-Z)
- Numbers (0-9)
- Special characters and punctuation
- Context-aware handling of ambiguous mappings
Development
Running Tests
npm testProject Structure
thai-english-text-toggler/
├── index.js # Main entry point
├── utils/
│ ├── text-toggler.js # Core conversion logic
├── data/
│ ├── thai-english-keyboard-text-dictionary.json # Character mappings
│ └── duplicate-mappings.json # Context-aware duplicate mappings
└── test/
└── utils/
├── text-toggler.test.js # Core functionality testsUse Cases
- Fix "forgot to change language" typing mistakes
- Text processing applications
- Keyboard layout conversion tools
- Thai-English bilingual applications
- Input validation and text normalization
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feat/amazing-feature) - Commit your changes (
git commit -m 'feat: Add some amazing feature') - Push to the branch (
git push origin feat/amazing-feature) - Open a Pull Request
Repository
GitHub: https://github.com/Fill-IT/thai-english-text-toggler
License
MIT
Keywords
thai, english, ลืมเปลี่ยนภาษา, forget, to, change, language, text, toggler, keyboard, layout, conversion
