GithubHelp home page GithubHelp logo

hay / transliterate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sindresorhus/transliterate

0.0 1.0 0.0 36 KB

Convert Unicode characters to Latin characters using transliteration

License: MIT License

JavaScript 98.21% TypeScript 1.79%

transliterate's Introduction

transliterate

Convert Unicode characters to Latin characters using transliteration

Can be useful for slugification purposes and other times you cannot use Unicode.

Install

$ npm install @sindresorhus/transliterate

Usage

import transliterate from '@sindresorhus/transliterate';

transliterate('Fußgängerübergänge');
//=> 'Fussgaengeruebergaenge'

transliterate('Я люблю единорогов');
//=> 'Ya lyublyu edinorogov'

transliterate('أنا أحب حيدات');
//=> 'ana ahb hydat'

transliterate('tôi yêu những chú kỳ lân');
//=> 'toi yeu nhung chu ky lan'

API

transliterate(string, options?)

string

Type: string

String to transliterate.

options

Type: object

customReplacements

Type: Array<string[]>
Default: []

Add your own custom replacements.

The replacements are run on the original string before any other transformations.

This only overrides a default replacement if you set an item with the same key.

import transliterate from '@sindresorhus/transliterate';

transliterate('Я люблю единорогов', {
	customReplacements: [
		['единорогов', '🦄']
	]
})
//=> 'Ya lyublyu 🦄'

Supported languages

Most major languages are supported.

This includes special handling for:

  • Arabic
  • Armenian
  • Czech
  • Danish
  • Dhivehi
  • Georgian
  • German (umlauts)
  • Greek
  • Hungarian
  • Latin
  • Latvian
  • Lithuanian
  • Macedonian
  • Pashto
  • Persian
  • Polish
  • Romanian
  • Russian
  • Serbian
  • Slovak
  • Swedish
  • Turkish
  • Ukrainian
  • Urdu
  • Vietnamese

However, Chinese is currently not supported.

Related

transliterate's People

Contributors

sindresorhus avatar hay avatar alexxnb avatar yhdgms1 avatar rhnorskov avatar richienb avatar vhpoet avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.