Skip to content
Moe Myat Zaw edited this page Jun 7, 2019 · 3 revisions

Transliteration Service for Angular

The ng-translit is a transliteration service for Angular applications which can be used in swapping letters such as α → a, ၎ → ၎င်း or Zawgyi-One to standard Myanmar Unicode.

Get Started

Installation

npm

npm install @dagonmetric/ng-translit

or yarn

yarn add @dagonmetric/ng-translit

Module Setup (app.module.ts)

The following code is a simple module setup with no rule loader.

import { TranslitModule } from '@dagonmetric/ng-translit';

@NgModule({
  imports: [
    // Other module imports

    // ng-translit module
    TranslitModule
  ]
})
export class AppModule { }

Usage (app.component.ts)

import { Component } from '@angular/core';

import { TranslitRuleItem, TranslitService } from '@dagonmetric/ng-translit';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html'
})
export class AppComponent {
  constructor(private readonly _translitService: TranslitService) {
    const zg2uniRules: TranslitRuleItem[] = [{
      from: '\u103B([\u1000-\u1021])',
      to: '$1\u103C'
    },
    {
      from: '\u1039',
      to: '\u103A'
    }];

    this._translitService.translit('ျမန္မာစာ', 'zg2uni', zg2uniRules)
      .subscribe(result => {
        // output: မြန်မာစာ
        console.log('output: ', result.outputText);
      });
  }
}

More Topics