transliteration

  • Version 2.3.5
  • Published
  • 1.59 MB
  • 1 dependency
  • MIT license

Install

npm i transliteration
yarn add transliteration
pnpm add transliteration

Overview

Unicode to ACSII transliteration / slugify module for node.js, browser, Web Worker, ReactNative and CLI.

Index

Variables

variable slugify

const slugify: SlugifyFunction;

    variable transliterate

    const transliterate: TransliterateFunction;

      Interfaces

      interface BrowserGlobalObject

      interface BrowserGlobalObject {}

        property slugify

        slugify: SlugifyFunction;

          property transl

          transl: TransliterateFunction;

            property transliterate

            transliterate: TransliterateFunction;

              interface OptionReplaceObject

              interface OptionReplaceObject {}

                index signature

                [from: string]: string;

                  interface OptionsSlugify

                  interface OptionsSlugify extends OptionsTransliterate {}

                    property allowedChars

                    allowedChars?: string;
                    • Allowed characters. When allowedChars is set to 'abc', then only characters match /[abc]/g will be preserved. Other characters will all be converted to separator 'a-zA-Z0-9-_.~''

                    property fixChineseSpacing

                    fixChineseSpacing?: boolean;
                    • Fix Chinese spacing. For example, 你好 is transliterated to Ni Hao instead of NiHao. If you don't need to transliterate Chinese characters, set it to false to false to improve performance.

                    property lowercase

                    lowercase?: boolean;
                    • Whether the result need to be converted into lowercase true

                    property separator

                    separator?: string;
                    • Custom separator string '-'

                    property uppercase

                    uppercase?: boolean;
                    • Whether the result need to be converted into uppercase false

                    interface OptionsTransliterate

                    interface OptionsTransliterate {}

                      property fixChineseSpacing

                      fixChineseSpacing?: boolean;
                      • Fix Chinese spacing. For example, 你好 is transliterated to Ni Hao instead of NiHao. If you don't need to transliterate Chinese characters, set it to false to false to improve performance. true

                      property ignore

                      ignore?: string[];
                      • Ignore a list of strings untouched

                        Example 1

                        tr('你好,世界', { ignore: ['你'] }) // 你 Hao , Shi Jie

                      property replace

                      replace?: OptionReplaceCombined;
                      • Replace a list of string / regex in the source string into the provided target string before transliteration The option can either be an array or an object

                        Example 1

                        tr('你好,世界', { replace: {你: 'You'} }) // You Hao , Shi Jie

                        Example 2

                        tr('你好,世界', { replace: [['你', 'You']] }) // You Hao , Shi Jie

                        Example 3

                        tr('你好,世界', { replace: [[/你/g, 'You']] }) // You Hao , Shi Jie

                      property replaceAfter

                      replaceAfter?: OptionReplaceCombined;
                      • Same as replace but after transliteration

                      property trim

                      trim?: boolean;
                      • Decides whether or not to trim the result string after transliteration false

                      property unknown

                      unknown?: string;
                      • Any characters not known by this library will be replaced by a specific string unknown ''

                      Type Aliases

                      type IntervalArray

                      type IntervalArray = [number, number][];

                        type OptionReplaceArray

                        type OptionReplaceArray = OptionReplaceArrayItem[];

                          type OptionReplaceArrayItem

                          type OptionReplaceArrayItem = [string | RegExp, string];

                            type OptionReplaceCombined

                            type OptionReplaceCombined = OptionReplaceArray | OptionReplaceObject;

                              type Options

                              type Options = OptionsTransliterate | OptionsSlugify;

                                type SlugifyFunction

                                type SlugifyFunction = TransliterationFunction<OptionsSlugify>;

                                  type TransliterateFunction

                                  type TransliterateFunction = TransliterationFunction<OptionsTransliterate>;

                                    Package Files (2)

                                    Dependencies (1)

                                    Dev Dependencies (30)

                                    Peer Dependencies (0)

                                    No peer dependencies.

                                    Badge

                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/transliteration.

                                    • Markdown
                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/transliteration)
                                    • HTML
                                      <a href="https://www.jsdocs.io/package/transliteration"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>