Skip to content

TranslitModule

Moe Myat Zaw edited this page Jun 7, 2019 · 1 revision

The transliteration NGMODULE for TranslitService.

export class TranslitModule {
  static forRootWithOptions(options: TranslitOptions): ModuleWithProviders

  static forChildWithOptions(options: TranslitOptions): ModuleWithProviders
}

Static methods

forRootWithOptions

Call this method to provide options for configuring the TranslitModule in root app module.

static forRootWithOptions(
  options: TranslitOptions = { shareCachedRules: true }): ModuleWithProviders
Parameters
  • options - An object of configuration options of type TranslitOptions.
TranslitOptions
/**
 * The TranslitOptions interface.
 */
export interface TranslitOptions {
  /**
   * Default `true`, if true provide `TranslitRuleStore` to share cache rules across modules.
   */
  shareCachedRules?: boolean;
  /**
   * If true, conversion trace information will be included in the transliteration result.
   */
  trace?: boolean;
}

forChildWithOptions

Call this method to provide options for configuring the TranslitModule in child modules.

static forRootWithOptions(
  options: TranslitOptions = { shareCachedRules: true }): ModuleWithProviders

Providers

  • TranslitService - The TranslitService class is a core transliteration service for swapping letters from one script to another and it will be provided by default.

  • TranslitRuleStore - The TranslitRuleStore service class to store loaded rules in application scope which will be provided when calling either forRootWithOptions or forChildWithOptions static method with shareCachedRules = true option.

Example 1 - Simple Module Import

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

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

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

Example 2 - Module Import with Options

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

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

    // ng-translit
    TranslitModule.forRootWithOptions({ trace: true })
  ]
})
export class AppModule { }

Example 3 - Module Import in Child Module with Options

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

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

    // ng-translit
    TranslitModule.forChildWithOptions({ shareCachedRules: true })
  ]
})
export class ChildModule { }