Skip to content

emoji_translator.js lets you translate English to emoji

License

Notifications You must be signed in to change notification settings

anaulin/emoji-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

emoji-translator.js

Build Status

A JavaScript library that translates English into emoji.

Also contains a helper data file with a recent list of Unicode codepoints for all emoji, their names and associated keywords.

How to use the library

The library provides its functionality via a Translator class, which can be instantiated by passing it the json emoji data object from emoji_data.json.

Once you have an initialized Translator, you can use its translate method to get an emojified version of your text.

// Load emoji-translator.js, which exports a constructor for Translator.
var emojiData = myFunctionToLoadData('emoji_data.json');
var translator = new Translator(emojiData);
translator.translate("I love emoji almost as much as cats. Oh joy!");
// Returns: "I 💖 emoji almost as much as 😸. Oh 😂!"

How it works

The current translation implementation looks up words from the input text in a table of words to emoji unicode codepoints.

If an input word matches more than one emoji in the list, a random matching emoji is returned. So, for example, "cat" might return different cat emojis on each call.

The table of emoji names and synonyms is created semi-automatically by parsing the Unicode website, and adding synonyms and associated concepts by hand. The utilities used to do this work can be found in the data-utils directory of this repository.

Developing

Install the dev dependencies using npm:

npm install

To run the tests:

npm test

Future work

Ideas for future improvements can be found on the issues tab of this repository.

Feel free to file bugs or feature requests there.

Or better still, send a pull request. 😻

License

Distributed under MIT License. See LICENSE for details.

About

emoji_translator.js lets you translate English to emoji

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages