Path: blob/master/node_modules/@bochilteam/scraper/lib/esm/texts/aksarajawa.js
1126 views
export function latinToAksara(str, options = { mode: 'ketik', space: true }) {1const aksara = new Aksara(str, options);2return aksara.toAksara();3}4export function aksaraToLatin(str, options = { HVokal: false }) {5const aksara = new Aksara(str, options);6return aksara.toLatin();7}8// https://bennylin.github.io/transliterasijawa/9// https://jv.wikipedia.org/w/index.php?title=Panganggo:Bennylin/trans.js&action=raw&ctype=text/javascript10const SuperTrim = (str) => str.replace(/^\s*|\s*$/g, '').replace(/\s+/g, ' '); // trim string, menemukan karakter di dalam string11const findstr = (str, find) => {12for (let i = 0; i < str.length; i++)13if (str[i] == find)14return true;15return false;16};17const isDigit = (a) => findstr('0123456789', a);18const isPunct = (a) => findstr(',.><?/+=-_}{[]*&^%$#@!~`"\\|:;()', a);19const isVowel = (a) => findstr('AaĂăEeÈèÉéIiOoUuÊêĚěĔĕṚṛXxôâāīūōåɔə', a);20const isConsonant = (a) => findstr('BCDfGHJKLMNPQRSTVWYZbcdfghjklmnpqrstvwyzḌḍṆṇṢṣṬṭŊŋÑñɲś', a); // Xx are vowels (pepet)21const isSpecial = (a) => findstr('GgHhRrYyñn', a); // untuk bikonsonan th, dh, ng (nga dan cecak), ny, -r- (cakra), -y- (pengkal), jñ/jnya (ꦘ)22const isHR = (a) => findstr('HhRrŊŋ', a); // untuk layar dan wignyan dan cecak ([[:en:w:Engma]])23const isLW = (a) => findstr('LlWw', a); // untuk panjingan ("ng" dapat diikuti "g", "r"/cakra, "y"/pengkal, dan "w" atau "l"/panjingan)24const isCJ = (a) => findstr('CcJj', a); // untuk anuswara -nj- dan -nc-25const GetSpecialSound = (str) => {26const specialsoundMap = {27f: 'ꦥ꦳꧀',28v: 'ꦮ꦳꧀',29z: 'ꦗ꦳꧀',30ś: 'ꦯ꧀',31Q: '꧀',32q: '꧀' /* pangkon */33};34if (specialsoundMap[str] !== undefined)35return specialsoundMap[str];36return null;37};38class Aksara {39constructor(str, opts = { mode: 'ketik', space: true, HVokal: true }) {40this.opts = opts;41this.str = '';42this.str2 = '';43this.spasi = '';44this.str = str.toString();45this.angkaFlag = opts.number;46this.cecakFlag = opts.cecak;47this.diftong = opts.diftong;48this.modeSpasi = opts.space;49this.murda = opts.murda;50this.mode = opts.mode;51this.isHVokal = opts.HVokal;52}53toAksara() {54let i = 0;55let ret = '';56let pi = 0; // ?offset57const angka = {580: '꧐',591: '꧑',602: '꧒',613: '꧓',624: '꧔',635: '꧕',646: '꧖',657: '꧗',668: '꧘',679: '꧙'68};69this.str = SuperTrim(this.str);70while (i < this.str.length) {71if (i > 0 && isVowel(this.str[i]) && isVowel(this.str[i - 1])) {72// deal with words that start with multiple vocals73if ((this.str[i - 1] == 'a' && this.str[i] == 'a') ||74(this.str[i - 1] == 'i' && this.str[i] == 'i') ||75(this.str[i - 1] == 'u' && this.str[i] == 'u') ||76(this.str[i - 1] == 'a' && this.str[i] == 'i') ||77(this.str[i - 1] == 'a' && this.str[i] == 'u')) {78// specials79if (i == 1 || (i > 1 && !isConsonant(this.str[i - 2]))) {80// for example if starts with 'ai-'81this.str =82this.str.substring(0, i) +83'h' +84this.str.substring(i, this.str.length);85}86else {87// var modeDiftong = document.getElementsByName("diftong");88// for (var rad in modeDiftong) {89// if (modeDiftong[rad].checked)90// diftong = modeDiftong[rad].value;91// }92if (this.diftong) {93// do nothing, look in matramap table if(diftong == "tidak")94}95else {96this.str =97this.str.substring(0, i) +98'h' +99this.str.substring(i, this.str.length);100}101}102}103else if ((this.str[i - 1] == 'e' ||104this.str[i - 1] == 'è' ||105this.str[i - 1] == 'é') &&106(this.str[i] == 'a' || this.str[i] == 'o')) {107// -y-108this.str =109this.str.substring(0, i) +110'y' +111this.str.substring(i, this.str.length);112}113else if (this.str[i - 1] == 'i' &&114(this.str[i] == 'a' ||115this.str[i] == 'e' ||116this.str[i] == 'è' ||117this.str[i] == 'é' ||118this.str[i] == 'o' ||119this.str[i] == 'u')) {120// -y-121this.str =122this.str.substring(0, i) +123'y' +124this.str.substring(i, this.str.length);125}126else if (this.str[i - 1] == 'o' &&127(this.str[i] == 'a' ||128this.str[i] == 'e' ||129this.str[i] == 'è' ||130this.str[i] == 'é')) {131// -w-132this.str =133this.str.substring(0, i) +134'w' +135this.str.substring(i, this.str.length);136}137else if (this.str[i - 1] == 'u' &&138(this.str[i] == 'a' ||139this.str[i] == 'e' ||140this.str[i] == 'è' ||141this.str[i] == 'é' ||142this.str[i] == 'i' ||143this.str[i] == 'o')) {144// -y-145this.str =146this.str.substring(0, i) +147'w' +148this.str.substring(i, this.str.length);149}150else {151this.str =152this.str.substring(0, i) +153'h' +154this.str.substring(i, this.str.length);155}156}157if ((isSpecial(this.str[i]) || isLW(this.str[i]) || isCJ(this.str[i])) &&158!this.vowelFlag) {159// i++;160}161else if ((this.str[i] == 'h' && this.vowelFlag) ||162(!isVowel(this.str[i]) && i > 0) ||163this.str[i] == ' ' ||164isPunct(this.str[i]) ||165isDigit(this.str[i]) ||166i - pi > 5) {167if (!isDigit(this.str[i]) && this.angkaFlag) {168// turn off the flag169ret += '꧇'; // with zws170this.angkaFlag = false;171}172if (pi < i) {173if (this.cecakFlag &&174this.GetSound(this.str.substring(pi, i)) == 'ꦁ') {175this.cecakFlag = false;176ret += 'ꦔ꧀ꦔ';177}178else if (!this.cecakFlag &&179this.GetSound(this.str.substring(pi, i)) == 'ꦁ') {180this.cecakFlag = true;181ret += 'ꦁ';182}183else {184this.cecakFlag = false;185ret += this.GetSound(this.str.substring(pi, i));186}187}188if (this.str[i] == ' ') {189// var spasi, modeSpasi;190// var pakaiSpasi = document.getElementsByName("spasi");191// for (var rad in pakaiSpasi) {192// if (pakaiSpasi[rad].checked)193// modeSpasi = pakaiSpasi[rad].value;194// }195if (this.modeSpasi) {196// if space preceeded by open vowel, or layar/wignyan (therefore, no pangkon/virama)197if (i > 0 &&198['a', 'e', 'i', 'o', 'u', 'r', 'h', 'ě'].indexOf(this.str[i - 1]) >= 0) {199this.spasi = ''; // zero-width space200}201else {202this.spasi = '';203}204}205else {206// if(mode == "with")207this.spasi = ''; // zero-width space208// spasi = ' '; }//hair space http://en.wikipedia.org/wiki/Space_(punctuation)#Spaces_in_Unicode209}210ret += this.spasi;211}212if (isPunct(this.str[i])) {213if (this.str[i] == '.') {214ret += '꧉'; // titik+zero-width space215pi = i + 1;216}217else if (this.str[i] == ',') {218ret += '꧈'; // koma+zero-width space219pi = i + 1;220}221else if (this.str[i] == ':') {222ret += '꧇'; // titik dua+zero-width space223pi = i + 1;224}225else if (this.str[i] == '|') {226ret += '꧋';227pi = i + 1;228/* comment out, not really a good way to do brackets229} else if (str[i] == '(') {230ret += "꧌"; pi = i + 1;231} else if (str[i] == ')') {232ret += "꧍"; pi = i + 1;// with zws233*/234}235else if (this.str[i] == '-') {236// tanda hubung237ret += '';238pi = i + 1;239}240else if (this.str[i] == '?' ||241this.str[i] == '!' ||242this.str[i] == '"' ||243this.str[i] == "'") {244// tanda tanya/seru/petik245ret += ''; // zero-width space246pi = i + 1;247}248else {249ret += this.str[i];250pi = i + 1;251}252}253else if (isDigit(this.str[i])) {254if (!this.angkaFlag)255ret += '꧇';256ret += angka[this.str[i]];257this.angkaFlag = true;258pi = i + 1;259}260else {261pi = i;262}263this.vowelFlag = false;264}265else if (isVowel(this.str[i]) && this.str[i] != 'h') {266if (!isDigit(this.str[i]) && this.angkaFlag) {267// turn off the flag268ret += '꧇'; // with zws269this.angkaFlag = false;270}271this.vowelFlag = true;272}273if (pi > 0 && isVowel(this.str[pi - 1])) {274// <vowel>ngg275this.vowelPrev = true;276}277else278this.vowelPrev = false;279/* not working280if (pi > 0 && findstr(" ",str[pi-1])) {//<vowel>ngg281spacePrev = true;282}283else spacePrev = false; */284i++;285} // endwhile286if (pi < i) {287ret += this.GetSound(this.str.substring(pi, i));288}289return SuperTrim(ret).toString();290}291GetMatra(str) {292let i = 0;293if (str.length < 1) {294return '꧀';295}296while (str[i] == 'h') {297i++;298if (i >= str.length) {299break;300}301}302if (i < str.length) {303str = str.substring(i);304}305const matramap1 = { e: 'ꦺ', E: 'ꦌ' }; // mode ketik306const matramap2 = { e: 'ꦼ', E: 'ꦄꦼ' }; // mode kopas307const matramap3 = {308// both mode ketik and kopas309ā: 'ꦴ',310â: 'ꦴ',311aa: 'ꦴ',312è: 'ꦺ',313é: 'ꦺ',314i: 'ꦶ',315ī: 'ꦷ',316ii: 'ꦷ',317o: 'ꦺꦴ',318ō: 'ꦼꦴ',319u: 'ꦸ',320ū: 'ꦹ',321uu: 'ꦹ',322x: 'ꦼ',323ě: 'ꦼ',324ĕ: 'ꦼ',325ê: 'ꦼ',326ə: 'ꦼ',327ô: '',328ă: '',329å: '',330ɔ: '',331A: 'ꦄ',332Ă: 'ꦄ',333È: 'ꦌ',334É: 'ꦌ',335I: 'ꦆ',336O: 'ꦎ',337U: 'ꦈ',338X: 'ꦄꦼ',339Ě: 'ꦄꦼ',340Ĕ: 'ꦄꦼ',341Ê: 'ꦄꦼ',342ṛ: 'ꦽ',343Ṛ: 'ꦽ',344ai: 'ꦻ',345au: 'ꦻꦴ'346};347// var matramap, mode;348// var modeTranslit = document.getElementsByName("mode");349// for (var rad in modeTranslit) {350// if (modeTranslit[rad].checked)351// mode = modeTranslit[rad].value;352// }353if (this.mode == 'kopas')354var matramap = { ...matramap2, ...matramap3 };355// if(mode == "ketik")356else357var matramap = { ...matramap1, ...matramap3 };358if (matramap[str] !== undefined) {359return matramap[str];360}361return '';362}363GetShift(str1) {364const str = str1.toLowerCase(); // case insensitive365// var modeMurda = document.getElementsByName("murda");366// for (var rad in modeMurda) {367// if (modeMurda[rad].checked)368// murda = modeMurda[rad].value;369// }370if (this.murda)371this.str2 = str1;372// case sensitive (particularly the 8 characters of ꦛ ꦜ ꦝ ꦞ ꦠ ꦡ ꦢ ꦣ),373// for combination of murda and cakra/pengkal/panjingan374// if(murda == "tidak")375else376this.str2 = str1.toLowerCase(); // case insensitive377// V.1. 2nd letter of the consonant cluster is 'h'378if (this.str2.indexOf('th') == 0) {379// suku kata diawali 'th'380if (this.str2.indexOf('thl') == 0) {381// thl-382return { CoreSound: 'ꦛ꧀ꦭ', len: 3 };383}384else if (this.str2.indexOf('thr') == 0) {385// thr-386return { CoreSound: 'ꦛꦿ', len: 3 };387}388else if (this.str2.indexOf('thw') == 0) {389// thw-390return { CoreSound: 'ꦛ꧀ꦮ', len: 3 };391}392else if (this.str2.indexOf('thy') == 0) {393// thy-394return { CoreSound: 'ꦛꦾ', len: 3 };395}396else {397return { CoreSound: 'ꦛ', len: 2 }; // tha398}399}400else if (this.str2.indexOf('dh') == 0) {401// suku kata diawali 'dh'402if (this.str2.indexOf('dhl') == 0) {403// dhl-404return { CoreSound: 'ꦝ꧀ꦭ', len: 3 };405}406else if (this.str2.indexOf('dhr') == 0) {407// dhr-408return { CoreSound: 'ꦝꦿ', len: 3 };409}410else if (this.str2.indexOf('dhw') == 0) {411// dhw-: dhwani412return { CoreSound: 'ꦝ꧀ꦮ', len: 3 };413}414else if (this.str2.indexOf('dhy') == 0) {415// dhy-: dhyaksa416return { CoreSound: 'ꦝꦾ', len: 3 };417}418else {419return { CoreSound: 'ꦝ', len: 2 }; // dha420}421}422else if (this.str2.indexOf('Th') == 0) {423// suku kata diawali 'Th'424if (this.str2.indexOf('Thl') == 0) {425// Thl-426return { CoreSound: 'ꦜ꧀ꦭ', len: 3 };427}428else if (this.str2.indexOf('Thr') == 0) {429// Thr-430return { CoreSound: 'ꦜꦿ', len: 3 };431}432else if (this.str2.indexOf('Thw') == 0) {433// Thw-434return { CoreSound: 'ꦜ꧀ꦮ', len: 3 };435}436else if (this.str2.indexOf('Thy') == 0) {437// Thy-438return { CoreSound: 'ꦜꦾ', len: 3 };439}440else {441return { CoreSound: 'ꦜ', len: 2 }; // Tha Mahaprana442}443}444else if (this.str2.indexOf('Dh') == 0) {445// suku kata diawali 'Dh'446if (this.str2.indexOf('Dhl') == 0) {447// Dhl-448return { CoreSound: 'ꦞ꧀ꦭ', len: 3 };449}450else if (this.str2.indexOf('Dhr') == 0) {451// Dhr-452return { CoreSound: 'ꦞꦿ', len: 3 };453}454else if (this.str2.indexOf('Dhw') == 0) {455// Dhw-: Dhwani456return { CoreSound: 'ꦞ꧀ꦮ', len: 3 };457}458else if (this.str2.indexOf('Dhy') == 0) {459// Dhy-: Dhyaksa460return { CoreSound: 'ꦞꦾ', len: 3 };461}462else {463return { CoreSound: 'ꦞ', len: 2 }; // Dha Mahaprana464}465/* murda block start */466}467else if (str.indexOf('ṭh') == 0) {468// ṭh (aksara murda: tha mahaprana)469if (str.indexOf('ṭhy') == 0) {470return { CoreSound: 'ꦜꦾ', len: 2 };471}472else if (str.indexOf('ṭhr') == 0) {473return { CoreSound: 'ꦜꦿ', len: 2 };474}475else476return { CoreSound: 'ꦜ', len: 2 };477}478else if (str.indexOf('ḍh') == 0) {479// ḍh (aksara murda: dha mahaprana)480if (str.indexOf('ḍhy') == 0) {481return { CoreSound: 'ꦞꦾ', len: 2 };482}483else if (str.indexOf('ḍhr') == 0) {484return { CoreSound: 'ꦞꦿ', len: 2 };485}486else487return { CoreSound: 'ꦞ', len: 2 };488}489else if (str.indexOf('kh') == 0) {490// kh (aksara murda: ka murda)491if (str.indexOf('khl') == 0) {492// ka murda + panjingan la493return { CoreSound: 'ꦑ꧀ꦭ', len: 3 };494}495else if (str.indexOf('khr') == 0) {496// ka murda + cakra497return { CoreSound: 'ꦑꦿ', len: 3 };498}499else if (str.indexOf('khw') == 0) {500// ka murda + panjingan wa501return { CoreSound: 'ꦑ꧀ꦮ', len: 3 };502}503else if (str.indexOf('khy') == 0) {504// ka murda + wignyan505return { CoreSound: 'ꦑꦾ', len: 3 };506}507else {508return { CoreSound: 'ꦑ', len: 2 };509}510}511else if (str.indexOf('gh') == 0) {512// gh (aksara murda: ga murda)513if (str.indexOf('ghl') == 0) {514// ga murda + panjingan la515return { CoreSound: 'ꦓ꧀ꦭ', len: 3 };516}517else if (str.indexOf('ghw') == 0) {518// ga murda + panjingan wa519return { CoreSound: 'ꦓ꧀ꦮ', len: 3 };520}521else if (str.indexOf('ghr') == 0) {522// ga murda + cakra523return { CoreSound: 'ꦓꦿ', len: 3 };524}525else if (str.indexOf('ghy') == 0) {526// ga murda + wignyan527return { CoreSound: 'ꦓꦾ', len: 3 };528}529else {530return { CoreSound: 'ꦓ', len: 2 };531}532}533else if (str.indexOf('ch') == 0) {534// ch (aksara murda: ca murda)535if (str.indexOf('chl') == 0) {536// ca murda + panjingan la537return { CoreSound: 'ꦖ꧀ꦭ', len: 3 };538}539else if (str.indexOf('chr') == 0) {540// ca murda + cakra541return { CoreSound: 'ꦖꦿ', len: 3 };542}543else if (str.indexOf('chw') == 0) {544// ca murda + panjingan wa545return { CoreSound: 'ꦖ꧀ꦮ', len: 3 };546}547else if (str.indexOf('chy') == 0) {548// ca murda + wignyan549return { CoreSound: 'ꦖꦾ', len: 3 };550}551else {552return { CoreSound: 'ꦖ', len: 2 };553}554}555else if (str.indexOf('jh') == 0) {556// jh (aksara murda: ja mahaprana)557if (str.indexOf('jhl') == 0) {558// ja mahaprana + panjingan la559return { CoreSound: 'ꦙ꧀ꦭ', len: 3 }; // with zws, otherwise the panjingan is overlapped560}561else if (str.indexOf('jhr') == 0) {562// ja mahaprana + cakra563return { CoreSound: 'ꦙꦿ', len: 3 };564}565else if (str.indexOf('jhw') == 0) {566// ja mahaprana + panjingan wa567return { CoreSound: 'ꦙ꧀ꦮ', len: 3 };568}569else if (str.indexOf('jhy') == 0) {570// ja mahaprana + wignyan571return { CoreSound: 'ꦙꦾ', len: 3 };572}573else {574return { CoreSound: 'ꦙ', len: 2 };575}576}577else if (str.indexOf('ph') == 0) {578// ph (aksara murda: pa murda)579if (str.indexOf('phl') == 0) {580// pa murda + panjingan la581return { CoreSound: 'ꦦ꧀ꦭ', len: 3 };582}583else if (str.indexOf('phr') == 0) {584// pa murda + cakra585return { CoreSound: 'ꦦꦿ', len: 3 };586}587else if (str.indexOf('phw') == 0) {588// pa murda + panjingan wa589return { CoreSound: 'ꦦ꧀ꦮ', len: 3 };590}591else if (str.indexOf('phy') == 0) {592// pa murda + wignyan593return { CoreSound: 'ꦦꦾ', len: 3 };594}595else {596return { CoreSound: 'ꦦ', len: 2 };597}598}599else if (str.indexOf('bh') == 0) {600// bh (aksara murda: ba murda)601if (str.indexOf('bhl') == 0) {602// ba murda + panjingan la603return { CoreSound: 'ꦨ꧀ꦭ', len: 3 };604}605else if (str.indexOf('bhr') == 0) {606// ba murda + cakra607return { CoreSound: 'ꦨꦿ', len: 3 };608}609else if (str.indexOf('bhw') == 0) {610// ba murda + panjingan wa611return { CoreSound: 'ꦨ꧀ꦮ', len: 3 };612}613else if (str.indexOf('bhy') == 0) {614// ba murda + wignyan615return { CoreSound: 'ꦨꦾ', len: 3 };616}617else {618return { CoreSound: 'ꦨ', len: 2 };619}620}621else if (str.indexOf('sh') == 0) {622// sh (aksara murda: sa murda)623if (str.indexOf('shl') == 0) {624// sa murda + panjingan la625return { CoreSound: 'ꦯ꧀ꦭ', len: 3 };626}627else if (str.indexOf('shr') == 0) {628// sa murda + cakra629return { CoreSound: 'ꦯꦿ', len: 3 };630}631else if (str.indexOf('shw') == 0) {632// sa murda + panjingan wa633return { CoreSound: 'ꦯ꧀ꦮ', len: 3 };634}635else if (str.indexOf('shy') == 0) {636// sa murda + wignyan637return { CoreSound: 'ꦯꦾ', len: 3 };638}639else {640return { CoreSound: 'ꦯ', len: 2 };641}642/* murda block end */643// Uncatched exception: -h followed by hy, hr, hl, hw644}645else if (str.indexOf('hh') == 0) {646// wignyan + ha, e.g. root word ends with 'h' with suffix -i647return { CoreSound: 'ꦃꦲ', len: 2 };648// Uncatched exception: -r followed by hy, hr, hl, hw649}650else if (str.indexOf('rh') == 0) {651// layar + ha652return { CoreSound: 'ꦂꦲ', len: 2 };653}654else if (str.indexOf('h') == 1) {655// h (h di posisi karakter kedua)656return {657CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦲ',658len: 2659};660}661// V.2. 2nd letter is 'g'662if (str.indexOf('ng') == 0) {663// suku kata diawali 'ng'664// Uncatched exception: -ng followed by ry, rw, rl665if (str.indexOf('ngr') == 0) {666// cakra (for cecak + ra, separate by a space)667return { CoreSound: '' + 'ꦔꦿ', len: 3 };668}669else if (str.indexOf('ngy') == 0) {670// pengkal (for cecak + ya, separate by a space)671return { CoreSound: '' + 'ꦔꦾ', len: 3 };672// Uncatched exception: -ng followed by hy, hr, hl673}674else if (str.indexOf('nghw') == 0) {675// tyonghwa676return { CoreSound: '' + 'ꦁꦲ꧀ꦮ', len: 4 };677}678else if (str.indexOf('ngg') == 0) {679// cecak + ga680if (str.indexOf('nggr') == 0) {681// nggronjal682return { CoreSound: 'ꦔ꧀ꦒꦿ', len: 4 };683}684else if (str.indexOf('nggl') == 0) {685// nggl-686return { CoreSound: 'ꦔ꧀ꦒ꧀ꦭ', len: 4 };687}688else if (str.indexOf('nggw') == 0) {689// nggw-, munggwing690return { CoreSound: 'ꦔ꧀ꦒ꧀ꦮ', len: 4 };691}692else if (str.indexOf('nggy') == 0) {693// nggy-, anggyat694return { CoreSound: 'ꦔ꧀ꦒꦾ', len: 4 };695}696else {697return { CoreSound: 'ꦔ꧀ꦒ', len: 3 };698}699}700else if (str.indexOf('ngn') == 0) {701// cecak + na702// Uncatched exception: -ng followed by ngy, ngr, ngl, ngw703if (str.indexOf('ngng') == 0) {704// ngng705return { CoreSound: 'ꦁꦔ', len: 4 };706}707else {708return { CoreSound: 'ꦁꦤ', len: 3 };709}710}711else if (str.indexOf('ngh') == 0) {712// cecak + ha713return { CoreSound: 'ꦁꦲ', len: 3 };714}715else if (str.indexOf('ngc') == 0) {716// cecak + ca717return { CoreSound: 'ꦁꦕ', len: 3 };718}719else if (str.indexOf('ngj') == 0) {720// cecak + ja721return { CoreSound: 'ꦁꦗ', len: 3 };722}723else if (str.indexOf('ngl') == 0) {724// ngl, e.g. ngluwari725return { CoreSound: 'ꦔ꧀ꦭ', len: 3 };726}727else if (str.indexOf('ngw') == 0) {728// ngw, e.g. ngwiru729return { CoreSound: 'ꦔ꧀ꦮ', len: 3 };730}731else {732return { CoreSound: 'ꦁ', len: 2 }; // cecak, with zws733}734}735else if (str.indexOf('gg') == 0) {736// 'gg', e.g. root word ends with 'g' with suffix -i737return { CoreSound: 'ꦒ꧀ꦒ', len: 2 };738}739else if (str.indexOf('hg') == 0) {740// wignyan + ga, e.g. dahgene741return { CoreSound: 'ꦃꦒ', len: 2 };742}743else if (str.indexOf('rg') == 0) {744// layar + ga, e.g. amarga745return { CoreSound: 'ꦂꦒ', len: 2 };746}747else if (str.indexOf('g') == 1) {748// g (g di posisi karakter kedua)749return {750CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦒ',751len: 2752};753}754// V.3. 2nd letter is 'y'755if (str.indexOf('ny') == 0) {756// suku kata diawali 'ny'757if (str.indexOf('nyr') == 0) {758// cakra759return { CoreSound: 'ꦚꦿ', len: 3 }; /*760} else if (str.indexOf("nyy") == 0) { //nyy, I don't think it's possible761return { "CoreSound": "ꦚꦾ", "len": 3 }; */762}763else if (str.indexOf('nyl') == 0) {764// nyl, e.g. nylonong765return { CoreSound: 'ꦚ꧀ꦭ', len: 3 };766}767else if (str.indexOf('nyw') == 0) {768// nyw769return { CoreSound: 'ꦚ꧀ꦮ', len: 3 }; /*770} else if (str2.indexOf("Ny") == 0) { //Na murda + pengkal, unlikely combination?771return { "CoreSound": "ꦟꦾ", "len": 2 }; */772}773else {774return { CoreSound: 'ꦚ', len: 2 };775}776}777else if (str.indexOf('hy') == 0) {778// wignyan + ya / ha + pengkal -- hyang779return { CoreSound: 'ꦲꦾ', len: 2 };780}781else if (this.str2.indexOf('ry') == 0) {782// layar + ya, e.g. Suryati, Wiryadi783if (str.indexOf('ryy') == 0) {784return { CoreSound: 'ꦂꦪꦾ', len: 3 }; // 'ryy', e.g. Duryyodhana (Jawa Kuno)785}786else {787return { CoreSound: 'ꦂꦪ', len: 2 };788} /*789} else if (str.indexOf("yy") == 0) { //'yy', I don't think it's possible790return { "CoreSound": "ꦪꦾ", "len": 2 }; */791}792else if (this.str2.indexOf('qy') == 0) {793// qy -- only pengkal794return { CoreSound: 'ꦾ', len: 1 };795}796else if (str.indexOf('y') == 1) {797// pengkal (y di posisi karakter kedua)798return {799CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + 'ꦾ',800len: 2801};802}803// V.4. 2nd letter is 'r'804// Uncatched exception: -h followed by ry, rw, rl805if (str.indexOf('hr') == 0) {806// wignyan + ra / ha + cakra807return { CoreSound: 'ꦲꦿ', len: 2 };808}809else if (str.indexOf('wr') == 0) {810// wr -- panjingan + cakra811return { CoreSound: '' + 'ꦮꦿ', len: 2 };812// Uncatched exception: -r followed by ry, rw, rl813}814else if (str.indexOf('rr') == 0) {815// layar + ra (no cakra)816return { CoreSound: 'ꦂꦫ', len: 2 };817}818else if (this.str2.indexOf('qr') == 0) {819// qr -- only pasangan ra820return { CoreSound: '꧀ꦫ', len: 1 };821}822else if (this.str2.indexOf('qR') == 0) {823// qR -- only cakra824return { CoreSound: 'ꦿ', len: 1 };825}826else if (str.indexOf('r') == 1) {827// cakra (r di posisi karakter kedua)828return {829CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + 'ꦿ',830len: 2831};832}833// V.5. 2nd letter is 'l' or 'w'834// panjingan -l835if (str.indexOf('hl') == 0) {836// wignyan + la837return { CoreSound: 'ꦃꦭ', len: 2 };838}839else if (str.indexOf('rl') == 0) {840// layar + la841return { CoreSound: 'ꦂꦭ', len: 2 };842}843else if (str.indexOf('ll') == 0) {844// ll845return { CoreSound: 'ꦭ꧀ꦭ', len: 2 };846}847else if (str.indexOf('ql') == 0) {848// only panjingan849return { CoreSound: '꧀ꦭ', len: 2 };850}851else if (str.indexOf('l') == 1) {852// (l di posisi karakter kedua)853return {854CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦭ',855len: 2856};857}858// panjingan -w859if (str.indexOf('hw') == 0) {860// wignyan + ha861return { CoreSound: 'ꦃꦮ', len: 2 }; // ꦲ꧀ꦮ862}863else if (str.indexOf('rw') == 0) {864// layar + ha865return { CoreSound: 'ꦂꦮ', len: 2 }; // error untuk 'rwi', 'rwab'866}867else if (str.indexOf('ww') == 0) {868// ww (wwang, pûrwwa) - terima kasih Mas Revo869return { CoreSound: 'ꦮ꧀ꦮ', len: 2 };870}871else if (str.indexOf('qw') == 0) {872// only panjingan873return { CoreSound: '꧀ꦮ', len: 2 };874}875else if (str.indexOf('w') == 1) {876// (w di posisi karakter kedua)877return {878CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦮ',879len: 2880};881}882// V.6. 2nd letter is 'c' or 'j'883if (str.indexOf('nc') == 0) {884// nc885if (str.indexOf('ncr') == 0) {886// ncr -- kencrung887return { CoreSound: 'ꦚ꧀ꦕꦿ', len: 3 };888}889else if (str.indexOf('ncl') == 0) {890// ncl -- kinclong891return { CoreSound: 'ꦚ꧀ꦕ꧀ꦭ', len: 3 };892}893else {894return { CoreSound: 'ꦚ꧀ꦕ', len: 2 };895}896}897else if (str.indexOf('hc') == 0) {898// wignyan + ca899return { CoreSound: 'ꦃꦕ', len: 2 };900}901else if (str.indexOf('rc') == 0) {902// layar + ca -- arca903return { CoreSound: 'ꦂꦕ', len: 2 };904}905else if (str.indexOf('cc') == 0) {906// cc -- impossible combination in real text907return { CoreSound: 'ꦕ꧀ꦕ', len: 2 };908}909else if (this.str2.indexOf('qc') == 0) {910// only pasangan ca911return { CoreSound: '꧀ꦕ', len: 2 };912}913else if (str.indexOf('c') == 1) {914// c915return {916CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦕ',917len: 2918};919}920if (str.indexOf('nj') == 0) {921// nj922if (str.indexOf('njr') == 0) {923// njr -- anjrit924return { CoreSound: 'ꦚ꧀ꦗꦿ', len: 3 };925}926else if (str.indexOf('njl') == 0) {927// njl -- anjlog928return { CoreSound: 'ꦚ꧀ꦗ꧀ꦭ', len: 3 };929}930else {931return { CoreSound: 'ꦚ꧀ꦗ', len: 2 };932}933}934else if (str.indexOf('hj') == 0) {935// wignyan + ja936return { CoreSound: 'ꦃꦗ', len: 2 };937}938else if (str.indexOf('rj') == 0) {939// layar + ja940return { CoreSound: 'ꦂꦗ', len: 2 };941}942else if (str.indexOf('jj') == 0) {943// jj -- impossible combination in real text944return { CoreSound: 'ꦗ꧀ꦗ', len: 2 };945}946else if (this.str2.indexOf('qj') == 0) {947// only pasangan ja948return { CoreSound: '꧀ꦗ', len: 2 };949}950else if (str.indexOf('j') == 1) {951// j952return {953CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦗ',954len: 2955};956}957// V.7. 2nd letter is 'ñ' or 'n'958if (str.indexOf('jñ') == 0) {959// suku kata diawali 'jñ'960if (str.indexOf('jñl') == 0) {961// suku kata diawali 'jñ' - nya murda962return { CoreSound: 'ꦘ꧀ꦭ', len: 3 };963}964else if (str.indexOf('jñr') == 0) {965// nya murda + cakra966return { CoreSound: 'ꦘꦿ', len: 3 };967}968else if (str.indexOf('jñw') == 0) {969// nya murda + panjingan wa970return { CoreSound: 'ꦘ꧀ꦮ', len: 3 };971}972else if (str.indexOf('jñy') == 0) {973// nya murda + wignyan974return { CoreSound: 'ꦘꦾ', len: 3 };975}976else {977return { CoreSound: 'ꦘ', len: 2 };978}979}980else if (str.indexOf('jn') == 0) {981// suku kata diawali 'jn'982if (str.indexOf('jny') == 0) {983// suku kata diawali 'jny' - nya murda984if (str.indexOf('jnyl') == 0) {985// suku kata diawali 'jny' - nya murda986return { CoreSound: 'ꦘ꧀ꦭ', len: 4 };987}988else if (str.indexOf('jnyr') == 0) {989// nya murda + cakra990return { CoreSound: 'ꦘꦿ', len: 4 };991}992else if (str.indexOf('jnyw') == 0) {993// nya murda + panjingan wa994return { CoreSound: 'ꦘ꧀ꦮ', len: 4 };995}996else if (str.indexOf('jnyy') == 0) {997// nya murda + wignyan998return { CoreSound: 'ꦘꦾ', len: 4 };999}1000else {1001return { CoreSound: 'ꦘ', len: 3 };1002}1003}1004else {1005return { CoreSound: 'ꦗ꧀ꦤ', len: 2 };1006}1007// Uncatched exception: -h followed by ngy, ngr, ngl, ngw1008}1009else if (str.indexOf('hn') == 0) {1010// wignyan + na1011return { CoreSound: 'ꦃꦤ', len: 2 };1012// Uncatched exception: -r followed by ngy, ngr, ngl, ngw1013}1014else if (str.indexOf('rn') == 0) {1015// layar + na1016return { CoreSound: 'ꦂꦤ', len: 2 };1017}1018else if (str.indexOf('nn') == 0) {1019// nn, e.g. root word ends with 'n' with suffix -i1020if (str.indexOf('nng') == 0) {1021//1022return { CoreSound: 'ꦤ꧀ꦁ', len: 3 };1023}1024else if (str.indexOf('nng') == 0) {1025//1026return { CoreSound: 'ꦤ꧀ꦚ꧀', len: 3 };1027}1028else {1029return { CoreSound: 'ꦤ꧀ꦤ', len: 2 };1030}1031}1032else if (this.str2.indexOf('qn') == 0) {1033// only pasangan na1034return { CoreSound: '꧀ꦤ', len: 2 };1035}1036else if (str.indexOf('ñ') == 1) {1037// huruf asing sih sebenarnya, kemungkinan kecil muncul1038return {1039CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦚ',1040len: 21041};1042}1043else if (str.indexOf('n') == 1) {1044//1045return {1046CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦤ',1047len: 21048};1049}1050// suku kata memiliki konsonan tersebut yang tidak di posisi kedua1051if (str.indexOf('h') > 1 ||1052str.indexOf('g') > 1 ||1053str.indexOf('y') > 1 ||1054str.indexOf('r') > 1 ||1055str.indexOf('l') > 1 ||1056str.indexOf('w') > 1 ||1057str.indexOf('c') > 1 ||1058str.indexOf('j') > 1 ||1059str.indexOf('n') > 1 ||1060str.indexOf('ñ') > 1) {1061let sound = '';1062let len = 0;1063let index = 0;1064for (index = 0; index < str.length; index++) {1065const c = str[index];1066if (!isVowel(c)) {1067sound += this.ResolveCharacterSound(c);1068len++;1069}1070else {1071break;1072}1073}1074return { CoreSound: sound, len: len };1075}1076return { CoreSound: null, len: 1 };1077}1078GetCoreSound(str) {1079const soundMap1 = {1080// 26 uppercase for non-Murda, largely mirror lowercase, except AEIOU, and HR1081A: 'ꦄ',1082B: 'ꦧ',1083C: 'ꦕ',1084D: 'ꦢ',1085E: 'ꦌ',1086F: 'ꦥ꦳',1087G: 'ꦒ',1088H: 'ꦲ',1089I: 'ꦆ',1090J: 'ꦗ',1091K: 'ꦏ',1092L: 'ꦭ',1093M: 'ꦩ',1094N: 'ꦤ',1095O: 'ꦎ',1096P: 'ꦥ',1097Q: '꧀',1098R: 'ꦫ',1099S: 'ꦱ',1100T: 'ꦠ',1101U: 'ꦈ',1102V: 'ꦮ꦳',1103W: 'ꦮ',1104X: 'ꦼ',1105Y: 'ꦪ',1106Z: 'ꦰ' // Sa Mahaprana1107// test: ABaCaDaEFaGaHaJaKaLaMaNaOPaRaSaTaUVaWaXYaZa1108};1109const soundMap2 = {1110// 26 uppercase for Murda (notice for J, Q, R, and Z)1111A: 'ꦄ',1112B: 'ꦨ',1113C: 'ꦖ',1114D: 'ꦣ',1115E: 'ꦌ',1116F: 'ꦦ꦳',1117G: 'ꦓ',1118H: 'ꦲ꦳',1119I: 'ꦆ',1120J: 'ꦙ',1121K: 'ꦑ',1122L: 'ꦭ',1123M: 'ꦩ',1124N: 'ꦟ',1125O: 'ꦎ',1126P: 'ꦦ',1127Q: 'ꦐ',1128R: 'ꦬ',1129S: 'ꦯ',1130T: 'ꦡ',1131U: 'ꦈ',1132V: 'ꦮ꦳',1133W: 'ꦮ',1134X: 'ꦼ',1135Y: 'ꦪ',1136Z: 'ꦰ' // Sa mahaprana1137// test: ABaCaDaEFaGaHaJaKaLaMaNaOPaQaRaSaTaUVaWaXaYaZa1138};1139const soundMap3 = {1140// 26 lowercase + 35 special, same for both Murda or non-Murda1141a: 'ꦲ',1142b: 'ꦧ',1143c: 'ꦕ',1144d: 'ꦢ',1145e: 'ꦲꦺ',1146f: 'ꦥ꦳',1147g: 'ꦒ',1148h: 'ꦃ',1149i: 'ꦲꦶ',1150j: 'ꦗ',1151k: 'ꦏ',1152l: 'ꦭ',1153m: 'ꦩ',1154n: 'ꦤ',1155o: 'ꦲꦺꦴ',1156p: 'ꦥ',1157q: '꧀',1158r: 'ꦂ',1159s: 'ꦱ',1160t: 'ꦠ',1161u: 'ꦲꦸ',1162v: 'ꦮ꦳',1163w: 'ꦮ',1164x: 'ꦲꦼ',1165y: 'ꦪ',1166z: 'ꦗ꦳',1167È: 'ꦌ',1168É: 'ꦌ',1169Ê: 'ꦄꦼ',1170Ě: 'ꦄꦼ',1171Ĕ: 'ꦄꦼ',1172è: 'ꦲꦺ',1173é: 'ꦲꦺ',1174ê: 'ꦲꦼ',1175ě: 'ꦲꦼ',1176ĕ: 'ꦲꦼ',1177ə: 'ꦲꦼ',1178ɔ: 'ꦲ',1179å: 'ꦲ',1180ô: 'ꦲ',1181â: 'ꦲꦴ',1182ā: 'ꦲꦴ',1183ī: 'ꦲꦷ',1184ū: 'ꦲꦹ',1185ō: 'ꦲꦼꦴ',1186Ñ: 'ꦚ',1187ñ: 'ꦚ',1188ɲ: 'ꦚ',1189Ŋ: 'ꦔ',1190ŋ: 'ꦔ',1191Ṇ: 'ꦟ',1192ṇ: 'ꦟ',1193Ḍ: 'ꦝ',1194ḍ: 'ꦝ',1195Ṭ: 'ꦛ',1196ṭ: 'ꦛ',1197ś: 'ꦯ',1198Ṣ: 'ꦰ',1199ṣ: 'ꦰ',1200Ṛ: 'ꦽ',1201ṛ: 'ꦽ' // idem1202// test: Èè.Éé.Êê.Ěě.Ĕĕ.Ṛṛ.ôâāīūōåɔə1203// test: ḌaḍaṆaṇaṢaṣaṬaṭaŊaŋaÑañaɲaśa1204};1205let soundMap;1206// var modeMurda = document.getElementsByName("murda");1207// for (var rad in modeMurda) {1208// if (modeMurda[rad].checked)1209// murda = modeMurda[rad].value;1210// }1211if (this.murda)1212soundMap = { ...soundMap2, ...soundMap3 };1213// if(murda == "tidak")1214else1215soundMap = { ...soundMap1, ...soundMap3 };1216const h_shift = this.GetShift(str);1217let core = str;1218if (h_shift.CoreSound == null) {1219if (soundMap[str.charAt(0)])1220core = soundMap[str.charAt(0)];1221return {1222CoreSound: core,1223len: 11224};1225}1226else {1227return h_shift;1228}1229}1230ResolveCharacterSound(c) {1231const str = c.toString();1232if (isDigit(c)) {1233return '' + ('꧇' + (parseInt(c) - 0));1234}1235else if (isHR(str[0])) {1236return '' + this.GetCoreSound(str).CoreSound; // layar dan wignyan1237}1238else if (isCJ(str[1])) {1239return '' + this.GetCoreSound(str).CoreSound + '꧀'; // anuswara1240}1241else if (isConsonant(str[0])) {1242return '' + this.GetCoreSound(str).CoreSound + '꧀';1243}1244else {1245// if (isVowel(str[0])) {1246return '' + this.GetCoreSound(str).CoreSound;1247}1248}1249GetSound(str) {1250str = SuperTrim(str);1251this.str2 = str.toLowerCase();1252if (str == null || str == '')1253return '';1254const SpecialSound = GetSpecialSound(str);1255if (SpecialSound != null && str.length == 1)1256return SpecialSound;1257if (str.length == 1)1258return this.ResolveCharacterSound(str[0]);1259else {1260const core_sound = this.GetCoreSound(str);1261// return "1"+core_sound.CoreSound+"2";1262let matra = '';1263let konsonan = '';1264if (core_sound.len >= 1) {1265matra = this.GetMatra(str.substring(core_sound.len)); // xeiou (pepet, taling, suku, taling tarung, wulu, dll.)1266/* if () {12671268} else {12691270} */1271}1272else {1273matra = '';1274} // a/å/ɔ1275/* rules for some cluster like ngg- that have different behaviour depending if it's the start of a word or not.1276TODO: find more elegant solution */1277if (this.str2.indexOf('nggr') == 0) {1278// nggr-1279if (this.vowelPrev)1280konsonan = 'ꦁꦒꦿ';1281// <vowel>nggr-, e.g. panggrahita1282// else if (matra = "")1283else1284konsonan = 'ꦔ꧀ꦒꦿ'; // <nonvowel>nggr-, i.e. nggronjal1285}1286else if (this.str2.indexOf('nggl') == 0) {1287// nggl-, e.g. ngglantung1288konsonan = 'ꦔ꧀ꦒ꧀ꦭ';1289}1290else if (this.str2.indexOf('nggw') == 0) {1291// nggw-, e.g. munggwing1292konsonan = 'ꦔ꧀ꦒ꧀ꦮ';1293}1294else if (this.str2.indexOf('nggy') == 0) {1295// nggy-, e.g. anggyat1296konsonan = 'ꦔ꧀ꦒꦾ';1297}1298else if (this.str2.indexOf('ngg') == 0) {1299// ngg-1300if (this.vowelPrev)1301konsonan = 'ꦁꦒ';1302// <vowel>ngg-, e.g. tunggal1303// else if (spacePrev) konsonan = "ꦔ꧀";//<space>ngg-, e.g. ditinggal nggambar (it has a zws)1304else1305konsonan = 'ꦔ꧀ꦒ'; // <nonvowel>ngg-, i.e. nggambar1306// for cluster longer than 4 consonants, such as "ditinggalnggambar",1307// need to separate it by a space, "ditinggal nggambar" to be correct1308}1309else if (this.str2.indexOf('rlx') == 0) {1310// r lx, e.g. pasarlxgi1311konsonan = 'ꦂꦊ';1312matra = '';1313}1314else if (this.str2.indexOf('rrx') == 0) {1315// r rx1316konsonan = 'ꦂꦉ';1317matra = '';1318}1319else if (this.str2.indexOf('hlx') == 0) {1320// h lx1321if (this.vowelPrev) {1322konsonan = 'ꦃꦊ';1323matra = '';1324}1325else1326konsonan = 'ꦲ꧀ꦭꦼ';1327matra = '';1328}1329else if (this.str2.indexOf('hrx') == 0) {1330// h rx1331if (this.vowelPrev) {1332konsonan = 'ꦃꦉ';1333matra = '';1334}1335else1336konsonan = 'ꦲꦽ';1337matra = '';1338}1339else if (this.str2.indexOf('qlx') == 0) {1340// just pasangan la + pepet1341konsonan = '꧀ꦭꦼ';1342matra = '';1343}1344else if (this.str2.indexOf('qrx') == 0) {1345// just cakra keret1346konsonan = 'ꦽ';1347matra = '';1348}1349else if (core_sound.CoreSound == 'ꦂꦂꦮ') {1350// -rw-1351if (this.vowelPrev)1352konsonan = 'ꦂꦮ';1353// -rw- -- arwana1354else1355konsonan = 'ꦫ꧀ꦮ'; // rw- -- rwa/rwi/rwab1356}1357else if (core_sound.CoreSound == 'ꦃꦃꦭ') {1358// -hl-1359if (this.vowelPrev)1360konsonan = 'ꦃꦭ';1361// -hl-1362else1363konsonan = 'ꦲ꧀ꦭ'; // hlam1364}1365else if (core_sound.CoreSound == 'ꦃꦃꦮ') {1366// -hw-1367if (this.vowelPrev)1368konsonan = 'ꦃꦮ';1369// -hw-1370else1371konsonan = 'ꦲ꧀ꦮ'; // hwab,hwan1372}1373else if (core_sound.CoreSound == 'ꦃꦲꦾ') {1374// -hy-1375if (this.vowelPrev)1376konsonan = 'ꦃꦪ';1377// sembahyang1378else1379konsonan = 'ꦲꦾ'; // hyang1380/* rules for some characters that change depends on the matra/vowel (e.g. lx and rx, and -rx) */1381}1382else if (findstr(core_sound.CoreSound, 'ꦾ') && matra == '꧀') {1383// pengkal1384konsonan = core_sound.CoreSound;1385matra = ''; // -y-1386}1387else if (findstr(core_sound.CoreSound, 'ꦿ') && matra == '꧀') {1388// cakra1389konsonan = core_sound.CoreSound;1390matra = ''; // -r-1391}1392else if (findstr(core_sound.CoreSound, 'ꦿ') && matra == 'ꦼ') {1393// cakra keret1394if ((str[0] == 'n' && str[1] == 'y') ||1395((str[0] == 't' || str[0] == 'd') && str[1] == 'h')) {1396konsonan = this.GetCoreSound(str[0] + str[1]).CoreSound + 'ꦽ';1397matra = ''; // nyrê-, thrê-, dhrê-1398}1399else if (str[0] == 'n' && str[1] == 'g') {1400if (str[2] == 'g')1401konsonan = 'ꦔ꧀ꦒꦽ';1402else1403konsonan = 'ꦔꦽ';1404matra = ''; // nggrê-/ngrê-1405}1406else {1407konsonan = this.GetCoreSound(str[0]).CoreSound + 'ꦽ';1408matra = ''; // -rê-1409}1410}1411else if (findstr(core_sound.CoreSound, 'ꦭ') && matra == 'ꦼ') {1412// nga lelet1413if ((str[0] == 'n' && str[1] == 'y') ||1414((str[0] == 't' || str[0] == 'd') && str[1] == 'h')) {1415konsonan = this.GetCoreSound(str[0] + str[1]).CoreSound + '꧀ꦭꦼ';1416matra = ''; // nylê-, thlê-, dhlê-1417}1418else if (str[0] == 'n' && str[1] == 'g') {1419if (str[2] == 'g')1420konsonan = 'ꦔ꧀ꦒ꧀ꦭꦼ';1421else1422konsonan = 'ꦔ꧀ꦭꦼ';1423matra = ''; // ngglê-/nglê-1424}1425else if (str[0] == 'l') {1426konsonan = 'ꦊ';1427matra = ''; // -lê-1428}1429else {1430konsonan = this.GetCoreSound(str[0]).CoreSound + '꧀ꦭꦼ';1431matra = ''; // -lê-1432}1433}1434else if (core_sound.CoreSound == 'ꦃ' && matra == '꧀') {1435// wignyan - 12 April1436konsonan = 'ꦲ'; // ha1437}1438else if (core_sound.CoreSound == 'ꦃ' && matra != '꧀') {1439// wignyan1440konsonan = 'ꦲ'; // ha1441}1442else if (core_sound.CoreSound == 'ꦂ' && matra == 'ꦼ') {1443// pa cerek1444konsonan = 'ꦉ';1445matra = ''; // rê1446}1447else if (core_sound.CoreSound == 'ꦂ' && matra == '꧀') {1448// layar1449konsonan = 'ꦫ'; // ra1450}1451else if (core_sound.CoreSound == 'ꦂ' && matra != '꧀') {1452// layar1453konsonan = 'ꦫ'; // ra1454}1455else if (core_sound.CoreSound == 'ꦁ' && matra == '꧀') {1456// cecak1457konsonan = 'ꦁ';1458matra = ''; // cecak1459}1460else if (core_sound.CoreSound == 'ꦁ' && matra != '꧀') {1461// cecak1462konsonan = 'ꦔ'; // nga1463}1464else {1465konsonan = core_sound.CoreSound;1466}1467return '' + konsonan + matra;1468}1469}1470toLatin() {1471// var agt = navigator.userAgent.toLowerCase();1472// if (agt.indexOf("msie")!=-1) { //IE1473// var range = document.selection.createRange()1474// txt = range.text;1475// if (txt == '') {1476// var str = window.document.formText.editSrc.value;1477// }else{1478// var str = range.text;1479// }1480// }1481// else {1482// str = window.document.formText.editSrc.value;1483// }1484const ganti = (index, character, str) => str.substr(0, index) + character;1485const ganti2 = (index, character, str) => str.substr(0, index - 1) + character;1486const ganti3 = (index, character, str) => str.substr(0, index - 2) + character;1487// const capitalize = (index: number, character: string, str: string) =>1488// str.charAt(0).toUpperCase() + str.slice(1)1489let trans = this.str;1490const regexp_file = this.aksara2Latin();1491for (let i = 0, j = 0; i < this.str.length; i++) {1492if (!regexp_file[this.str[i]]) {1493// not Aksara Jawa1494trans = ganti(j, this.str[i], trans);1495j++;1496}1497else {1498if (this.str[i] == 'ꦴ' ||1499this.str[i] == 'ꦶ' ||1500this.str[i] == 'ꦸ' ||1501this.str[i] == 'ꦺ' ||1502this.str[i] == 'ꦼ') {1503if (i > 2 && this.str[i - 1] == 'ꦲ' && this.str[i - 2] == 'ꦲ') {1504// -hah-1505if (this.str[i] == 'ꦴ')1506trans = ganti3(j, 'ā', trans);1507else if (this.str[i] == 'ꦶ')1508trans = ganti3(j, 'ai', trans);1509else if (this.str[i] == 'ꦸ')1510trans = ganti3(j, 'au', trans);1511else if (this.str[i] == 'ꦺ')1512trans = ganti3(j, 'ae', trans);1513else if (this.str[i] == 'ꦼ')1514trans = ganti3(j, 'aě', trans);1515// str[i] == "ꦶ" || str[i] == "ꦸ" || str[i] == "ꦺ" || str[i] == "ꦼ"1516}1517else if (i > 2 && this.str[i - 1] == 'ꦲ') {1518// -h-1519if (this.str[i] == 'ꦴ')1520trans = ganti2(j, 'ā', trans);1521else if (this.str[i] == 'ꦶ')1522trans = ganti2(j, 'i', trans);1523else if (this.str[i] == 'ꦸ')1524trans = ganti2(j, 'u', trans);1525else if (this.str[i] == 'ꦺ')1526trans = ganti2(j, 'e', trans);1527else if (this.str[i] == 'ꦼ')1528trans = ganti2(j, 'ě', trans);1529} /**/1530else if (i > 0 &&1531this.str[i] == 'ꦴ' &&1532this.str[i - 1] == 'ꦺ') {1533trans = ganti2(j, 'o', trans); // -o //2 aksara -> 1 huruf1534}1535else if (i > 0 && this.str[i] == 'ꦴ' && this.str[i - 1] == 'ꦻ') {1536trans = ganti3(j, 'au', trans); // -au //2 aksara -> 2 huruf1537}1538else if (this.str[i] == 'ꦴ') {1539trans = ganti(j, 'aa', trans); // -aa1540j++;1541}1542else if (i > 0 &&1543(this.str[i] == 'ꦶ' ||1544this.str[i] == 'ꦸ' ||1545this.str[i] == 'ꦺ' ||1546this.str[i] == 'ꦼ') &&1547(this.str[i - 1] == 'ꦄ' ||1548this.str[i - 1] == 'ꦌ' ||1549this.str[i - 1] == 'ꦆ' ||1550this.str[i - 1] == 'ꦎ' ||1551this.str[i - 1] == 'ꦈ')) {1552trans = ganti(j, regexp_file[this.str[i]], trans);1553j++;1554}1555else {1556trans = ganti2(j, regexp_file[this.str[i]], trans);1557}1558}1559else if (this.str[i] == 'ꦽ' ||1560this.str[i] == 'ꦾ' ||1561this.str[i] == 'ꦿ' ||1562this.str[i] == 'ꦷ' ||1563this.str[i] == 'ꦹ' ||1564this.str[i] == 'ꦻ' ||1565this.str[i] == 'ꦇ' ||1566this.str[i] == 'ꦍ') {1567// 1 aksara -> 2 huruf1568trans = ganti2(j, regexp_file[this.str[i]], trans);1569j++;1570}1571else if (this.str[i] == '꦳') {1572// 2 aksara -> 2 huruf1573if (i > 0 && this.str[i - 1] == 'ꦗ') {1574if (i > 1 && this.str[i - 2] == '꧊') {1575trans = ganti3(j, 'Za', trans);1576}1577else {1578trans = ganti3(j, 'za', trans);1579}1580}1581else if (i > 0 && this.str[i - 1] == 'ꦥ') {1582if (i > 1 && this.str[i - 2] == '꧊') {1583trans = ganti3(j, 'Fa', trans);1584}1585else {1586trans = ganti3(j, 'fa', trans);1587}1588}1589else if (i > 0 && this.str[i - 1] == 'ꦮ') {1590if (i > 1 && this.str[i - 2] == '꧊') {1591trans = ganti3(j, 'Va', trans);1592}1593else {1594trans = ganti3(j, 'va', trans);1595} // catatan, "va" biasanya ditulis sama dengan "fa" (dengan pa+cecak telu), variannya adalah wa+cecak telu.1596}1597else if (i > 0 && this.str[i - 1] == 'ꦲ') {1598if (i > 1 && this.str[i - 2] == '꧊') {1599trans = ganti3(j, 'Ḥa', trans);1600}1601else {1602trans = ganti3(j, 'ḥa', trans);1603}1604}1605else if (i > 0 && this.str[i - 1] == 'ꦏ') {1606if (i > 1 && this.str[i - 2] == '꧊') {1607trans = ganti3(j, 'Kha', trans);1608j++;1609}1610else {1611trans = ganti3(j, 'kha', trans);1612j++;1613}1614}1615else if (i > 0 && this.str[i - 1] == 'ꦢ') {1616if (i > 1 && this.str[i - 2] == '꧊') {1617trans = ganti3(j, 'Dza', trans);1618j++;1619}1620else {1621trans = ganti3(j, 'dza', trans);1622j++;1623}1624}1625else if (i > 0 && this.str[i - 1] == 'ꦱ') {1626if (i > 1 && this.str[i - 2] == '꧊') {1627trans = ganti3(j, 'Sya', trans);1628j++;1629}1630else {1631trans = ganti3(j, 'sya', trans);1632j++;1633}1634}1635else if (i > 0 && this.str[i - 1] == 'ꦒ') {1636if (i > 1 && this.str[i - 2] == '꧊') {1637trans = ganti3(j, 'Gha', trans);1638j++;1639}1640else {1641trans = ganti3(j, 'gha', trans);1642j++;1643}1644}1645else if (i > 0 && this.str[i - 1] == 'ꦔ') {1646trans = ganti3(j, "'a", trans);1647}1648else {1649trans = ganti2(j, regexp_file[this.str[i]], trans);1650}1651}1652else if (this.str[i] == '꧀') {1653trans = ganti2(j, regexp_file[this.str[i]], trans);1654}1655else if (this.str[i] == 'ꦏ' ||1656this.str[i] == 'ꦐ' ||1657this.str[i] == 'ꦒ' ||1658this.str[i] == 'ꦕ' ||1659this.str[i] == 'ꦗ' ||1660this.str[i] == 'ꦟ' ||1661this.str[i] == 'ꦠ' ||1662this.str[i] == 'ꦡ' ||1663this.str[i] == 'ꦢ' ||1664this.str[i] == 'ꦣ' ||1665this.str[i] == 'ꦤ' ||1666this.str[i] == 'ꦥ' ||1667this.str[i] == 'ꦧ' ||1668this.str[i] == 'ꦩ' ||1669this.str[i] == 'ꦪ' ||1670this.str[i] == 'ꦫ' ||1671this.str[i] == 'ꦬ' ||1672this.str[i] == 'ꦭ' ||1673this.str[i] == 'ꦮ' ||1674this.str[i] == 'ꦯ' ||1675this.str[i] == 'ꦰ' ||1676this.str[i] == 'ꦱ' ||1677this.str[i] == 'ꦉ' ||1678this.str[i] == 'ꦊ' ||1679this.str[i] == 'ꦁ' ||1680this.str[i] == 'ꦲ' ||1681this.str[i] == 'ꦑ' ||1682this.str[i] == 'ꦓ' ||1683this.str[i] == 'ꦖ' ||1684this.str[i] == 'ꦙ' ||1685this.str[i] == 'ꦡ' ||1686this.str[i] == 'ꦣ' ||1687this.str[i] == 'ꦦ' ||1688this.str[i] == 'ꦨ') {1689if (i > 0 && this.str[i - 1] == '꧊') {1690if (this.str[i] == 'ꦐ') {1691trans = ganti(j, 'Qa', trans);1692j += 2;1693}1694else if (this.str[i] == 'ꦧ' || this.str[i] == 'ꦨ') {1695trans = ganti(j, 'Ba', trans);1696j += 2;1697}1698else if (this.str[i] == 'ꦕ' || this.str[i] == 'ꦖ') {1699trans = ganti(j, 'Ca', trans);1700j += 2;1701}1702else if (this.str[i] == 'ꦢ' || this.str[i] == 'ꦣ') {1703trans = ganti(j, 'Da', trans);1704j += 2;1705}1706else if (this.str[i] == 'ꦒ' || this.str[i] == 'ꦓ') {1707trans = ganti(j, 'Ga', trans);1708j += 2;1709}1710else if (this.str[i] == 'ꦲ') {1711if (i > 0 &&1712(this.str[i - 1] == 'ꦼ' ||1713this.str[i - 1] == 'ꦺ' ||1714this.str[i - 1] == 'ꦶ' ||1715this.str[i - 1] == 'ꦴ' ||1716this.str[i - 1] == 'ꦸ' ||1717this.str[i - 1] == 'ꦄ' ||1718this.str[i - 1] == 'ꦌ' ||1719this.str[i - 1] == 'ꦆ' ||1720this.str[i - 1] == 'ꦎ' ||1721this.str[i - 1] == 'ꦈ' ||1722this.str[i - 1] == 'ꦿ' ||1723this.str[i - 1] == 'ꦾ' ||1724this.str[i - 1] == 'ꦽ')) {1725trans = ganti(j, 'h' + regexp_file[this.str[i]], trans);1726j += 2;1727}1728if (i > 0 && this.str[i - 1] == '꧊') {1729trans = ganti(j, 'H' + regexp_file[this.str[i]], trans);1730j += 2;1731}1732else {1733trans = ganti(j, '@' + regexp_file[this.str[i]], trans);1734j += 2;1735}1736// trans = ganti(j, "Ha", trans);j+=2;1737}1738else if (this.str[i] == 'ꦗ' || this.str[i] == 'ꦙ') {1739trans = ganti(j, 'Ja', trans);1740j += 2;1741}1742else if (this.str[i] == 'ꦏ' || this.str[i] == 'ꦑ') {1743trans = ganti(j, 'Ka', trans);1744j += 2;1745}1746else if (this.str[i] == 'ꦭ') {1747trans = ganti(j, 'La', trans);1748j += 2;1749}1750else if (this.str[i] == 'ꦩ') {1751trans = ganti(j, 'Ma', trans);1752j += 2;1753}1754else if (this.str[i] == 'ꦤ' || this.str[i] == 'ꦟ') {1755trans = ganti(j, 'Na', trans);1756j += 2;1757}1758else if (this.str[i] == 'ꦥ' || this.str[i] == 'ꦦ') {1759trans = ganti(j, 'Pa', trans);1760j += 2;1761}1762else if (this.str[i] == 'ꦫ' || this.str[i] == 'ꦬ') {1763trans = ganti(j, 'Ra', trans);1764j += 2;1765}1766else if (this.str[i] == 'ꦱ' || this.str[i] == 'ꦯ') {1767trans = ganti(j, 'Sa', trans);1768j += 2;1769}1770else if (this.str[i] == 'ꦠ' || this.str[i] == 'ꦡ') {1771trans = ganti(j, 'Ta', trans);1772j += 2;1773}1774else if (this.str[i] == 'ꦮ') {1775trans = ganti(j, 'Wa', trans);1776j += 2;1777}1778else if (this.str[i] == 'ꦪ') {1779trans = ganti(j, 'Ya', trans);1780j += 2;1781}1782else {1783ganti(j, regexp_file[this.str[i]], trans);1784j += 3;1785}1786}1787else if (i > 0 && this.str[i] == 'ꦲ' && this.str[i - 1] == 'ꦃ') {1788// double hh1789trans = ganti(j, 'a', trans);1790j++;1791}1792else if (i > 0 && this.str[i] == 'ꦫ' && this.str[i - 1] == 'ꦂ') {1793// double rr1794trans = ganti(j, 'a', trans);1795j++;1796}1797else if (i > 0 && this.str[i] == 'ꦔ' && this.str[i - 1] == 'ꦁ') {1798// double ngng1799trans = ganti(j, 'a', trans);1800j++;1801}1802else if (i > 1 &&1803this.str[i] == 'ꦕ' &&1804this.str[i - 1] == '꧀' &&1805this.str[i - 2] == 'ꦚ') {1806// nyj & nyc1807trans = ganti(j - 3, 'nca', trans);1808}1809else if (i > 1 &&1810this.str[i] == 'ꦗ' &&1811this.str[i - 1] == '꧀' &&1812this.str[i - 2] == 'ꦚ') {1813// nyj & nyc1814trans = ganti(j - 3, 'nja', trans);1815}1816else if (this.str[i] == 'ꦲ' &&1817(i == 0 ||1818[1819' ',1820'',1821'꧀',1822'꦳',1823'ꦴ',1824'ꦶ',1825'ꦷ',1826'ꦸ',1827'ꦹ',1828'ꦺ',1829'ꦻ',1830'ꦼ',1831'ꦽ',1832'ꦾ',1833'ꦿ'1834].indexOf(this.str[i - 1]) >= 0)) {1835// ha, preceeded by space or zws or open vowel1836trans = ganti(j, '_a', trans);1837j += 2;1838}1839else if (this.str[i] == 'ꦑ' ||1840this.str[i] == 'ꦓ' ||1841this.str[i] == 'ꦖ' ||1842this.str[i] == 'ꦙ' ||1843this.str[i] == 'ꦡ' ||1844this.str[i] == 'ꦣ' ||1845this.str[i] == 'ꦦ' ||1846this.str[i] == 'ꦨ') {1847// bha, cha, dha, dll.1848trans = ganti(j, regexp_file[this.str[i]], trans);1849j += 3;1850}1851else {1852// ba, ca, da, dll.1853trans = ganti(j, regexp_file[this.str[i]], trans);1854j += 2;1855}1856}1857else if (this.str[i] == 'ꦔ' ||1858this.str[i] == 'ꦘ' ||1859this.str[i] == 'ꦚ' ||1860this.str[i] == 'ꦛ' ||1861this.str[i] == 'ꦜ' ||1862this.str[i] == 'ꦝ' ||1863this.str[i] == 'ꦞ' ||1864this.str[i] == 'ꦋ') {1865// nga, nya, tha, dha1866if (i > 0 && this.str[i - 1] == '꧊') {1867if (this.str[i] == 'ꦔ') {1868trans = ganti(j, 'Nga', trans);1869j += 3;1870}1871else if (this.str[i] == 'ꦚ' || this.str[i] == 'ꦘ') {1872trans = ganti(j, 'Nya', trans);1873j += 3;1874}1875else if (this.str[i] == 'ꦛ' || this.str[i] == 'ꦜ') {1876trans = ganti(j, 'Tha', trans);1877j += 3;1878}1879else if (this.str[i] == 'ꦝ' || this.str[i] == 'ꦞ') {1880trans = ganti(j, 'Dha', trans);1881j += 3;1882}1883else {1884ganti(j, regexp_file[this.str[i]], trans);1885j += 3;1886}1887}1888else if (i > 0 && this.str[i] == 'ꦘ') {1889trans = ganti(j, regexp_file[this.str[i]], trans);1890j += 4;1891}1892else {1893trans = ganti(j, regexp_file[this.str[i]], trans);1894j += 3;1895}1896}1897else if (this.str[i] == '꧊') {1898// penanda nama diri -- made up for Latin back-compat1899trans = ganti(j, '', trans);1900}1901else if ((this.str[i] == ' ', trans)) {1902if (i > 0 && this.str[i - 1] == '꧀') {1903// pangkon diikuti regular space = koma1904trans = ganti(j, ', ', trans);1905j += 2;1906}1907else {1908trans = ganti(j, ' ', trans);1909j++;1910}1911}1912else if ((this.str[i] == '꧈', trans)) {1913if (i > 0 && this.str[i - 1] == '꧀') {1914// pangkon diikuti pada lingsa = titik1915trans = ganti(j, '.', trans);1916j++;1917}1918else {1919// pada lingsa saja = koma1920trans = ganti(j, ',', trans);1921j++;1922}1923}1924else {1925trans = ganti(j, regexp_file[this.str[i]], trans);1926j++;1927}1928}1929}1930trans = trans1931.split(' ')1932.map((v) => v.startsWith('_') ? v.replace('_', this.isHVokal ? '' : 'h') : v)1933.join(' ');1934return trans.toString();1935}1936aksara2Latin() {1937return {1938ꦏ: 'ka',1939ꦐ: 'qa',1940ꦑ: 'kʰa',1941ꦒ: 'ga',1942ꦓ: 'gʰa',1943ꦔ: 'nga',1944ꦕ: 'ca',1945ꦖ: 'cʰa',1946ꦗ: 'ja',1947ꦘ: 'jnya',1948ꦙ: 'jʰa',1949ꦚ: 'nya',1950ꦛ: 'tha',1951ꦜ: 'ṭʰa',1952ꦝ: 'dha',1953ꦞ: 'ḍʰa',1954ꦟ: 'ṇa',1955ꦠ: 'ta',1956ꦡ: 'ṭa',1957ꦢ: 'da',1958ꦣ: 'ḍa',1959ꦤ: 'na',1960ꦥ: 'pa',1961ꦦ: 'pʰa',1962ꦧ: 'ba',1963ꦨ: 'bʰa',1964ꦩ: 'ma',1965ꦪ: 'ya',1966ꦫ: 'ra',1967ꦬ: 'ṛa',1968ꦭ: 'la',1969ꦮ: 'wa',1970ꦯ: 'śa',1971ꦰ: 'ṣa',1972ꦱ: 'sa',1973ꦲ: 'ha',1974'ꦁ': 'ng',1975'ꦂ': 'r',1976'ꦃ': 'h',1977ꦄ: 'A',1978ꦅ: 'I',1979ꦆ: 'I',1980ꦇ: 'Ii',1981ꦈ: 'U',1982ꦉ: 'rê',1983ꦊ: 'lê',1984ꦋ: 'lêu',1985ꦌ: 'E',1986ꦍ: 'Ai',1987ꦎ: 'O',1988'ꦺꦴ': 'o',1989'ꦴ': 'a',1990'ꦶ': 'i',1991'ꦷ': 'ii',1992'ꦸ': 'u',1993'ꦹ': 'uu',1994'ꦺ': 'e',1995'ꦻ': 'ai',1996'ꦼ': 'ê',1997'ꦽ': 'rê',1998'ꦾ': 'ya',1999'ꦿ': 'ra',2000'ꦀ': '',2001'꦳': '',2002'꧀': '',2003'꧇': '',2004'꧁': '—',2005'꧂': '—',2006'꧃': '–',2007'꧄': '–',2008'꧅': '–',2009'꧆': '',2010'꧈': ',',2011'꧉': '.',2012'꧊': 'qqq',2013'꧋': '–',2014'꧌': '–',2015'꧍': '–',2016ꧏ: '²',2017'꧐': '0',2018'꧑': '1',2019'꧒': '2',2020'꧓': '3',2021'꧔': '4',2022'꧕': '5',2023'꧖': '6',2024'꧗': '7',2025'꧘': '8',2026'꧙': '9',2027'꧞': '—',2028'꧟': '—',2029// "": '#',//zero-width joiner2030'': ' ',2031' ': ' ' // regular space2032};2033}2034}2035//# sourceMappingURL=aksarajawa.js.map20362037