-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Moe Myat Zaw edited this page Jun 7, 2019
·
3 revisions
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.
npm
npm install @dagonmetric/ng-translit
or yarn
yarn add @dagonmetric/ng-translit
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 { }
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);
});
}
}