Giter Site home page Giter Site logo

latinize's Introduction

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 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's People

Contributors

adamvr avatar dundalek avatar edbond88 avatar romanlubushkin avatar trodrigues avatar yetzt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

latinize's Issues

How to use multiple instances?

I need to work with two different translation tables:

One translates only non-German characters not included in the PDF embedded font:
const umlauts = {'Ä': 'Ä', 'Ö': 'Ö', 'Ü': 'Ü', 'ä': 'ä', 'ö': 'ö', 'ü': 'ü', 'ß': 'ß'};

Another one is used to make search easier, it translates German characters:
const umlauts = {'Ä': 'Ae', 'Ö': 'Oe', 'Ü': 'Ue', 'ä': 'ae', 'ö': 'oe', 'ü': 'ue', 'ß': 'ss'};

I am using typescript and did import latinize from 'latinize'; in two different files, but changing latinize.characters always changes the values in both instances. Using var latinize = require('latinize'); did not help on the high level, only when put into the function using the translation. But now it is initialised new every time.

Is it possible to use multiple instances at the same time?

TS support

please , make support for typescript.There is a problem, in your export

Y u no minify?

Thinking of whether there maybe is a legit reason, e.g. characters disappearing or something.

License?

Hi!

I found a mention of BSD in the package.json but this is not binding legally.
Could a license file be added?

Thank you!

It seems not working with Angular AoT

Hello. I have an Angular 4 project which I'm using Latinize and it doesn't seem to work with the AoT compiling system. I've been following te Angular official guide: https://angular.io/guide/aot-compiler and trying this command:
node_modules/.bin/ngc -p tsconfig-aot.json, however I get this error due latinize:

Error encountered resolving symbol values statically. Calling function 'makeDecorator', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol Injectable in /home/danilo/Proyectos/krgo/frontend/node_modules/angular2latinize/node_modules/@angular/core/src/di/metadata.d.ts, resolving symbol OpaqueToken in /home/danilo/Proyectos/krgo/frontend/node_modules/angular2latinize/node_modules/@angular/core/src/di/opaque_token.d.ts, resolving symbol OpaqueToken in /home/danilo/Proyectos/krgo/frontend/node_modules/angular2latinize/node_modules/@angular/core/src/di/opaque_token.d.ts

so I can't change the way Angular compiles and I really need to do it. How can I solve this please??

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.