GitHub - dzcpy/transliteration: UTF-8 to ASCII transliteration / slugify module for node.js, browser, Web Worker, React Native, Electron and CLI.
Want to be notified of new releases in dzcpy/transliteration?
Universal Unicode to Latin transliteration + slugify module. Works on all platforms and with all major languages.
IE 9+ and all modern browsers.
If you are using Typescript, please do not install @types/transliteration. Since v2 type definition files are built-in.
// Ni Hao , world!
transliteration can be loaded as an AMD / CommonJS module, or as global variables (UMD).
Transliterates the string str and return the result. Characters which this module doesn't recognise will be defaulted to the placeholder from the unknown argument in the configuration option, defaults to ''.
Bind options object globally so any following calls will be using optoinsObj as default. If optionsObj is omitted, it will return current default options object.
Convert Unicode str to a slug string for making sure it is safe to be used in an URL as a file name.
* When `allowedChars` is set to `'abc'`, then only characters which match `/[abc]/g` will be preserved.
Bind options globally so any following calls will be using optoinsObj by default. If optionsObj argument is omitted, it will return current default option object.
transliterate "你好, world!" -r 好=good -r          Replace `,` with `!`, `world` with `shijie`.
"world=Shi Jie"                                     Result: Ni good, Shi Jie!
transliterate "你好，世界!" -i 你好 -i ，           Ignore `你好` and `，`.
slugify "你好，世界!" -i 你好 -i ，                 Ignore `你好` and `，`.
Added transliterate as global variable for browser builds. Keep transl for backward compatibility.
The entire module had been refactored in Typescript, with big performance improvements as well as a reduced package size.
Better code quality. 100% unit tested.
bower support was dropped. Please use CDN or webpack/rollup.
As according to RFC 3986, more characters(/a-zA-Z0-9-_.~/) are kept as allowed characters in the result for slugify, and it is configurable.
Added uppercase as an option for slugify, if is set to true then the generated slug will be converted to uppercase letters.
Unknown characters will be transliterated as empty string by default, instead of a meaningless [?].
The options parameter of transliterate now is an Object (In 0.1.x it's a string unknown).
Unknown string will be transliterated as [?] instead of ?.
In the browser, global variables have been changed to window.transl and windnow.slugify. Other global variables are removed.
Chinese: Polyphonic characters are not always transliterated correctly. Alternative: pinyin.
Japanese: Most Japanese Kanji characters are transliterated into Chinese Pinyin because of the overlapped code map in Unicode. Also there are many polyphonic characters in Japanese which makes it impossible to transliterate Japanese Kanji correctly without tokenizing the sentence. Consider using kuroshiro for a better Kanji -> Romaji conversion.
Thai: Currently it is not working. If you know how to fix it, please comment on this issue.
Cylic: Cylic characters are overlapped between a few languages. The result might be inaccurate in some specific languages, for example Bulgarian.
If you there's any other issues, please raise a ticket.