diff --git a/README.md b/README.md index 54c22f4..de3bf0f 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ script[1][1]; // { index: 14, romanization: 'ka', script: 'க', iso15919: 'ka', ``` The same data is available as the named export `script`. Letters borrowed from the Grantha script -(`ஜ்`, `ஶ்`, `ஷ்`, `ஸ்`, `ஹ்` and `க்ஷ்`) are kept separately in `granthaScript`. +(`ஜ்`, `ஶ்`, `ஷ்`, `ஸ்`, `ஹ்` and `க்ஷ்`) are kept separately in `granthaScript`, in the same shape: one row per +consonant with its vowel forms, numbered on from `script`. Transliteration --- @@ -44,11 +45,13 @@ getIPA('பாடசாலைக்கு சென்றேன்'); // 'paːɖ - `getIso15919` – the [ISO 15919](https://en.wikipedia.org/wiki/ISO_15919) standard for romanizing Indic scripts - `getIPA` – the [International Phonetic Alphabet](https://en.wikipedia.org/wiki/International_Phonetic_Alphabet) -Grantha letters are left as they are unless you opt in to them: +Letters borrowed from the Grantha script are transliterated too, on their own and with a vowel. Pass +`{ grantha: false }` to leave them as they are: ```js -getIso15919('ஜ்'); // 'ஜ்' -getIso15919('ஜ்', { grantha: true }); // 'j' +getIso15919('ஜன்னல்'); // 'jaṉṉal' +getIPA('சந்தோஷம்'); // 't͡ɕan̪toːʂam' +getIso15919('ஜன்னல்', { grantha: false }); // 'ஜṉṉal' ``` Contribution diff --git a/src/__snapshots__/index.spec.ts.snap b/src/__snapshots__/index.spec.ts.snap index 2e97915..f13801b 100644 --- a/src/__snapshots__/index.spec.ts.snap +++ b/src/__snapshots__/index.spec.ts.snap @@ -1771,3 +1771,566 @@ exports[`script tests exports scripts from json 1`] = ` ], ] `; + +exports[`script tests exports the grantha letters in the same shape as the script 1`] = ` +[ + [ + { + "index": 247, + "ipa": "d͡ʑ", + "iso15919": "j", + "romanization": "j", + "script": "ஜ்", + }, + { + "index": 248, + "ipa": "d͡ʑa", + "iso15919": "ja", + "romanization": "ja", + "script": "ஜ", + }, + { + "index": 249, + "ipa": "d͡ʑaː", + "iso15919": "jā", + "romanization": "jaa", + "script": "ஜா", + }, + { + "index": 250, + "ipa": "d͡ʑi", + "iso15919": "ji", + "romanization": "ji", + "script": "ஜி", + }, + { + "index": 251, + "ipa": "d͡ʑiː", + "iso15919": "jī", + "romanization": "jii", + "script": "ஜீ", + }, + { + "index": 252, + "ipa": "d͡ʑu", + "iso15919": "ju", + "romanization": "ju", + "script": "ஜு", + }, + { + "index": 253, + "ipa": "d͡ʑuː", + "iso15919": "jū", + "romanization": "juu", + "script": "ஜூ", + }, + { + "index": 254, + "ipa": "d͡ʑe", + "iso15919": "je", + "romanization": "je", + "script": "ஜெ", + }, + { + "index": 255, + "ipa": "d͡ʑeː", + "iso15919": "jē", + "romanization": "jee", + "script": "ஜே", + }, + { + "index": 256, + "ipa": "d͡ʑaɪ", + "iso15919": "jai", + "romanization": "jai", + "script": "ஜை", + }, + { + "index": 257, + "ipa": "d͡ʑo", + "iso15919": "jo", + "romanization": "jo", + "script": "ஜொ", + }, + { + "index": 258, + "ipa": "d͡ʑoː", + "iso15919": "jō", + "romanization": "joo", + "script": "ஜோ", + }, + { + "index": 259, + "ipa": "d͡ʑaʊ", + "iso15919": "jau", + "romanization": "jau", + "script": "ஜௌ", + }, + ], + [ + { + "index": 260, + "ipa": "ɕ", + "iso15919": "ś", + "romanization": "s", + "script": "ஶ்", + }, + { + "index": 261, + "ipa": "ɕa", + "iso15919": "śa", + "romanization": "sa", + "script": "ஶ", + }, + { + "index": 262, + "ipa": "ɕaː", + "iso15919": "śā", + "romanization": "saa", + "script": "ஶா", + }, + { + "index": 263, + "ipa": "ɕi", + "iso15919": "śi", + "romanization": "si", + "script": "ஶி", + }, + { + "index": 264, + "ipa": "ɕiː", + "iso15919": "śī", + "romanization": "sii", + "script": "ஶீ", + }, + { + "index": 265, + "ipa": "ɕu", + "iso15919": "śu", + "romanization": "su", + "script": "ஶு", + }, + { + "index": 266, + "ipa": "ɕuː", + "iso15919": "śū", + "romanization": "suu", + "script": "ஶூ", + }, + { + "index": 267, + "ipa": "ɕe", + "iso15919": "śe", + "romanization": "se", + "script": "ஶெ", + }, + { + "index": 268, + "ipa": "ɕeː", + "iso15919": "śē", + "romanization": "see", + "script": "ஶே", + }, + { + "index": 269, + "ipa": "ɕaɪ", + "iso15919": "śai", + "romanization": "sai", + "script": "ஶை", + }, + { + "index": 270, + "ipa": "ɕo", + "iso15919": "śo", + "romanization": "so", + "script": "ஶொ", + }, + { + "index": 271, + "ipa": "ɕoː", + "iso15919": "śō", + "romanization": "soo", + "script": "ஶோ", + }, + { + "index": 272, + "ipa": "ɕaʊ", + "iso15919": "śau", + "romanization": "sau", + "script": "ஶௌ", + }, + ], + [ + { + "index": 273, + "ipa": "ʂ", + "iso15919": "ṣ", + "romanization": "s", + "script": "ஷ்", + }, + { + "index": 274, + "ipa": "ʂa", + "iso15919": "ṣa", + "romanization": "sa", + "script": "ஷ", + }, + { + "index": 275, + "ipa": "ʂaː", + "iso15919": "ṣā", + "romanization": "saa", + "script": "ஷா", + }, + { + "index": 276, + "ipa": "ʂi", + "iso15919": "ṣi", + "romanization": "si", + "script": "ஷி", + }, + { + "index": 277, + "ipa": "ʂiː", + "iso15919": "ṣī", + "romanization": "sii", + "script": "ஷீ", + }, + { + "index": 278, + "ipa": "ʂu", + "iso15919": "ṣu", + "romanization": "su", + "script": "ஷு", + }, + { + "index": 279, + "ipa": "ʂuː", + "iso15919": "ṣū", + "romanization": "suu", + "script": "ஷூ", + }, + { + "index": 280, + "ipa": "ʂe", + "iso15919": "ṣe", + "romanization": "se", + "script": "ஷெ", + }, + { + "index": 281, + "ipa": "ʂeː", + "iso15919": "ṣē", + "romanization": "see", + "script": "ஷே", + }, + { + "index": 282, + "ipa": "ʂaɪ", + "iso15919": "ṣai", + "romanization": "sai", + "script": "ஷை", + }, + { + "index": 283, + "ipa": "ʂo", + "iso15919": "ṣo", + "romanization": "so", + "script": "ஷொ", + }, + { + "index": 284, + "ipa": "ʂoː", + "iso15919": "ṣō", + "romanization": "soo", + "script": "ஷோ", + }, + { + "index": 285, + "ipa": "ʂaʊ", + "iso15919": "ṣau", + "romanization": "sau", + "script": "ஷௌ", + }, + ], + [ + { + "index": 286, + "ipa": "s", + "iso15919": "s", + "romanization": "s", + "script": "ஸ்", + }, + { + "index": 287, + "ipa": "sa", + "iso15919": "sa", + "romanization": "sa", + "script": "ஸ", + }, + { + "index": 288, + "ipa": "saː", + "iso15919": "sā", + "romanization": "saa", + "script": "ஸா", + }, + { + "index": 289, + "ipa": "si", + "iso15919": "si", + "romanization": "si", + "script": "ஸி", + }, + { + "index": 290, + "ipa": "siː", + "iso15919": "sī", + "romanization": "sii", + "script": "ஸீ", + }, + { + "index": 291, + "ipa": "su", + "iso15919": "su", + "romanization": "su", + "script": "ஸு", + }, + { + "index": 292, + "ipa": "suː", + "iso15919": "sū", + "romanization": "suu", + "script": "ஸூ", + }, + { + "index": 293, + "ipa": "se", + "iso15919": "se", + "romanization": "se", + "script": "ஸெ", + }, + { + "index": 294, + "ipa": "seː", + "iso15919": "sē", + "romanization": "see", + "script": "ஸே", + }, + { + "index": 295, + "ipa": "saɪ", + "iso15919": "sai", + "romanization": "sai", + "script": "ஸை", + }, + { + "index": 296, + "ipa": "so", + "iso15919": "so", + "romanization": "so", + "script": "ஸொ", + }, + { + "index": 297, + "ipa": "soː", + "iso15919": "sō", + "romanization": "soo", + "script": "ஸோ", + }, + { + "index": 298, + "ipa": "saʊ", + "iso15919": "sau", + "romanization": "sau", + "script": "ஸௌ", + }, + ], + [ + { + "index": 299, + "ipa": "h", + "iso15919": "h", + "romanization": "h", + "script": "ஹ்", + }, + { + "index": 300, + "ipa": "ha", + "iso15919": "ha", + "romanization": "ha", + "script": "ஹ", + }, + { + "index": 301, + "ipa": "haː", + "iso15919": "hā", + "romanization": "haa", + "script": "ஹா", + }, + { + "index": 302, + "ipa": "hi", + "iso15919": "hi", + "romanization": "hi", + "script": "ஹி", + }, + { + "index": 303, + "ipa": "hiː", + "iso15919": "hī", + "romanization": "hii", + "script": "ஹீ", + }, + { + "index": 304, + "ipa": "hu", + "iso15919": "hu", + "romanization": "hu", + "script": "ஹு", + }, + { + "index": 305, + "ipa": "huː", + "iso15919": "hū", + "romanization": "huu", + "script": "ஹூ", + }, + { + "index": 306, + "ipa": "he", + "iso15919": "he", + "romanization": "he", + "script": "ஹெ", + }, + { + "index": 307, + "ipa": "heː", + "iso15919": "hē", + "romanization": "hee", + "script": "ஹே", + }, + { + "index": 308, + "ipa": "haɪ", + "iso15919": "hai", + "romanization": "hai", + "script": "ஹை", + }, + { + "index": 309, + "ipa": "ho", + "iso15919": "ho", + "romanization": "ho", + "script": "ஹொ", + }, + { + "index": 310, + "ipa": "hoː", + "iso15919": "hō", + "romanization": "hoo", + "script": "ஹோ", + }, + { + "index": 311, + "ipa": "haʊ", + "iso15919": "hau", + "romanization": "hau", + "script": "ஹௌ", + }, + ], + [ + { + "index": 312, + "ipa": "kʂ", + "iso15919": "kṣ", + "romanization": "ks", + "script": "க்ஷ்", + }, + { + "index": 313, + "ipa": "kʂa", + "iso15919": "kṣa", + "romanization": "ksa", + "script": "க்ஷ", + }, + { + "index": 314, + "ipa": "kʂaː", + "iso15919": "kṣā", + "romanization": "ksaa", + "script": "க்ஷா", + }, + { + "index": 315, + "ipa": "kʂi", + "iso15919": "kṣi", + "romanization": "ksi", + "script": "க்ஷி", + }, + { + "index": 316, + "ipa": "kʂiː", + "iso15919": "kṣī", + "romanization": "ksii", + "script": "க்ஷீ", + }, + { + "index": 317, + "ipa": "kʂu", + "iso15919": "kṣu", + "romanization": "ksu", + "script": "க்ஷு", + }, + { + "index": 318, + "ipa": "kʂuː", + "iso15919": "kṣū", + "romanization": "ksuu", + "script": "க்ஷூ", + }, + { + "index": 319, + "ipa": "kʂe", + "iso15919": "kṣe", + "romanization": "kse", + "script": "க்ஷெ", + }, + { + "index": 320, + "ipa": "kʂeː", + "iso15919": "kṣē", + "romanization": "ksee", + "script": "க்ஷே", + }, + { + "index": 321, + "ipa": "kʂaɪ", + "iso15919": "kṣai", + "romanization": "ksai", + "script": "க்ஷை", + }, + { + "index": 322, + "ipa": "kʂo", + "iso15919": "kṣo", + "romanization": "kso", + "script": "க்ஷொ", + }, + { + "index": 323, + "ipa": "kʂoː", + "iso15919": "kṣō", + "romanization": "ksoo", + "script": "க்ஷோ", + }, + { + "index": 324, + "ipa": "kʂaʊ", + "iso15919": "kṣau", + "romanization": "ksau", + "script": "க்ஷௌ", + }, + ], +] +`; diff --git a/src/grantha.json b/src/grantha.json index 978af73..b44d7e0 100644 --- a/src/grantha.json +++ b/src/grantha.json @@ -1,8 +1,92 @@ [ - [{ "script": "ஜ்", "romanization": "j", "ipa": "d͡ʑ", "iso15919": "j" }], - [{ "script": "ஶ்", "romanization": "s", "ipa": "ɕ", "iso15919": "ś" }], - [{ "script": "ஷ்", "romanization": "s", "ipa": "ʂ", "iso15919": "ṣ" }], - [{ "script": "ஸ்", "romanization": "s", "ipa": "s", "iso15919": "s" }], - [{ "script": "ஹ்", "romanization": "h", "ipa": "h", "iso15919": "h" }], - [{ "script": "க்ஷ்", "romanization": "ks", "ipa": "kʂ", "iso15919": "kṣ" }] + [ + { "index": 247, "romanization": "j", "script": "ஜ்", "iso15919": "j", "ipa": "d͡ʑ" }, + { "index": 248, "romanization": "ja", "script": "ஜ", "iso15919": "ja", "ipa": "d͡ʑa" }, + { "index": 249, "romanization": "jaa", "script": "ஜா", "iso15919": "jā", "ipa": "d͡ʑaː" }, + { "index": 250, "romanization": "ji", "script": "ஜி", "iso15919": "ji", "ipa": "d͡ʑi" }, + { "index": 251, "romanization": "jii", "script": "ஜீ", "iso15919": "jī", "ipa": "d͡ʑiː" }, + { "index": 252, "romanization": "ju", "script": "ஜு", "iso15919": "ju", "ipa": "d͡ʑu" }, + { "index": 253, "romanization": "juu", "script": "ஜூ", "iso15919": "jū", "ipa": "d͡ʑuː" }, + { "index": 254, "romanization": "je", "script": "ஜெ", "iso15919": "je", "ipa": "d͡ʑe" }, + { "index": 255, "romanization": "jee", "script": "ஜே", "iso15919": "jē", "ipa": "d͡ʑeː" }, + { "index": 256, "romanization": "jai", "script": "ஜை", "iso15919": "jai", "ipa": "d͡ʑaɪ" }, + { "index": 257, "romanization": "jo", "script": "ஜொ", "iso15919": "jo", "ipa": "d͡ʑo" }, + { "index": 258, "romanization": "joo", "script": "ஜோ", "iso15919": "jō", "ipa": "d͡ʑoː" }, + { "index": 259, "romanization": "jau", "script": "ஜௌ", "iso15919": "jau", "ipa": "d͡ʑaʊ" } + ], + [ + { "index": 260, "romanization": "s", "script": "ஶ்", "iso15919": "ś", "ipa": "ɕ" }, + { "index": 261, "romanization": "sa", "script": "ஶ", "iso15919": "śa", "ipa": "ɕa" }, + { "index": 262, "romanization": "saa", "script": "ஶா", "iso15919": "śā", "ipa": "ɕaː" }, + { "index": 263, "romanization": "si", "script": "ஶி", "iso15919": "śi", "ipa": "ɕi" }, + { "index": 264, "romanization": "sii", "script": "ஶீ", "iso15919": "śī", "ipa": "ɕiː" }, + { "index": 265, "romanization": "su", "script": "ஶு", "iso15919": "śu", "ipa": "ɕu" }, + { "index": 266, "romanization": "suu", "script": "ஶூ", "iso15919": "śū", "ipa": "ɕuː" }, + { "index": 267, "romanization": "se", "script": "ஶெ", "iso15919": "śe", "ipa": "ɕe" }, + { "index": 268, "romanization": "see", "script": "ஶே", "iso15919": "śē", "ipa": "ɕeː" }, + { "index": 269, "romanization": "sai", "script": "ஶை", "iso15919": "śai", "ipa": "ɕaɪ" }, + { "index": 270, "romanization": "so", "script": "ஶொ", "iso15919": "śo", "ipa": "ɕo" }, + { "index": 271, "romanization": "soo", "script": "ஶோ", "iso15919": "śō", "ipa": "ɕoː" }, + { "index": 272, "romanization": "sau", "script": "ஶௌ", "iso15919": "śau", "ipa": "ɕaʊ" } + ], + [ + { "index": 273, "romanization": "s", "script": "ஷ்", "iso15919": "ṣ", "ipa": "ʂ" }, + { "index": 274, "romanization": "sa", "script": "ஷ", "iso15919": "ṣa", "ipa": "ʂa" }, + { "index": 275, "romanization": "saa", "script": "ஷா", "iso15919": "ṣā", "ipa": "ʂaː" }, + { "index": 276, "romanization": "si", "script": "ஷி", "iso15919": "ṣi", "ipa": "ʂi" }, + { "index": 277, "romanization": "sii", "script": "ஷீ", "iso15919": "ṣī", "ipa": "ʂiː" }, + { "index": 278, "romanization": "su", "script": "ஷு", "iso15919": "ṣu", "ipa": "ʂu" }, + { "index": 279, "romanization": "suu", "script": "ஷூ", "iso15919": "ṣū", "ipa": "ʂuː" }, + { "index": 280, "romanization": "se", "script": "ஷெ", "iso15919": "ṣe", "ipa": "ʂe" }, + { "index": 281, "romanization": "see", "script": "ஷே", "iso15919": "ṣē", "ipa": "ʂeː" }, + { "index": 282, "romanization": "sai", "script": "ஷை", "iso15919": "ṣai", "ipa": "ʂaɪ" }, + { "index": 283, "romanization": "so", "script": "ஷொ", "iso15919": "ṣo", "ipa": "ʂo" }, + { "index": 284, "romanization": "soo", "script": "ஷோ", "iso15919": "ṣō", "ipa": "ʂoː" }, + { "index": 285, "romanization": "sau", "script": "ஷௌ", "iso15919": "ṣau", "ipa": "ʂaʊ" } + ], + [ + { "index": 286, "romanization": "s", "script": "ஸ்", "iso15919": "s", "ipa": "s" }, + { "index": 287, "romanization": "sa", "script": "ஸ", "iso15919": "sa", "ipa": "sa" }, + { "index": 288, "romanization": "saa", "script": "ஸா", "iso15919": "sā", "ipa": "saː" }, + { "index": 289, "romanization": "si", "script": "ஸி", "iso15919": "si", "ipa": "si" }, + { "index": 290, "romanization": "sii", "script": "ஸீ", "iso15919": "sī", "ipa": "siː" }, + { "index": 291, "romanization": "su", "script": "ஸு", "iso15919": "su", "ipa": "su" }, + { "index": 292, "romanization": "suu", "script": "ஸூ", "iso15919": "sū", "ipa": "suː" }, + { "index": 293, "romanization": "se", "script": "ஸெ", "iso15919": "se", "ipa": "se" }, + { "index": 294, "romanization": "see", "script": "ஸே", "iso15919": "sē", "ipa": "seː" }, + { "index": 295, "romanization": "sai", "script": "ஸை", "iso15919": "sai", "ipa": "saɪ" }, + { "index": 296, "romanization": "so", "script": "ஸொ", "iso15919": "so", "ipa": "so" }, + { "index": 297, "romanization": "soo", "script": "ஸோ", "iso15919": "sō", "ipa": "soː" }, + { "index": 298, "romanization": "sau", "script": "ஸௌ", "iso15919": "sau", "ipa": "saʊ" } + ], + [ + { "index": 299, "romanization": "h", "script": "ஹ்", "iso15919": "h", "ipa": "h" }, + { "index": 300, "romanization": "ha", "script": "ஹ", "iso15919": "ha", "ipa": "ha" }, + { "index": 301, "romanization": "haa", "script": "ஹா", "iso15919": "hā", "ipa": "haː" }, + { "index": 302, "romanization": "hi", "script": "ஹி", "iso15919": "hi", "ipa": "hi" }, + { "index": 303, "romanization": "hii", "script": "ஹீ", "iso15919": "hī", "ipa": "hiː" }, + { "index": 304, "romanization": "hu", "script": "ஹு", "iso15919": "hu", "ipa": "hu" }, + { "index": 305, "romanization": "huu", "script": "ஹூ", "iso15919": "hū", "ipa": "huː" }, + { "index": 306, "romanization": "he", "script": "ஹெ", "iso15919": "he", "ipa": "he" }, + { "index": 307, "romanization": "hee", "script": "ஹே", "iso15919": "hē", "ipa": "heː" }, + { "index": 308, "romanization": "hai", "script": "ஹை", "iso15919": "hai", "ipa": "haɪ" }, + { "index": 309, "romanization": "ho", "script": "ஹொ", "iso15919": "ho", "ipa": "ho" }, + { "index": 310, "romanization": "hoo", "script": "ஹோ", "iso15919": "hō", "ipa": "hoː" }, + { "index": 311, "romanization": "hau", "script": "ஹௌ", "iso15919": "hau", "ipa": "haʊ" } + ], + [ + { "index": 312, "romanization": "ks", "script": "க்ஷ்", "iso15919": "kṣ", "ipa": "kʂ" }, + { "index": 313, "romanization": "ksa", "script": "க்ஷ", "iso15919": "kṣa", "ipa": "kʂa" }, + { "index": 314, "romanization": "ksaa", "script": "க்ஷா", "iso15919": "kṣā", "ipa": "kʂaː" }, + { "index": 315, "romanization": "ksi", "script": "க்ஷி", "iso15919": "kṣi", "ipa": "kʂi" }, + { "index": 316, "romanization": "ksii", "script": "க்ஷீ", "iso15919": "kṣī", "ipa": "kʂiː" }, + { "index": 317, "romanization": "ksu", "script": "க்ஷு", "iso15919": "kṣu", "ipa": "kʂu" }, + { "index": 318, "romanization": "ksuu", "script": "க்ஷூ", "iso15919": "kṣū", "ipa": "kʂuː" }, + { "index": 319, "romanization": "kse", "script": "க்ஷெ", "iso15919": "kṣe", "ipa": "kʂe" }, + { "index": 320, "romanization": "ksee", "script": "க்ஷே", "iso15919": "kṣē", "ipa": "kʂeː" }, + { "index": 321, "romanization": "ksai", "script": "க்ஷை", "iso15919": "kṣai", "ipa": "kʂaɪ" }, + { "index": 322, "romanization": "kso", "script": "க்ஷொ", "iso15919": "kṣo", "ipa": "kʂo" }, + { "index": 323, "romanization": "ksoo", "script": "க்ஷோ", "iso15919": "kṣō", "ipa": "kʂoː" }, + { "index": 324, "romanization": "ksau", "script": "க்ஷௌ", "iso15919": "kṣau", "ipa": "kʂaʊ" } + ] ] diff --git a/src/index.spec.ts b/src/index.spec.ts index 92a27b1..cb8a344 100644 --- a/src/index.spec.ts +++ b/src/index.spec.ts @@ -1,4 +1,4 @@ -import script, { getIso15919, getIPA, getRomanization } from './index'; +import script, { granthaScript, getIso15919, getIPA, getRomanization } from './index'; describe('script tests', () => { it('exports scripts from json', () => { @@ -7,6 +7,13 @@ describe('script tests', () => { expect(script.length).toBe(19); }); + it('exports the grantha letters in the same shape as the script', () => { + expect(granthaScript).toMatchSnapshot(); + expect(granthaScript.length).toBe(6); + expect(granthaScript.every((row) => row.length === 13)).toBeTruthy(); + expect(granthaScript[0][0].index).toBe(script.flat().length); + }); + it('builds the iso 15919 for word', () => { expect(getIso15919('அம்மா')).toEqual('ammā'); expect(getIso15919('பாடசாலைக்கு சென்றேன்')).toEqual('pāṭacālaikku ceṉṟēṉ'); @@ -29,12 +36,25 @@ describe('script tests', () => { }); it('takes grantha scripts into account', () => { - expect(getIPA('"";அம்!மாஜ்&&=')).toEqual('"";am!maːஜ்&&='); - expect(getIso15919('+அம்!மாஜ்--!')).toEqual('+am!māஜ்--!'); - expect(getRomanization('+அம்!மாஜ்--!')).toEqual('+am!maaஜ்--!'); + expect(getIPA('"";அம்!மாஜ்&&=')).toEqual('"";am!maːd͡ʑ&&='); + expect(getIso15919('+அம்!மாஜ்--!')).toEqual('+am!māj--!'); + expect(getRomanization('+அம்!மாஜ்--!')).toEqual('+am!maaj--!'); + + expect(getIPA('"";அம்!மாஜ்&&=', { grantha: false })).toEqual('"";am!maːஜ்&&='); + expect(getIso15919('+அம்!மாஜ்--!', { grantha: false })).toEqual('+am!māஜ்--!'); + expect(getRomanization('+அம்!மாஜ்--!', { grantha: false })).toEqual('+am!maaஜ்--!'); + }); - expect(getIPA('"";அம்!மாஜ்&&=', { grantha: true })).toEqual('"";am!maːd͡ʑ&&='); - expect(getIso15919('+அம்!மாஜ்--!', { grantha: true })).toEqual('+am!māj--!'); - expect(getRomanization('+அம்!மாஜ்--!', { grantha: true })).toEqual('+am!maaj--!'); + it('transliterates grantha letters with a vowel', () => { + expect(getIso15919('ஜன்னல்')).toEqual('jaṉṉal'); + expect(getIPA('ஜன்னல்')).toEqual('d͡ʑannal'); + expect(getIso15919('சந்தோஷம்')).toEqual('cantōṣam'); + expect(getIPA('சந்தோஷம்')).toEqual('t͡ɕan̪toːʂam'); + expect(getIso15919('கஷ்டம்')).toEqual('kaṣṭam'); + expect(getIso15919('ஹோட்டல்')).toEqual('hōṭṭal'); + expect(getIso15919('ஸ்ரீ')).toEqual('srī'); + expect(getIso15919('பக்ஷி')).toEqual('pakṣi'); + expect(getRomanization('ஜூஸ்')).toEqual('juus'); + expect(getIso15919('ஜன்னல்', { grantha: false })).toEqual('ஜṉṉal'); }); }); diff --git a/src/index.ts b/src/index.ts index 9914e9f..e8363a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,14 +11,14 @@ export type Script = { }; export type Options = { - grantha: boolean; + grantha?: boolean; }; export const script = data as Script[][]; export const granthaScript = grantha as Script[][]; const transliterate = (phrase: string, notation: 'romanization' | 'iso15919' | 'ipa', options?: Options) => { - const notationMap = [...script, ...(options?.grantha ? grantha : [])] + const notationMap = [...script, ...(options?.grantha === false ? [] : grantha)] .flat() .reduce( (scripts, newScript) => ({ ...scripts, [newScript.script]: newScript[notation] }),