JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 56404
  • Score
    100M100P100Q152487F
  • License BSD

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

Package Exports

  • latinize
  • latinize/latinize.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (latinize) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Latinize.js

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

Install

npm install latinize

Usage

ES module

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

node.js CommonJS

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

AMD

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

browser

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

You can use the latinize.characters object to access the translation table and pass custom mapping as a second argument:

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

Details

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