npm package: @myanmartools/ng-translit
Description: Transliteration core service package for Angular applications which can be used in font encodings conversion such as Zawgyi to Myanmar Unicode.
Author: DagonMetric
Latest version: 1.0.0
Deprecated: This package has been moved to @dagonmetric/ng-transliterate. Please use it instead.

[![Build Status](https://dev.azure.com/myanmartools/ng-translit/_apis/build/status/myanmartools.ng-translit?branchName=master)](https://dev.azure.com/myanmartools/ng-translit/_build/latest?definitionId=1&branchName=master)
[![Build status](https://ci.appveyor.com/api/projects/status/r4t2e94rcolaw326?svg=true)](https://ci.appveyor.com/project/admindagonmetriccom/ng-translit)

# Transliteration Core Package for Angular

[![Gitter](https://badges.gitter.im/myanmartools/community.svg)](https://gitter.im/myanmartools/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

Transliteration core service package for Angular applications which can be used in font encodings conversion such as Zawgyi to Myanmar Unicode.

## Features

* Transliterate rules can be loaded dynamically or statically (lazily or eagerly) using custom TranslitRuleLoader
* Extendable TranslitRuleLoader (see built-in [HttpTranslitRuleLoader](https://github.com/myanmartools/ng-translit/blob/master/modules/ng-translit/http-loader/src/http-translit-rule-loader.ts) for implementation demo)
* Latest Angular versions are supported
* Compatible with Angular Universal (Server Side Rendering - SSR)

## Get Started

### Installation

npm

```shell
npm install @myanmartools/ng-translit
```

or yarn

```shell
yarn add @myanmartools/ng-translit
```

### Module Setup (app.module.ts)

```typescript
import { TranslitModule } from '@myanmartools/ng-translit';
import { HttpTranslitRuleLoaderModule } from '@myanmartools/ng-translit/http-loader';

export function translitEndpointFactory(baseUrl: string, sourceEnc: string, targetEnc: string): string {
    const prefix = sourceEnc === 'zg' ? 'zawgyi-to-unicode-rules/' : 'unicode-to-zawgyi-rules/';

    return `${baseUrl}${prefix}${sourceEnc}2${targetEnc}.json`;
}

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

        // ng-translit
        TranslitModule,
        HttpTranslitRuleLoaderModule.withOptions({
            baseUrl: 'https://raw.githubusercontent.com/myanmartools/zawgyi-unicode-translit-rules/master/rules/',
            endpointFactory: translitEndpointFactory
        })
    ]
})
export class AppModule { }
```

### Usage (app.component.ts)

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

import { TranslitService } from '@myanmartools/ng-translit';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html'
})
export class AppComponent {
    sourceEnc = 'zg';
    targetEnc = 'uni';

    constructor(private readonly _translitService: TranslitService) {
        this._translitService.translit('ျမန္မာစာ', this.sourceEnc, this.targetEnc)
            .subscribe(result => {
                // output: မြန်မာစာ
                console.log('output: ', result.outputText);
            });
    }
}
```

### Installing Translit Rules Locally (Optional)

Transliterate rules can be installed locally, for example, to install Zawgyi Unicode conversion rules:

```shell
npm install @myanmartools/zawgyi-unicode-translit-rules
```

## Example

[Demo](https://github.com/myanmartools/ng-translit/tree/master/samples/ng-translit-demo) - demo Angular application for ng-translit

## Real-word Application - Zawgyi Unicode Converter

[![Zawgyi Unicode Converter](https://zawgyi-unicode-converter.myanmartools.org/assets/images/appicons/v1/android/android-launchericon-192x192.png)](https://zawgyi-unicode-converter.myanmartools.org)

[Zawgyi Unicode Converter](https://zawgyi-unicode-converter.myanmartools.org) is an Angular Progress Web Application (PWA) designed to detect & convert Myanmar font encodings between Zawgyi-One and Unicode.

## Related Projects

These are some other repos for related projects:

* [myanmartools/zawgyi-unicode-translit-rules](https://github.com/myanmartools/zawgyi-unicode-translit-rules) - contains Zawgyi Unicode convert/translit rules in JSON format.

* [myanmartools/ng-zawgyi-detector](https://github.com/myanmartools/ng-zawgyi-detector) - contains Zawgyi-One / Myanmar Unicode font encoding detection modules for Angular.

## Myanmar Tools Website

[![Myanmar Tools Website](https://myanmartools.org/assets/images/appicons/v1/android/android-launchericon-192x192.png)](https://myanmartools.org)

[https://myanmartools.org](https://myanmartools.org)

A list of open source projects for Myanmar specific software applications, libraries, productivity utilities, language, script, Unicode and font tools.

## Feedback and Contributing

Check out the [Contributing](https://github.com/myanmartools/ng-translit/blob/master/CONTRIBUTING.md) page to see the best places to log issues and start discussions.

## License

This repository is licensed with the [MIT](https://github.com/myanmartools/ng-translit/blob/master/LICENSE) license.