
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@lorefnon/sanscript
Advanced tools
Sanscript is a transliteration library for Indian languages. It supports the most popular Indian scripts and several different romanization schemes. Although Sanscript focuses on Sanskrit transliteration, it has partial support for other languages and is
:warning: Please use @indic-transliteration/sanscript instead of this fork. Changes here will be upstreamed.
Sanscript is a transliteration library for Indian languages. It supports the most popular Indian scripts and several different romanization schemes. Although Sanscript focuses on Sanskrit transliteration, it has partial support for other languages and is easy to extend.
The package is officially distributed at npm here, whereas a variant due to Vikram Iyer is separately available here. So one can use commands such as:
npm install @indic-transliteration/sanscriptSanscript is simple to use:
var output = Sanscript.t(input, from, to);
Here, from and to are the names of different schemes. In Sanscript, the word "scheme" refers to both scripts and romanizations. These schemes are of two types:
For a full list of schemes, see schemes in https://github.com/indic-transliteration/common_maps . A possibly outdated listing of supported schemes:
ahom, assamese, avestan, balinese, bengali, bhaisuki, brahmi, brahmi_tamil, burmese, chakma, cham, cyrillic, devanagari, dogra, gondi_gunjala, gondi_masaram, grantha, grantha_pandya, gujarati, gurmukhi, hk, iast, itrans, itrans_dravidian, javanese, kannada, khamti_shan, kharoshti, khmer, khom_thai, khudawadi, kolkata, lao, lao_pali, lepcha, limbu, mahajani, malayalam, manipuri, marchen, modi, mon, mro, multani, newa, ol_chiki, oriya, persian_old, phags_pa, ranjana, rejang, rohingya, sanskritOCR, shan, sharada, siddham, sinhala, slp1, sora_sompeng, sundanese, syloti_nagari, tagalog, tagbanwa, tai_laing, takri, tamil, tamil_extended, tamil_superscripted, telugu, thai, tibetan, tirhuta_maithili, urdu, vattelutu, velthuis, wancho, warang_citi, wx, zanbazar_square
of which the following are Roman schemes:
hk (Harvard-Kyoto)iast (International Alphabet of Sanskrit Transliteration)isoitrans (ITRANS)itrans_dravidian (ITRANS with support for Dravidian short "e" and "o")kolkata (National Library at Kolkata)slp1 (Sanskrit Library Phonetic Basic)velthuis (Velthuis)wx (WX)cyrillicWhen Sanscript sees the token ##, it toggles the transliteration state:
Sanscript.t('ga##Na##pa##te', 'hk', 'devanagari'); // गNaपte
Sanscript.t('ध##र्म##क्षेत्रे', 'devanagari', 'hk'); // dhaर्मkSetre
When Sanscript sees the token \, it disables transliteration on the character that immediately follows. \ is used for ITRANS compatibility; we recommend always using ## instead.
Sanscript.t('a \\a', 'itrans', 'devanagari'); // अ a
Sanscript.t('\\##aham', 'itrans', 'devanagari'); // ##अहम्
A lossy scheme does not have the letters needed to support lossless translation. For example, Bengali is a lossy scheme because it uses ব for both ba and va. In future releases, Sanscript might let you choose how to handle lossiness. For the time being, it makes some fairly bad hard-coded assumptions. Corrections and advice are always welcome.
You can tweak the transliteration function by passing an options object:
<script src="node_modules/@indic-transliteration/sanscript/sanscript.js"></script>
<script>
var output = Sanscript.t(input, from, to, options);
</script>
options maps options to values. Currently, these options are supported:
skip_sgml - If true, transliterate SGML tags as if they were ordinary words (<b>iti</b> → <ब्>इति</ब्>). Defaults to false.syncope - If true, use Hindi-style transliteration (ajay → अजय). In linguistics, this behavior is known as schwa syncope. Defaults to false.preferred_alternates - This object map can define which alternates should be used during transliteration. I.e. in case you transliterate to itrans and you prefer aa instead of A, ii instead of I, etc., you can set a map like this:{ itrans : { "A" : "aa", "I" : "ii", "U" : "uu", "j~n" : "GY" } }
npm installPlease note that schemes are in a different repo as a separate package dependency, which you can find in common_maps repo.
If you want to efficiently work locally editing schemes try out npm link. Check out usage here.
In a nutshell, the steps:
npm link in the shellsanscript.js repo and type npm link @indic-transliteration/common_mapsThis way the node_modules/@indic-transliteration/common_maps folder will become a link, pointing to your local checked out folder. So you can simply make there your changes.
When you want to revert to the real downloaded package simply type npm unlink @indic-transliteration/common_maps
Adding a new scheme is simple:
Sanscript.addBrahmicScheme(schemeName, schemeData);
Sanscript.addRomanScheme(schemeName, schemeData);
For help in creating schemeData, see the comments on the addBrahmicScheme and addRomanScheme functions.
Prior to testing, run npm run dist so that the distribution file sanscript.js is generated at the root folder.
We use qunit for testing.
After installing dependencies, you can either:
npm run test to run tests from the command linenpm publish --access public
FAQs
Sanscript is a transliteration library for Indian languages. It supports the most popular Indian scripts and several different romanization schemes. Although Sanscript focuses on Sanskrit transliteration, it has partial support for other languages and is
We found that @lorefnon/sanscript demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.