latinize-to-ascii

0.5.3 • Public • Published

Latinize.js

Simple library to convert accents (diacritics) from strings to latin characters.

FORK from unmaintained https://github.com/dundalek/latinize

Install

npm install latinize-to-ascii

Usage

ESM / MJS / ES6+ / Javascript Module

import latinize from 'dist/latinize.mjs';
latinize('ỆᶍǍᶆṔƚÉ áéíóúýčďěňřšťžů'); // => 'ExAmPlE aeiouycdenrstzu'

or

import latinize from 'latinize';
latinize('ỆᶍǍᶆṔƚÉ áéíóúýčďěňřšťžů'); // => 'ExAmPlE aeiouycdenrstzu'

node.cjs / CommonJS

var latinize = require('latinize');
latinize('ỆᶍǍᶆṔƚÉ áéíóúýčďěňřšťžů'); // => 'ExAmPlE aeiouycdenrstzu'

AMD

require(['latinize'], function(latinize){
  latinize('ỆᶍǍᶆṔƚÉ áéíóúýčďěňřšťžů');
});

browser

<script src="dist/latinize.min.js"></script>
<script>
    document.write(latinize('ỆᶍǍᶆṔƚÉ áéíóúýčďěňřšťžů'));
</script>

You can use the latinize.characters object to access the translation table or to change the mapping:

latinize.characters['Ω'] = 'O';

// modify the behavior for German umlauts
_.extend(latinize.characters,
  {'Ä': 'Ae', 'Ö': 'Oe', 'Ü': 'Ue', 'ä': 'ae', 'ö': 'oe', 'ü': 'ue'});

Details

Is is a lookup table taken from http://jsperf.com/latinize packaged for node and browser. Visit the link to see more approaches.

/latinize-to-ascii/

    Package Sidebar

    Install

    npm i latinize-to-ascii

    Weekly Downloads

    10

    Version

    0.5.3

    License

    BSD

    Unpacked Size

    128 kB

    Total Files

    14

    Last publish

    Collaborators

    • 1000i100