Package Exports
- transliteration
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 (transliteration) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Transliteration
Transliteration module for node.js. Can be used to transliterate unicode text into corresponding ascii characters, with support of nearly every common languages including CJK (Chinese, Japanese and Korean).
Install
npm install transliterationUsage
transliteration(str, [unknown])
Transliterate the string str. Characters which this module doesn't recognise will be converted to the character in the unknown parameter, defaults to ?.
Example
var tr = require('transliteration');
tr('你好,世界'); // Ni Hao ,Shi Jie
tr('Γεια σας, τον κόσμο'); // Geia sas, ton kosmo
tr('안녕하세요, 세계'); // annyeonghaseyo, segyeslugify(str, options)
Converts unicode string to slugs. So it can be safely used in URL or file name.
Options:
{
lowercase: true,
separator: '-'
}If no options parameter provided it will use the above default values.
Example:
var slugify = require('transliteration').slugify;
slugify('你好,世界'); // ni-hao-shi-jie
slugify('你好,世界', {lowercase: false, separator: '_'}); // Ni_Hao_Shi_JieClient side usage
Transliteration module can be run in the browser as well.
Donload the library with bower:
bower install transliterationIt supports AMD / CommonJS standard or just to be loaded as a global variable.
When use in the browser, by default it will create global variables under window object:
TR('你好, World'); // window.TR
// or
Transliteration('String'); // window.TransliterationIf you don't like the default variable names or they conflict with other libraries, you can call noConfilict() method before loading other libraries, then both window.TR and window.Transliteration will be deleted from windows object and Transliteration function will be returned:
var trans = Transliteration.noConflict();
trans('你好, World');
trans.slugify('你好, World');For detailed usage, please check example.html.