Path: blob/master/node_modules/@bochilteam/scraper/lib/cjs/texts/aksarajawa.js
1126 views
"use strict";1Object.defineProperty(exports, "__esModule", { value: true });2exports.aksaraToLatin = exports.latinToAksara = void 0;3function latinToAksara(str, options = { mode: 'ketik', space: true }) {4const aksara = new Aksara(str, options);5return aksara.toAksara();6}7exports.latinToAksara = latinToAksara;8function aksaraToLatin(str, options = { HVokal: false }) {9const aksara = new Aksara(str, options);10return aksara.toLatin();11}12exports.aksaraToLatin = aksaraToLatin;13// https://bennylin.github.io/transliterasijawa/14// https://jv.wikipedia.org/w/index.php?title=Panganggo:Bennylin/trans.js&action=raw&ctype=text/javascript15const SuperTrim = (str) => str.replace(/^\s*|\s*$/g, '').replace(/\s+/g, ' '); // trim string, menemukan karakter di dalam string16const findstr = (str, find) => {17for (let i = 0; i < str.length; i++)18if (str[i] == find)19return true;20return false;21};22const isDigit = (a) => findstr('0123456789', a);23const isPunct = (a) => findstr(',.><?/+=-_}{[]*&^%$#@!~`"\\|:;()', a);24const isVowel = (a) => findstr('AaĂăEeÈèÉéIiOoUuÊêĚěĔĕṚṛXxôâāīūōåɔə', a);25const isConsonant = (a) => findstr('BCDfGHJKLMNPQRSTVWYZbcdfghjklmnpqrstvwyzḌḍṆṇṢṣṬṭŊŋÑñɲś', a); // Xx are vowels (pepet)26const isSpecial = (a) => findstr('GgHhRrYyñn', a); // untuk bikonsonan th, dh, ng (nga dan cecak), ny, -r- (cakra), -y- (pengkal), jñ/jnya (ꦘ)27const isHR = (a) => findstr('HhRrŊŋ', a); // untuk layar dan wignyan dan cecak ([[:en:w:Engma]])28const isLW = (a) => findstr('LlWw', a); // untuk panjingan ("ng" dapat diikuti "g", "r"/cakra, "y"/pengkal, dan "w" atau "l"/panjingan)29const isCJ = (a) => findstr('CcJj', a); // untuk anuswara -nj- dan -nc-30const GetSpecialSound = (str) => {31const specialsoundMap = {32f: 'ꦥ꦳꧀',33v: 'ꦮ꦳꧀',34z: 'ꦗ꦳꧀',35ś: 'ꦯ꧀',36Q: '꧀',37q: '꧀' /* pangkon */38};39if (specialsoundMap[str] !== undefined)40return specialsoundMap[str];41return null;42};43class Aksara {44constructor(str, opts = { mode: 'ketik', space: true, HVokal: true }) {45this.opts = opts;46this.str = '';47this.str2 = '';48this.spasi = '';49this.str = str.toString();50this.angkaFlag = opts.number;51this.cecakFlag = opts.cecak;52this.diftong = opts.diftong;53this.modeSpasi = opts.space;54this.murda = opts.murda;55this.mode = opts.mode;56this.isHVokal = opts.HVokal;57}58toAksara() {59let i = 0;60let ret = '';61let pi = 0; // ?offset62const angka = {630: '꧐',641: '꧑',652: '꧒',663: '꧓',674: '꧔',685: '꧕',696: '꧖',707: '꧗',718: '꧘',729: '꧙'73};74this.str = SuperTrim(this.str);75while (i < this.str.length) {76if (i > 0 && isVowel(this.str[i]) && isVowel(this.str[i - 1])) {77// deal with words that start with multiple vocals78if ((this.str[i - 1] == 'a' && this.str[i] == 'a') ||79(this.str[i - 1] == 'i' && this.str[i] == 'i') ||80(this.str[i - 1] == 'u' && this.str[i] == 'u') ||81(this.str[i - 1] == 'a' && this.str[i] == 'i') ||82(this.str[i - 1] == 'a' && this.str[i] == 'u')) {83// specials84if (i == 1 || (i > 1 && !isConsonant(this.str[i - 2]))) {85// for example if starts with 'ai-'86this.str =87this.str.substring(0, i) +88'h' +89this.str.substring(i, this.str.length);90}91else {92// var modeDiftong = document.getElementsByName("diftong");93// for (var rad in modeDiftong) {94// if (modeDiftong[rad].checked)95// diftong = modeDiftong[rad].value;96// }97if (this.diftong) {98// do nothing, look in matramap table if(diftong == "tidak")99}100else {101this.str =102this.str.substring(0, i) +103'h' +104this.str.substring(i, this.str.length);105}106}107}108else if ((this.str[i - 1] == 'e' ||109this.str[i - 1] == 'è' ||110this.str[i - 1] == 'é') &&111(this.str[i] == 'a' || this.str[i] == 'o')) {112// -y-113this.str =114this.str.substring(0, i) +115'y' +116this.str.substring(i, this.str.length);117}118else if (this.str[i - 1] == 'i' &&119(this.str[i] == 'a' ||120this.str[i] == 'e' ||121this.str[i] == 'è' ||122this.str[i] == 'é' ||123this.str[i] == 'o' ||124this.str[i] == 'u')) {125// -y-126this.str =127this.str.substring(0, i) +128'y' +129this.str.substring(i, this.str.length);130}131else if (this.str[i - 1] == 'o' &&132(this.str[i] == 'a' ||133this.str[i] == 'e' ||134this.str[i] == 'è' ||135this.str[i] == 'é')) {136// -w-137this.str =138this.str.substring(0, i) +139'w' +140this.str.substring(i, this.str.length);141}142else if (this.str[i - 1] == 'u' &&143(this.str[i] == 'a' ||144this.str[i] == 'e' ||145this.str[i] == 'è' ||146this.str[i] == 'é' ||147this.str[i] == 'i' ||148this.str[i] == 'o')) {149// -y-150this.str =151this.str.substring(0, i) +152'w' +153this.str.substring(i, this.str.length);154}155else {156this.str =157this.str.substring(0, i) +158'h' +159this.str.substring(i, this.str.length);160}161}162if ((isSpecial(this.str[i]) || isLW(this.str[i]) || isCJ(this.str[i])) &&163!this.vowelFlag) {164// i++;165}166else if ((this.str[i] == 'h' && this.vowelFlag) ||167(!isVowel(this.str[i]) && i > 0) ||168this.str[i] == ' ' ||169isPunct(this.str[i]) ||170isDigit(this.str[i]) ||171i - pi > 5) {172if (!isDigit(this.str[i]) && this.angkaFlag) {173// turn off the flag174ret += '꧇'; // with zws175this.angkaFlag = false;176}177if (pi < i) {178if (this.cecakFlag &&179this.GetSound(this.str.substring(pi, i)) == 'ꦁ') {180this.cecakFlag = false;181ret += 'ꦔ꧀ꦔ';182}183else if (!this.cecakFlag &&184this.GetSound(this.str.substring(pi, i)) == 'ꦁ') {185this.cecakFlag = true;186ret += 'ꦁ';187}188else {189this.cecakFlag = false;190ret += this.GetSound(this.str.substring(pi, i));191}192}193if (this.str[i] == ' ') {194// var spasi, modeSpasi;195// var pakaiSpasi = document.getElementsByName("spasi");196// for (var rad in pakaiSpasi) {197// if (pakaiSpasi[rad].checked)198// modeSpasi = pakaiSpasi[rad].value;199// }200if (this.modeSpasi) {201// if space preceeded by open vowel, or layar/wignyan (therefore, no pangkon/virama)202if (i > 0 &&203['a', 'e', 'i', 'o', 'u', 'r', 'h', 'ě'].indexOf(this.str[i - 1]) >= 0) {204this.spasi = ''; // zero-width space205}206else {207this.spasi = '';208}209}210else {211// if(mode == "with")212this.spasi = ''; // zero-width space213// spasi = ' '; }//hair space http://en.wikipedia.org/wiki/Space_(punctuation)#Spaces_in_Unicode214}215ret += this.spasi;216}217if (isPunct(this.str[i])) {218if (this.str[i] == '.') {219ret += '꧉'; // titik+zero-width space220pi = i + 1;221}222else if (this.str[i] == ',') {223ret += '꧈'; // koma+zero-width space224pi = i + 1;225}226else if (this.str[i] == ':') {227ret += '꧇'; // titik dua+zero-width space228pi = i + 1;229}230else if (this.str[i] == '|') {231ret += '꧋';232pi = i + 1;233/* comment out, not really a good way to do brackets234} else if (str[i] == '(') {235ret += "꧌"; pi = i + 1;236} else if (str[i] == ')') {237ret += "꧍"; pi = i + 1;// with zws238*/239}240else if (this.str[i] == '-') {241// tanda hubung242ret += '';243pi = i + 1;244}245else if (this.str[i] == '?' ||246this.str[i] == '!' ||247this.str[i] == '"' ||248this.str[i] == "'") {249// tanda tanya/seru/petik250ret += ''; // zero-width space251pi = i + 1;252}253else {254ret += this.str[i];255pi = i + 1;256}257}258else if (isDigit(this.str[i])) {259if (!this.angkaFlag)260ret += '꧇';261ret += angka[this.str[i]];262this.angkaFlag = true;263pi = i + 1;264}265else {266pi = i;267}268this.vowelFlag = false;269}270else if (isVowel(this.str[i]) && this.str[i] != 'h') {271if (!isDigit(this.str[i]) && this.angkaFlag) {272// turn off the flag273ret += '꧇'; // with zws274this.angkaFlag = false;275}276this.vowelFlag = true;277}278if (pi > 0 && isVowel(this.str[pi - 1])) {279// <vowel>ngg280this.vowelPrev = true;281}282else283this.vowelPrev = false;284/* not working285if (pi > 0 && findstr(" ",str[pi-1])) {//<vowel>ngg286spacePrev = true;287}288else spacePrev = false; */289i++;290} // endwhile291if (pi < i) {292ret += this.GetSound(this.str.substring(pi, i));293}294return SuperTrim(ret).toString();295}296GetMatra(str) {297let i = 0;298if (str.length < 1) {299return '꧀';300}301while (str[i] == 'h') {302i++;303if (i >= str.length) {304break;305}306}307if (i < str.length) {308str = str.substring(i);309}310const matramap1 = { e: 'ꦺ', E: 'ꦌ' }; // mode ketik311const matramap2 = { e: 'ꦼ', E: 'ꦄꦼ' }; // mode kopas312const matramap3 = {313// both mode ketik and kopas314ā: 'ꦴ',315â: 'ꦴ',316aa: 'ꦴ',317è: 'ꦺ',318é: 'ꦺ',319i: 'ꦶ',320ī: 'ꦷ',321ii: 'ꦷ',322o: 'ꦺꦴ',323ō: 'ꦼꦴ',324u: 'ꦸ',325ū: 'ꦹ',326uu: 'ꦹ',327x: 'ꦼ',328ě: 'ꦼ',329ĕ: 'ꦼ',330ê: 'ꦼ',331ə: 'ꦼ',332ô: '',333ă: '',334å: '',335ɔ: '',336A: 'ꦄ',337Ă: 'ꦄ',338È: 'ꦌ',339É: 'ꦌ',340I: 'ꦆ',341O: 'ꦎ',342U: 'ꦈ',343X: 'ꦄꦼ',344Ě: 'ꦄꦼ',345Ĕ: 'ꦄꦼ',346Ê: 'ꦄꦼ',347ṛ: 'ꦽ',348Ṛ: 'ꦽ',349ai: 'ꦻ',350au: 'ꦻꦴ'351};352// var matramap, mode;353// var modeTranslit = document.getElementsByName("mode");354// for (var rad in modeTranslit) {355// if (modeTranslit[rad].checked)356// mode = modeTranslit[rad].value;357// }358if (this.mode == 'kopas')359var matramap = { ...matramap2, ...matramap3 };360// if(mode == "ketik")361else362var matramap = { ...matramap1, ...matramap3 };363if (matramap[str] !== undefined) {364return matramap[str];365}366return '';367}368GetShift(str1) {369const str = str1.toLowerCase(); // case insensitive370// var modeMurda = document.getElementsByName("murda");371// for (var rad in modeMurda) {372// if (modeMurda[rad].checked)373// murda = modeMurda[rad].value;374// }375if (this.murda)376this.str2 = str1;377// case sensitive (particularly the 8 characters of ꦛ ꦜ ꦝ ꦞ ꦠ ꦡ ꦢ ꦣ),378// for combination of murda and cakra/pengkal/panjingan379// if(murda == "tidak")380else381this.str2 = str1.toLowerCase(); // case insensitive382// V.1. 2nd letter of the consonant cluster is 'h'383if (this.str2.indexOf('th') == 0) {384// suku kata diawali 'th'385if (this.str2.indexOf('thl') == 0) {386// thl-387return { CoreSound: 'ꦛ꧀ꦭ', len: 3 };388}389else if (this.str2.indexOf('thr') == 0) {390// thr-391return { CoreSound: 'ꦛꦿ', len: 3 };392}393else if (this.str2.indexOf('thw') == 0) {394// thw-395return { CoreSound: 'ꦛ꧀ꦮ', len: 3 };396}397else if (this.str2.indexOf('thy') == 0) {398// thy-399return { CoreSound: 'ꦛꦾ', len: 3 };400}401else {402return { CoreSound: 'ꦛ', len: 2 }; // tha403}404}405else if (this.str2.indexOf('dh') == 0) {406// suku kata diawali 'dh'407if (this.str2.indexOf('dhl') == 0) {408// dhl-409return { CoreSound: 'ꦝ꧀ꦭ', len: 3 };410}411else if (this.str2.indexOf('dhr') == 0) {412// dhr-413return { CoreSound: 'ꦝꦿ', len: 3 };414}415else if (this.str2.indexOf('dhw') == 0) {416// dhw-: dhwani417return { CoreSound: 'ꦝ꧀ꦮ', len: 3 };418}419else if (this.str2.indexOf('dhy') == 0) {420// dhy-: dhyaksa421return { CoreSound: 'ꦝꦾ', len: 3 };422}423else {424return { CoreSound: 'ꦝ', len: 2 }; // dha425}426}427else if (this.str2.indexOf('Th') == 0) {428// suku kata diawali 'Th'429if (this.str2.indexOf('Thl') == 0) {430// Thl-431return { CoreSound: 'ꦜ꧀ꦭ', len: 3 };432}433else if (this.str2.indexOf('Thr') == 0) {434// Thr-435return { CoreSound: 'ꦜꦿ', len: 3 };436}437else if (this.str2.indexOf('Thw') == 0) {438// Thw-439return { CoreSound: 'ꦜ꧀ꦮ', len: 3 };440}441else if (this.str2.indexOf('Thy') == 0) {442// Thy-443return { CoreSound: 'ꦜꦾ', len: 3 };444}445else {446return { CoreSound: 'ꦜ', len: 2 }; // Tha Mahaprana447}448}449else if (this.str2.indexOf('Dh') == 0) {450// suku kata diawali 'Dh'451if (this.str2.indexOf('Dhl') == 0) {452// Dhl-453return { CoreSound: 'ꦞ꧀ꦭ', len: 3 };454}455else if (this.str2.indexOf('Dhr') == 0) {456// Dhr-457return { CoreSound: 'ꦞꦿ', len: 3 };458}459else if (this.str2.indexOf('Dhw') == 0) {460// Dhw-: Dhwani461return { CoreSound: 'ꦞ꧀ꦮ', len: 3 };462}463else if (this.str2.indexOf('Dhy') == 0) {464// Dhy-: Dhyaksa465return { CoreSound: 'ꦞꦾ', len: 3 };466}467else {468return { CoreSound: 'ꦞ', len: 2 }; // Dha Mahaprana469}470/* murda block start */471}472else if (str.indexOf('ṭh') == 0) {473// ṭh (aksara murda: tha mahaprana)474if (str.indexOf('ṭhy') == 0) {475return { CoreSound: 'ꦜꦾ', len: 2 };476}477else if (str.indexOf('ṭhr') == 0) {478return { CoreSound: 'ꦜꦿ', len: 2 };479}480else481return { CoreSound: 'ꦜ', len: 2 };482}483else if (str.indexOf('ḍh') == 0) {484// ḍh (aksara murda: dha mahaprana)485if (str.indexOf('ḍhy') == 0) {486return { CoreSound: 'ꦞꦾ', len: 2 };487}488else if (str.indexOf('ḍhr') == 0) {489return { CoreSound: 'ꦞꦿ', len: 2 };490}491else492return { CoreSound: 'ꦞ', len: 2 };493}494else if (str.indexOf('kh') == 0) {495// kh (aksara murda: ka murda)496if (str.indexOf('khl') == 0) {497// ka murda + panjingan la498return { CoreSound: 'ꦑ꧀ꦭ', len: 3 };499}500else if (str.indexOf('khr') == 0) {501// ka murda + cakra502return { CoreSound: 'ꦑꦿ', len: 3 };503}504else if (str.indexOf('khw') == 0) {505// ka murda + panjingan wa506return { CoreSound: 'ꦑ꧀ꦮ', len: 3 };507}508else if (str.indexOf('khy') == 0) {509// ka murda + wignyan510return { CoreSound: 'ꦑꦾ', len: 3 };511}512else {513return { CoreSound: 'ꦑ', len: 2 };514}515}516else if (str.indexOf('gh') == 0) {517// gh (aksara murda: ga murda)518if (str.indexOf('ghl') == 0) {519// ga murda + panjingan la520return { CoreSound: 'ꦓ꧀ꦭ', len: 3 };521}522else if (str.indexOf('ghw') == 0) {523// ga murda + panjingan wa524return { CoreSound: 'ꦓ꧀ꦮ', len: 3 };525}526else if (str.indexOf('ghr') == 0) {527// ga murda + cakra528return { CoreSound: 'ꦓꦿ', len: 3 };529}530else if (str.indexOf('ghy') == 0) {531// ga murda + wignyan532return { CoreSound: 'ꦓꦾ', len: 3 };533}534else {535return { CoreSound: 'ꦓ', len: 2 };536}537}538else if (str.indexOf('ch') == 0) {539// ch (aksara murda: ca murda)540if (str.indexOf('chl') == 0) {541// ca murda + panjingan la542return { CoreSound: 'ꦖ꧀ꦭ', len: 3 };543}544else if (str.indexOf('chr') == 0) {545// ca murda + cakra546return { CoreSound: 'ꦖꦿ', len: 3 };547}548else if (str.indexOf('chw') == 0) {549// ca murda + panjingan wa550return { CoreSound: 'ꦖ꧀ꦮ', len: 3 };551}552else if (str.indexOf('chy') == 0) {553// ca murda + wignyan554return { CoreSound: 'ꦖꦾ', len: 3 };555}556else {557return { CoreSound: 'ꦖ', len: 2 };558}559}560else if (str.indexOf('jh') == 0) {561// jh (aksara murda: ja mahaprana)562if (str.indexOf('jhl') == 0) {563// ja mahaprana + panjingan la564return { CoreSound: 'ꦙ꧀ꦭ', len: 3 }; // with zws, otherwise the panjingan is overlapped565}566else if (str.indexOf('jhr') == 0) {567// ja mahaprana + cakra568return { CoreSound: 'ꦙꦿ', len: 3 };569}570else if (str.indexOf('jhw') == 0) {571// ja mahaprana + panjingan wa572return { CoreSound: 'ꦙ꧀ꦮ', len: 3 };573}574else if (str.indexOf('jhy') == 0) {575// ja mahaprana + wignyan576return { CoreSound: 'ꦙꦾ', len: 3 };577}578else {579return { CoreSound: 'ꦙ', len: 2 };580}581}582else if (str.indexOf('ph') == 0) {583// ph (aksara murda: pa murda)584if (str.indexOf('phl') == 0) {585// pa murda + panjingan la586return { CoreSound: 'ꦦ꧀ꦭ', len: 3 };587}588else if (str.indexOf('phr') == 0) {589// pa murda + cakra590return { CoreSound: 'ꦦꦿ', len: 3 };591}592else if (str.indexOf('phw') == 0) {593// pa murda + panjingan wa594return { CoreSound: 'ꦦ꧀ꦮ', len: 3 };595}596else if (str.indexOf('phy') == 0) {597// pa murda + wignyan598return { CoreSound: 'ꦦꦾ', len: 3 };599}600else {601return { CoreSound: 'ꦦ', len: 2 };602}603}604else if (str.indexOf('bh') == 0) {605// bh (aksara murda: ba murda)606if (str.indexOf('bhl') == 0) {607// ba murda + panjingan la608return { CoreSound: 'ꦨ꧀ꦭ', len: 3 };609}610else if (str.indexOf('bhr') == 0) {611// ba murda + cakra612return { CoreSound: 'ꦨꦿ', len: 3 };613}614else if (str.indexOf('bhw') == 0) {615// ba murda + panjingan wa616return { CoreSound: 'ꦨ꧀ꦮ', len: 3 };617}618else if (str.indexOf('bhy') == 0) {619// ba murda + wignyan620return { CoreSound: 'ꦨꦾ', len: 3 };621}622else {623return { CoreSound: 'ꦨ', len: 2 };624}625}626else if (str.indexOf('sh') == 0) {627// sh (aksara murda: sa murda)628if (str.indexOf('shl') == 0) {629// sa murda + panjingan la630return { CoreSound: 'ꦯ꧀ꦭ', len: 3 };631}632else if (str.indexOf('shr') == 0) {633// sa murda + cakra634return { CoreSound: 'ꦯꦿ', len: 3 };635}636else if (str.indexOf('shw') == 0) {637// sa murda + panjingan wa638return { CoreSound: 'ꦯ꧀ꦮ', len: 3 };639}640else if (str.indexOf('shy') == 0) {641// sa murda + wignyan642return { CoreSound: 'ꦯꦾ', len: 3 };643}644else {645return { CoreSound: 'ꦯ', len: 2 };646}647/* murda block end */648// Uncatched exception: -h followed by hy, hr, hl, hw649}650else if (str.indexOf('hh') == 0) {651// wignyan + ha, e.g. root word ends with 'h' with suffix -i652return { CoreSound: 'ꦃꦲ', len: 2 };653// Uncatched exception: -r followed by hy, hr, hl, hw654}655else if (str.indexOf('rh') == 0) {656// layar + ha657return { CoreSound: 'ꦂꦲ', len: 2 };658}659else if (str.indexOf('h') == 1) {660// h (h di posisi karakter kedua)661return {662CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦲ',663len: 2664};665}666// V.2. 2nd letter is 'g'667if (str.indexOf('ng') == 0) {668// suku kata diawali 'ng'669// Uncatched exception: -ng followed by ry, rw, rl670if (str.indexOf('ngr') == 0) {671// cakra (for cecak + ra, separate by a space)672return { CoreSound: '' + 'ꦔꦿ', len: 3 };673}674else if (str.indexOf('ngy') == 0) {675// pengkal (for cecak + ya, separate by a space)676return { CoreSound: '' + 'ꦔꦾ', len: 3 };677// Uncatched exception: -ng followed by hy, hr, hl678}679else if (str.indexOf('nghw') == 0) {680// tyonghwa681return { CoreSound: '' + 'ꦁꦲ꧀ꦮ', len: 4 };682}683else if (str.indexOf('ngg') == 0) {684// cecak + ga685if (str.indexOf('nggr') == 0) {686// nggronjal687return { CoreSound: 'ꦔ꧀ꦒꦿ', len: 4 };688}689else if (str.indexOf('nggl') == 0) {690// nggl-691return { CoreSound: 'ꦔ꧀ꦒ꧀ꦭ', len: 4 };692}693else if (str.indexOf('nggw') == 0) {694// nggw-, munggwing695return { CoreSound: 'ꦔ꧀ꦒ꧀ꦮ', len: 4 };696}697else if (str.indexOf('nggy') == 0) {698// nggy-, anggyat699return { CoreSound: 'ꦔ꧀ꦒꦾ', len: 4 };700}701else {702return { CoreSound: 'ꦔ꧀ꦒ', len: 3 };703}704}705else if (str.indexOf('ngn') == 0) {706// cecak + na707// Uncatched exception: -ng followed by ngy, ngr, ngl, ngw708if (str.indexOf('ngng') == 0) {709// ngng710return { CoreSound: 'ꦁꦔ', len: 4 };711}712else {713return { CoreSound: 'ꦁꦤ', len: 3 };714}715}716else if (str.indexOf('ngh') == 0) {717// cecak + ha718return { CoreSound: 'ꦁꦲ', len: 3 };719}720else if (str.indexOf('ngc') == 0) {721// cecak + ca722return { CoreSound: 'ꦁꦕ', len: 3 };723}724else if (str.indexOf('ngj') == 0) {725// cecak + ja726return { CoreSound: 'ꦁꦗ', len: 3 };727}728else if (str.indexOf('ngl') == 0) {729// ngl, e.g. ngluwari730return { CoreSound: 'ꦔ꧀ꦭ', len: 3 };731}732else if (str.indexOf('ngw') == 0) {733// ngw, e.g. ngwiru734return { CoreSound: 'ꦔ꧀ꦮ', len: 3 };735}736else {737return { CoreSound: 'ꦁ', len: 2 }; // cecak, with zws738}739}740else if (str.indexOf('gg') == 0) {741// 'gg', e.g. root word ends with 'g' with suffix -i742return { CoreSound: 'ꦒ꧀ꦒ', len: 2 };743}744else if (str.indexOf('hg') == 0) {745// wignyan + ga, e.g. dahgene746return { CoreSound: 'ꦃꦒ', len: 2 };747}748else if (str.indexOf('rg') == 0) {749// layar + ga, e.g. amarga750return { CoreSound: 'ꦂꦒ', len: 2 };751}752else if (str.indexOf('g') == 1) {753// g (g di posisi karakter kedua)754return {755CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦒ',756len: 2757};758}759// V.3. 2nd letter is 'y'760if (str.indexOf('ny') == 0) {761// suku kata diawali 'ny'762if (str.indexOf('nyr') == 0) {763// cakra764return { CoreSound: 'ꦚꦿ', len: 3 }; /*765} else if (str.indexOf("nyy") == 0) { //nyy, I don't think it's possible766return { "CoreSound": "ꦚꦾ", "len": 3 }; */767}768else if (str.indexOf('nyl') == 0) {769// nyl, e.g. nylonong770return { CoreSound: 'ꦚ꧀ꦭ', len: 3 };771}772else if (str.indexOf('nyw') == 0) {773// nyw774return { CoreSound: 'ꦚ꧀ꦮ', len: 3 }; /*775} else if (str2.indexOf("Ny") == 0) { //Na murda + pengkal, unlikely combination?776return { "CoreSound": "ꦟꦾ", "len": 2 }; */777}778else {779return { CoreSound: 'ꦚ', len: 2 };780}781}782else if (str.indexOf('hy') == 0) {783// wignyan + ya / ha + pengkal -- hyang784return { CoreSound: 'ꦲꦾ', len: 2 };785}786else if (this.str2.indexOf('ry') == 0) {787// layar + ya, e.g. Suryati, Wiryadi788if (str.indexOf('ryy') == 0) {789return { CoreSound: 'ꦂꦪꦾ', len: 3 }; // 'ryy', e.g. Duryyodhana (Jawa Kuno)790}791else {792return { CoreSound: 'ꦂꦪ', len: 2 };793} /*794} else if (str.indexOf("yy") == 0) { //'yy', I don't think it's possible795return { "CoreSound": "ꦪꦾ", "len": 2 }; */796}797else if (this.str2.indexOf('qy') == 0) {798// qy -- only pengkal799return { CoreSound: 'ꦾ', len: 1 };800}801else if (str.indexOf('y') == 1) {802// pengkal (y di posisi karakter kedua)803return {804CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + 'ꦾ',805len: 2806};807}808// V.4. 2nd letter is 'r'809// Uncatched exception: -h followed by ry, rw, rl810if (str.indexOf('hr') == 0) {811// wignyan + ra / ha + cakra812return { CoreSound: 'ꦲꦿ', len: 2 };813}814else if (str.indexOf('wr') == 0) {815// wr -- panjingan + cakra816return { CoreSound: '' + 'ꦮꦿ', len: 2 };817// Uncatched exception: -r followed by ry, rw, rl818}819else if (str.indexOf('rr') == 0) {820// layar + ra (no cakra)821return { CoreSound: 'ꦂꦫ', len: 2 };822}823else if (this.str2.indexOf('qr') == 0) {824// qr -- only pasangan ra825return { CoreSound: '꧀ꦫ', len: 1 };826}827else if (this.str2.indexOf('qR') == 0) {828// qR -- only cakra829return { CoreSound: 'ꦿ', len: 1 };830}831else if (str.indexOf('r') == 1) {832// cakra (r di posisi karakter kedua)833return {834CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + 'ꦿ',835len: 2836};837}838// V.5. 2nd letter is 'l' or 'w'839// panjingan -l840if (str.indexOf('hl') == 0) {841// wignyan + la842return { CoreSound: 'ꦃꦭ', len: 2 };843}844else if (str.indexOf('rl') == 0) {845// layar + la846return { CoreSound: 'ꦂꦭ', len: 2 };847}848else if (str.indexOf('ll') == 0) {849// ll850return { CoreSound: 'ꦭ꧀ꦭ', len: 2 };851}852else if (str.indexOf('ql') == 0) {853// only panjingan854return { CoreSound: '꧀ꦭ', len: 2 };855}856else if (str.indexOf('l') == 1) {857// (l di posisi karakter kedua)858return {859CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦭ',860len: 2861};862}863// panjingan -w864if (str.indexOf('hw') == 0) {865// wignyan + ha866return { CoreSound: 'ꦃꦮ', len: 2 }; // ꦲ꧀ꦮ867}868else if (str.indexOf('rw') == 0) {869// layar + ha870return { CoreSound: 'ꦂꦮ', len: 2 }; // error untuk 'rwi', 'rwab'871}872else if (str.indexOf('ww') == 0) {873// ww (wwang, pûrwwa) - terima kasih Mas Revo874return { CoreSound: 'ꦮ꧀ꦮ', len: 2 };875}876else if (str.indexOf('qw') == 0) {877// only panjingan878return { CoreSound: '꧀ꦮ', len: 2 };879}880else if (str.indexOf('w') == 1) {881// (w di posisi karakter kedua)882return {883CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦮ',884len: 2885};886}887// V.6. 2nd letter is 'c' or 'j'888if (str.indexOf('nc') == 0) {889// nc890if (str.indexOf('ncr') == 0) {891// ncr -- kencrung892return { CoreSound: 'ꦚ꧀ꦕꦿ', len: 3 };893}894else if (str.indexOf('ncl') == 0) {895// ncl -- kinclong896return { CoreSound: 'ꦚ꧀ꦕ꧀ꦭ', len: 3 };897}898else {899return { CoreSound: 'ꦚ꧀ꦕ', len: 2 };900}901}902else if (str.indexOf('hc') == 0) {903// wignyan + ca904return { CoreSound: 'ꦃꦕ', len: 2 };905}906else if (str.indexOf('rc') == 0) {907// layar + ca -- arca908return { CoreSound: 'ꦂꦕ', len: 2 };909}910else if (str.indexOf('cc') == 0) {911// cc -- impossible combination in real text912return { CoreSound: 'ꦕ꧀ꦕ', len: 2 };913}914else if (this.str2.indexOf('qc') == 0) {915// only pasangan ca916return { CoreSound: '꧀ꦕ', len: 2 };917}918else if (str.indexOf('c') == 1) {919// c920return {921CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦕ',922len: 2923};924}925if (str.indexOf('nj') == 0) {926// nj927if (str.indexOf('njr') == 0) {928// njr -- anjrit929return { CoreSound: 'ꦚ꧀ꦗꦿ', len: 3 };930}931else if (str.indexOf('njl') == 0) {932// njl -- anjlog933return { CoreSound: 'ꦚ꧀ꦗ꧀ꦭ', len: 3 };934}935else {936return { CoreSound: 'ꦚ꧀ꦗ', len: 2 };937}938}939else if (str.indexOf('hj') == 0) {940// wignyan + ja941return { CoreSound: 'ꦃꦗ', len: 2 };942}943else if (str.indexOf('rj') == 0) {944// layar + ja945return { CoreSound: 'ꦂꦗ', len: 2 };946}947else if (str.indexOf('jj') == 0) {948// jj -- impossible combination in real text949return { CoreSound: 'ꦗ꧀ꦗ', len: 2 };950}951else if (this.str2.indexOf('qj') == 0) {952// only pasangan ja953return { CoreSound: '꧀ꦗ', len: 2 };954}955else if (str.indexOf('j') == 1) {956// j957return {958CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦗ',959len: 2960};961}962// V.7. 2nd letter is 'ñ' or 'n'963if (str.indexOf('jñ') == 0) {964// suku kata diawali 'jñ'965if (str.indexOf('jñl') == 0) {966// suku kata diawali 'jñ' - nya murda967return { CoreSound: 'ꦘ꧀ꦭ', len: 3 };968}969else if (str.indexOf('jñr') == 0) {970// nya murda + cakra971return { CoreSound: 'ꦘꦿ', len: 3 };972}973else if (str.indexOf('jñw') == 0) {974// nya murda + panjingan wa975return { CoreSound: 'ꦘ꧀ꦮ', len: 3 };976}977else if (str.indexOf('jñy') == 0) {978// nya murda + wignyan979return { CoreSound: 'ꦘꦾ', len: 3 };980}981else {982return { CoreSound: 'ꦘ', len: 2 };983}984}985else if (str.indexOf('jn') == 0) {986// suku kata diawali 'jn'987if (str.indexOf('jny') == 0) {988// suku kata diawali 'jny' - nya murda989if (str.indexOf('jnyl') == 0) {990// suku kata diawali 'jny' - nya murda991return { CoreSound: 'ꦘ꧀ꦭ', len: 4 };992}993else if (str.indexOf('jnyr') == 0) {994// nya murda + cakra995return { CoreSound: 'ꦘꦿ', len: 4 };996}997else if (str.indexOf('jnyw') == 0) {998// nya murda + panjingan wa999return { CoreSound: 'ꦘ꧀ꦮ', len: 4 };1000}1001else if (str.indexOf('jnyy') == 0) {1002// nya murda + wignyan1003return { CoreSound: 'ꦘꦾ', len: 4 };1004}1005else {1006return { CoreSound: 'ꦘ', len: 3 };1007}1008}1009else {1010return { CoreSound: 'ꦗ꧀ꦤ', len: 2 };1011}1012// Uncatched exception: -h followed by ngy, ngr, ngl, ngw1013}1014else if (str.indexOf('hn') == 0) {1015// wignyan + na1016return { CoreSound: 'ꦃꦤ', len: 2 };1017// Uncatched exception: -r followed by ngy, ngr, ngl, ngw1018}1019else if (str.indexOf('rn') == 0) {1020// layar + na1021return { CoreSound: 'ꦂꦤ', len: 2 };1022}1023else if (str.indexOf('nn') == 0) {1024// nn, e.g. root word ends with 'n' with suffix -i1025if (str.indexOf('nng') == 0) {1026//1027return { CoreSound: 'ꦤ꧀ꦁ', len: 3 };1028}1029else if (str.indexOf('nng') == 0) {1030//1031return { CoreSound: 'ꦤ꧀ꦚ꧀', len: 3 };1032}1033else {1034return { CoreSound: 'ꦤ꧀ꦤ', len: 2 };1035}1036}1037else if (this.str2.indexOf('qn') == 0) {1038// only pasangan na1039return { CoreSound: '꧀ꦤ', len: 2 };1040}1041else if (str.indexOf('ñ') == 1) {1042// huruf asing sih sebenarnya, kemungkinan kecil muncul1043return {1044CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦚ',1045len: 21046};1047}1048else if (str.indexOf('n') == 1) {1049//1050return {1051CoreSound: '' + this.GetCoreSound(this.str2[0]).CoreSound + '꧀ꦤ',1052len: 21053};1054}1055// suku kata memiliki konsonan tersebut yang tidak di posisi kedua1056if (str.indexOf('h') > 1 ||1057str.indexOf('g') > 1 ||1058str.indexOf('y') > 1 ||1059str.indexOf('r') > 1 ||1060str.indexOf('l') > 1 ||1061str.indexOf('w') > 1 ||1062str.indexOf('c') > 1 ||1063str.indexOf('j') > 1 ||1064str.indexOf('n') > 1 ||1065str.indexOf('ñ') > 1) {1066let sound = '';1067let len = 0;1068let index = 0;1069for (index = 0; index < str.length; index++) {1070const c = str[index];1071if (!isVowel(c)) {1072sound += this.ResolveCharacterSound(c);1073len++;1074}1075else {1076break;1077}1078}1079return { CoreSound: sound, len: len };1080}1081return { CoreSound: null, len: 1 };1082}1083GetCoreSound(str) {1084const soundMap1 = {1085// 26 uppercase for non-Murda, largely mirror lowercase, except AEIOU, and HR1086A: 'ꦄ',1087B: 'ꦧ',1088C: 'ꦕ',1089D: 'ꦢ',1090E: 'ꦌ',1091F: 'ꦥ꦳',1092G: 'ꦒ',1093H: 'ꦲ',1094I: 'ꦆ',1095J: 'ꦗ',1096K: 'ꦏ',1097L: 'ꦭ',1098M: 'ꦩ',1099N: 'ꦤ',1100O: 'ꦎ',1101P: 'ꦥ',1102Q: '꧀',1103R: 'ꦫ',1104S: 'ꦱ',1105T: 'ꦠ',1106U: 'ꦈ',1107V: 'ꦮ꦳',1108W: 'ꦮ',1109X: 'ꦼ',1110Y: 'ꦪ',1111Z: 'ꦰ' // Sa Mahaprana1112// test: ABaCaDaEFaGaHaJaKaLaMaNaOPaRaSaTaUVaWaXYaZa1113};1114const soundMap2 = {1115// 26 uppercase for Murda (notice for J, Q, R, and Z)1116A: 'ꦄ',1117B: 'ꦨ',1118C: 'ꦖ',1119D: 'ꦣ',1120E: 'ꦌ',1121F: 'ꦦ꦳',1122G: 'ꦓ',1123H: 'ꦲ꦳',1124I: 'ꦆ',1125J: 'ꦙ',1126K: 'ꦑ',1127L: 'ꦭ',1128M: 'ꦩ',1129N: 'ꦟ',1130O: 'ꦎ',1131P: 'ꦦ',1132Q: 'ꦐ',1133R: 'ꦬ',1134S: 'ꦯ',1135T: 'ꦡ',1136U: 'ꦈ',1137V: 'ꦮ꦳',1138W: 'ꦮ',1139X: 'ꦼ',1140Y: 'ꦪ',1141Z: 'ꦰ' // Sa mahaprana1142// test: ABaCaDaEFaGaHaJaKaLaMaNaOPaQaRaSaTaUVaWaXaYaZa1143};1144const soundMap3 = {1145// 26 lowercase + 35 special, same for both Murda or non-Murda1146a: 'ꦲ',1147b: 'ꦧ',1148c: 'ꦕ',1149d: 'ꦢ',1150e: 'ꦲꦺ',1151f: 'ꦥ꦳',1152g: 'ꦒ',1153h: 'ꦃ',1154i: 'ꦲꦶ',1155j: 'ꦗ',1156k: 'ꦏ',1157l: 'ꦭ',1158m: 'ꦩ',1159n: 'ꦤ',1160o: 'ꦲꦺꦴ',1161p: 'ꦥ',1162q: '꧀',1163r: 'ꦂ',1164s: 'ꦱ',1165t: 'ꦠ',1166u: 'ꦲꦸ',1167v: 'ꦮ꦳',1168w: 'ꦮ',1169x: 'ꦲꦼ',1170y: 'ꦪ',1171z: 'ꦗ꦳',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ṭ: 'ꦛ',1202ś: 'ꦯ',1203Ṣ: 'ꦰ',1204ṣ: 'ꦰ',1205Ṛ: 'ꦽ',1206ṛ: 'ꦽ' // idem1207// test: Èè.Éé.Êê.Ěě.Ĕĕ.Ṛṛ.ôâāīūōåɔə1208// test: ḌaḍaṆaṇaṢaṣaṬaṭaŊaŋaÑañaɲaśa1209};1210let soundMap;1211// var modeMurda = document.getElementsByName("murda");1212// for (var rad in modeMurda) {1213// if (modeMurda[rad].checked)1214// murda = modeMurda[rad].value;1215// }1216if (this.murda)1217soundMap = { ...soundMap2, ...soundMap3 };1218// if(murda == "tidak")1219else1220soundMap = { ...soundMap1, ...soundMap3 };1221const h_shift = this.GetShift(str);1222let core = str;1223if (h_shift.CoreSound == null) {1224if (soundMap[str.charAt(0)])1225core = soundMap[str.charAt(0)];1226return {1227CoreSound: core,1228len: 11229};1230}1231else {1232return h_shift;1233}1234}1235ResolveCharacterSound(c) {1236const str = c.toString();1237if (isDigit(c)) {1238return '' + ('꧇' + (parseInt(c) - 0));1239}1240else if (isHR(str[0])) {1241return '' + this.GetCoreSound(str).CoreSound; // layar dan wignyan1242}1243else if (isCJ(str[1])) {1244return '' + this.GetCoreSound(str).CoreSound + '꧀'; // anuswara1245}1246else if (isConsonant(str[0])) {1247return '' + this.GetCoreSound(str).CoreSound + '꧀';1248}1249else {1250// if (isVowel(str[0])) {1251return '' + this.GetCoreSound(str).CoreSound;1252}1253}1254GetSound(str) {1255str = SuperTrim(str);1256this.str2 = str.toLowerCase();1257if (str == null || str == '')1258return '';1259const SpecialSound = GetSpecialSound(str);1260if (SpecialSound != null && str.length == 1)1261return SpecialSound;1262if (str.length == 1)1263return this.ResolveCharacterSound(str[0]);1264else {1265const core_sound = this.GetCoreSound(str);1266// return "1"+core_sound.CoreSound+"2";1267let matra = '';1268let konsonan = '';1269if (core_sound.len >= 1) {1270matra = this.GetMatra(str.substring(core_sound.len)); // xeiou (pepet, taling, suku, taling tarung, wulu, dll.)1271/* if () {12721273} else {12741275} */1276}1277else {1278matra = '';1279} // a/å/ɔ1280/* rules for some cluster like ngg- that have different behaviour depending if it's the start of a word or not.1281TODO: find more elegant solution */1282if (this.str2.indexOf('nggr') == 0) {1283// nggr-1284if (this.vowelPrev)1285konsonan = 'ꦁꦒꦿ';1286// <vowel>nggr-, e.g. panggrahita1287// else if (matra = "")1288else1289konsonan = 'ꦔ꧀ꦒꦿ'; // <nonvowel>nggr-, i.e. nggronjal1290}1291else if (this.str2.indexOf('nggl') == 0) {1292// nggl-, e.g. ngglantung1293konsonan = 'ꦔ꧀ꦒ꧀ꦭ';1294}1295else if (this.str2.indexOf('nggw') == 0) {1296// nggw-, e.g. munggwing1297konsonan = 'ꦔ꧀ꦒ꧀ꦮ';1298}1299else if (this.str2.indexOf('nggy') == 0) {1300// nggy-, e.g. anggyat1301konsonan = 'ꦔ꧀ꦒꦾ';1302}1303else if (this.str2.indexOf('ngg') == 0) {1304// ngg-1305if (this.vowelPrev)1306konsonan = 'ꦁꦒ';1307// <vowel>ngg-, e.g. tunggal1308// else if (spacePrev) konsonan = "ꦔ꧀";//<space>ngg-, e.g. ditinggal nggambar (it has a zws)1309else1310konsonan = 'ꦔ꧀ꦒ'; // <nonvowel>ngg-, i.e. nggambar1311// for cluster longer than 4 consonants, such as "ditinggalnggambar",1312// need to separate it by a space, "ditinggal nggambar" to be correct1313}1314else if (this.str2.indexOf('rlx') == 0) {1315// r lx, e.g. pasarlxgi1316konsonan = 'ꦂꦊ';1317matra = '';1318}1319else if (this.str2.indexOf('rrx') == 0) {1320// r rx1321konsonan = 'ꦂꦉ';1322matra = '';1323}1324else if (this.str2.indexOf('hlx') == 0) {1325// h lx1326if (this.vowelPrev) {1327konsonan = 'ꦃꦊ';1328matra = '';1329}1330else1331konsonan = 'ꦲ꧀ꦭꦼ';1332matra = '';1333}1334else if (this.str2.indexOf('hrx') == 0) {1335// h rx1336if (this.vowelPrev) {1337konsonan = 'ꦃꦉ';1338matra = '';1339}1340else1341konsonan = 'ꦲꦽ';1342matra = '';1343}1344else if (this.str2.indexOf('qlx') == 0) {1345// just pasangan la + pepet1346konsonan = '꧀ꦭꦼ';1347matra = '';1348}1349else if (this.str2.indexOf('qrx') == 0) {1350// just cakra keret1351konsonan = 'ꦽ';1352matra = '';1353}1354else if (core_sound.CoreSound == 'ꦂꦂꦮ') {1355// -rw-1356if (this.vowelPrev)1357konsonan = 'ꦂꦮ';1358// -rw- -- arwana1359else1360konsonan = 'ꦫ꧀ꦮ'; // rw- -- rwa/rwi/rwab1361}1362else if (core_sound.CoreSound == 'ꦃꦃꦭ') {1363// -hl-1364if (this.vowelPrev)1365konsonan = 'ꦃꦭ';1366// -hl-1367else1368konsonan = 'ꦲ꧀ꦭ'; // hlam1369}1370else if (core_sound.CoreSound == 'ꦃꦃꦮ') {1371// -hw-1372if (this.vowelPrev)1373konsonan = 'ꦃꦮ';1374// -hw-1375else1376konsonan = 'ꦲ꧀ꦮ'; // hwab,hwan1377}1378else if (core_sound.CoreSound == 'ꦃꦲꦾ') {1379// -hy-1380if (this.vowelPrev)1381konsonan = 'ꦃꦪ';1382// sembahyang1383else1384konsonan = 'ꦲꦾ'; // hyang1385/* rules for some characters that change depends on the matra/vowel (e.g. lx and rx, and -rx) */1386}1387else if (findstr(core_sound.CoreSound, 'ꦾ') && matra == '꧀') {1388// pengkal1389konsonan = core_sound.CoreSound;1390matra = ''; // -y-1391}1392else if (findstr(core_sound.CoreSound, 'ꦿ') && matra == '꧀') {1393// cakra1394konsonan = core_sound.CoreSound;1395matra = ''; // -r-1396}1397else if (findstr(core_sound.CoreSound, 'ꦿ') && matra == 'ꦼ') {1398// cakra keret1399if ((str[0] == 'n' && str[1] == 'y') ||1400((str[0] == 't' || str[0] == 'd') && str[1] == 'h')) {1401konsonan = this.GetCoreSound(str[0] + str[1]).CoreSound + 'ꦽ';1402matra = ''; // nyrê-, thrê-, dhrê-1403}1404else if (str[0] == 'n' && str[1] == 'g') {1405if (str[2] == 'g')1406konsonan = 'ꦔ꧀ꦒꦽ';1407else1408konsonan = 'ꦔꦽ';1409matra = ''; // nggrê-/ngrê-1410}1411else {1412konsonan = this.GetCoreSound(str[0]).CoreSound + 'ꦽ';1413matra = ''; // -rê-1414}1415}1416else if (findstr(core_sound.CoreSound, 'ꦭ') && matra == 'ꦼ') {1417// nga lelet1418if ((str[0] == 'n' && str[1] == 'y') ||1419((str[0] == 't' || str[0] == 'd') && str[1] == 'h')) {1420konsonan = this.GetCoreSound(str[0] + str[1]).CoreSound + '꧀ꦭꦼ';1421matra = ''; // nylê-, thlê-, dhlê-1422}1423else if (str[0] == 'n' && str[1] == 'g') {1424if (str[2] == 'g')1425konsonan = 'ꦔ꧀ꦒ꧀ꦭꦼ';1426else1427konsonan = 'ꦔ꧀ꦭꦼ';1428matra = ''; // ngglê-/nglê-1429}1430else if (str[0] == 'l') {1431konsonan = 'ꦊ';1432matra = ''; // -lê-1433}1434else {1435konsonan = this.GetCoreSound(str[0]).CoreSound + '꧀ꦭꦼ';1436matra = ''; // -lê-1437}1438}1439else if (core_sound.CoreSound == 'ꦃ' && matra == '꧀') {1440// wignyan - 12 April1441konsonan = 'ꦲ'; // ha1442}1443else if (core_sound.CoreSound == 'ꦃ' && matra != '꧀') {1444// wignyan1445konsonan = 'ꦲ'; // ha1446}1447else if (core_sound.CoreSound == 'ꦂ' && matra == 'ꦼ') {1448// pa cerek1449konsonan = 'ꦉ';1450matra = ''; // rê1451}1452else if (core_sound.CoreSound == 'ꦂ' && matra == '꧀') {1453// layar1454konsonan = 'ꦫ'; // ra1455}1456else if (core_sound.CoreSound == 'ꦂ' && matra != '꧀') {1457// layar1458konsonan = 'ꦫ'; // ra1459}1460else if (core_sound.CoreSound == 'ꦁ' && matra == '꧀') {1461// cecak1462konsonan = 'ꦁ';1463matra = ''; // cecak1464}1465else if (core_sound.CoreSound == 'ꦁ' && matra != '꧀') {1466// cecak1467konsonan = 'ꦔ'; // nga1468}1469else {1470konsonan = core_sound.CoreSound;1471}1472return '' + konsonan + matra;1473}1474}1475toLatin() {1476// var agt = navigator.userAgent.toLowerCase();1477// if (agt.indexOf("msie")!=-1) { //IE1478// var range = document.selection.createRange()1479// txt = range.text;1480// if (txt == '') {1481// var str = window.document.formText.editSrc.value;1482// }else{1483// var str = range.text;1484// }1485// }1486// else {1487// str = window.document.formText.editSrc.value;1488// }1489const ganti = (index, character, str) => str.substr(0, index) + character;1490const ganti2 = (index, character, str) => str.substr(0, index - 1) + character;1491const ganti3 = (index, character, str) => str.substr(0, index - 2) + character;1492// const capitalize = (index: number, character: string, str: string) =>1493// str.charAt(0).toUpperCase() + str.slice(1)1494let trans = this.str;1495const regexp_file = this.aksara2Latin();1496for (let i = 0, j = 0; i < this.str.length; i++) {1497if (!regexp_file[this.str[i]]) {1498// not Aksara Jawa1499trans = ganti(j, this.str[i], trans);1500j++;1501}1502else {1503if (this.str[i] == 'ꦴ' ||1504this.str[i] == 'ꦶ' ||1505this.str[i] == 'ꦸ' ||1506this.str[i] == 'ꦺ' ||1507this.str[i] == 'ꦼ') {1508if (i > 2 && this.str[i - 1] == 'ꦲ' && this.str[i - 2] == 'ꦲ') {1509// -hah-1510if (this.str[i] == 'ꦴ')1511trans = ganti3(j, 'ā', trans);1512else if (this.str[i] == 'ꦶ')1513trans = ganti3(j, 'ai', trans);1514else if (this.str[i] == 'ꦸ')1515trans = ganti3(j, 'au', trans);1516else if (this.str[i] == 'ꦺ')1517trans = ganti3(j, 'ae', trans);1518else if (this.str[i] == 'ꦼ')1519trans = ganti3(j, 'aě', trans);1520// str[i] == "ꦶ" || str[i] == "ꦸ" || str[i] == "ꦺ" || str[i] == "ꦼ"1521}1522else if (i > 2 && this.str[i - 1] == 'ꦲ') {1523// -h-1524if (this.str[i] == 'ꦴ')1525trans = ganti2(j, 'ā', trans);1526else if (this.str[i] == 'ꦶ')1527trans = ganti2(j, 'i', trans);1528else if (this.str[i] == 'ꦸ')1529trans = ganti2(j, 'u', trans);1530else if (this.str[i] == 'ꦺ')1531trans = ganti2(j, 'e', trans);1532else if (this.str[i] == 'ꦼ')1533trans = ganti2(j, 'ě', trans);1534} /**/1535else if (i > 0 &&1536this.str[i] == 'ꦴ' &&1537this.str[i - 1] == 'ꦺ') {1538trans = ganti2(j, 'o', trans); // -o //2 aksara -> 1 huruf1539}1540else if (i > 0 && this.str[i] == 'ꦴ' && this.str[i - 1] == 'ꦻ') {1541trans = ganti3(j, 'au', trans); // -au //2 aksara -> 2 huruf1542}1543else if (this.str[i] == 'ꦴ') {1544trans = ganti(j, 'aa', trans); // -aa1545j++;1546}1547else if (i > 0 &&1548(this.str[i] == 'ꦶ' ||1549this.str[i] == 'ꦸ' ||1550this.str[i] == 'ꦺ' ||1551this.str[i] == 'ꦼ') &&1552(this.str[i - 1] == 'ꦄ' ||1553this.str[i - 1] == 'ꦌ' ||1554this.str[i - 1] == 'ꦆ' ||1555this.str[i - 1] == 'ꦎ' ||1556this.str[i - 1] == 'ꦈ')) {1557trans = ganti(j, regexp_file[this.str[i]], trans);1558j++;1559}1560else {1561trans = ganti2(j, regexp_file[this.str[i]], trans);1562}1563}1564else if (this.str[i] == 'ꦽ' ||1565this.str[i] == 'ꦾ' ||1566this.str[i] == 'ꦿ' ||1567this.str[i] == 'ꦷ' ||1568this.str[i] == 'ꦹ' ||1569this.str[i] == 'ꦻ' ||1570this.str[i] == 'ꦇ' ||1571this.str[i] == 'ꦍ') {1572// 1 aksara -> 2 huruf1573trans = ganti2(j, regexp_file[this.str[i]], trans);1574j++;1575}1576else if (this.str[i] == '꦳') {1577// 2 aksara -> 2 huruf1578if (i > 0 && this.str[i - 1] == 'ꦗ') {1579if (i > 1 && this.str[i - 2] == '꧊') {1580trans = ganti3(j, 'Za', trans);1581}1582else {1583trans = ganti3(j, 'za', trans);1584}1585}1586else if (i > 0 && this.str[i - 1] == 'ꦥ') {1587if (i > 1 && this.str[i - 2] == '꧊') {1588trans = ganti3(j, 'Fa', trans);1589}1590else {1591trans = ganti3(j, 'fa', trans);1592}1593}1594else if (i > 0 && this.str[i - 1] == 'ꦮ') {1595if (i > 1 && this.str[i - 2] == '꧊') {1596trans = ganti3(j, 'Va', trans);1597}1598else {1599trans = ganti3(j, 'va', trans);1600} // catatan, "va" biasanya ditulis sama dengan "fa" (dengan pa+cecak telu), variannya adalah wa+cecak telu.1601}1602else if (i > 0 && this.str[i - 1] == 'ꦲ') {1603if (i > 1 && this.str[i - 2] == '꧊') {1604trans = ganti3(j, 'Ḥa', trans);1605}1606else {1607trans = ganti3(j, 'ḥa', trans);1608}1609}1610else if (i > 0 && this.str[i - 1] == 'ꦏ') {1611if (i > 1 && this.str[i - 2] == '꧊') {1612trans = ganti3(j, 'Kha', trans);1613j++;1614}1615else {1616trans = ganti3(j, 'kha', trans);1617j++;1618}1619}1620else if (i > 0 && this.str[i - 1] == 'ꦢ') {1621if (i > 1 && this.str[i - 2] == '꧊') {1622trans = ganti3(j, 'Dza', trans);1623j++;1624}1625else {1626trans = ganti3(j, 'dza', trans);1627j++;1628}1629}1630else if (i > 0 && this.str[i - 1] == 'ꦱ') {1631if (i > 1 && this.str[i - 2] == '꧊') {1632trans = ganti3(j, 'Sya', trans);1633j++;1634}1635else {1636trans = ganti3(j, 'sya', trans);1637j++;1638}1639}1640else if (i > 0 && this.str[i - 1] == 'ꦒ') {1641if (i > 1 && this.str[i - 2] == '꧊') {1642trans = ganti3(j, 'Gha', trans);1643j++;1644}1645else {1646trans = ganti3(j, 'gha', trans);1647j++;1648}1649}1650else if (i > 0 && this.str[i - 1] == 'ꦔ') {1651trans = ganti3(j, "'a", trans);1652}1653else {1654trans = ganti2(j, regexp_file[this.str[i]], trans);1655}1656}1657else if (this.str[i] == '꧀') {1658trans = ganti2(j, regexp_file[this.str[i]], trans);1659}1660else if (this.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] == 'ꦖ' ||1689this.str[i] == 'ꦙ' ||1690this.str[i] == 'ꦡ' ||1691this.str[i] == 'ꦣ' ||1692this.str[i] == 'ꦦ' ||1693this.str[i] == 'ꦨ') {1694if (i > 0 && this.str[i - 1] == '꧊') {1695if (this.str[i] == 'ꦐ') {1696trans = ganti(j, 'Qa', trans);1697j += 2;1698}1699else if (this.str[i] == 'ꦧ' || this.str[i] == 'ꦨ') {1700trans = ganti(j, 'Ba', trans);1701j += 2;1702}1703else if (this.str[i] == 'ꦕ' || this.str[i] == 'ꦖ') {1704trans = ganti(j, 'Ca', trans);1705j += 2;1706}1707else if (this.str[i] == 'ꦢ' || this.str[i] == 'ꦣ') {1708trans = ganti(j, 'Da', trans);1709j += 2;1710}1711else if (this.str[i] == 'ꦒ' || this.str[i] == 'ꦓ') {1712trans = ganti(j, 'Ga', trans);1713j += 2;1714}1715else if (this.str[i] == 'ꦲ') {1716if (i > 0 &&1717(this.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] == 'ꦆ' ||1725this.str[i - 1] == 'ꦎ' ||1726this.str[i - 1] == 'ꦈ' ||1727this.str[i - 1] == 'ꦿ' ||1728this.str[i - 1] == 'ꦾ' ||1729this.str[i - 1] == 'ꦽ')) {1730trans = ganti(j, 'h' + regexp_file[this.str[i]], trans);1731j += 2;1732}1733if (i > 0 && this.str[i - 1] == '꧊') {1734trans = ganti(j, 'H' + regexp_file[this.str[i]], trans);1735j += 2;1736}1737else {1738trans = ganti(j, '@' + regexp_file[this.str[i]], trans);1739j += 2;1740}1741// trans = ganti(j, "Ha", trans);j+=2;1742}1743else if (this.str[i] == 'ꦗ' || this.str[i] == 'ꦙ') {1744trans = ganti(j, 'Ja', trans);1745j += 2;1746}1747else if (this.str[i] == 'ꦏ' || this.str[i] == 'ꦑ') {1748trans = ganti(j, 'Ka', trans);1749j += 2;1750}1751else if (this.str[i] == 'ꦭ') {1752trans = ganti(j, 'La', trans);1753j += 2;1754}1755else if (this.str[i] == 'ꦩ') {1756trans = ganti(j, 'Ma', trans);1757j += 2;1758}1759else if (this.str[i] == 'ꦤ' || this.str[i] == 'ꦟ') {1760trans = ganti(j, 'Na', trans);1761j += 2;1762}1763else if (this.str[i] == 'ꦥ' || this.str[i] == 'ꦦ') {1764trans = ganti(j, 'Pa', trans);1765j += 2;1766}1767else if (this.str[i] == 'ꦫ' || this.str[i] == 'ꦬ') {1768trans = ganti(j, 'Ra', trans);1769j += 2;1770}1771else if (this.str[i] == 'ꦱ' || this.str[i] == 'ꦯ') {1772trans = ganti(j, 'Sa', trans);1773j += 2;1774}1775else if (this.str[i] == 'ꦠ' || this.str[i] == 'ꦡ') {1776trans = ganti(j, 'Ta', trans);1777j += 2;1778}1779else if (this.str[i] == 'ꦮ') {1780trans = ganti(j, 'Wa', trans);1781j += 2;1782}1783else if (this.str[i] == 'ꦪ') {1784trans = ganti(j, 'Ya', trans);1785j += 2;1786}1787else {1788ganti(j, regexp_file[this.str[i]], trans);1789j += 3;1790}1791}1792else if (i > 0 && this.str[i] == 'ꦲ' && this.str[i - 1] == 'ꦃ') {1793// double hh1794trans = ganti(j, 'a', trans);1795j++;1796}1797else if (i > 0 && this.str[i] == 'ꦫ' && this.str[i - 1] == 'ꦂ') {1798// double rr1799trans = ganti(j, 'a', trans);1800j++;1801}1802else if (i > 0 && this.str[i] == 'ꦔ' && this.str[i - 1] == 'ꦁ') {1803// double ngng1804trans = ganti(j, 'a', trans);1805j++;1806}1807else if (i > 1 &&1808this.str[i] == 'ꦕ' &&1809this.str[i - 1] == '꧀' &&1810this.str[i - 2] == 'ꦚ') {1811// nyj & nyc1812trans = ganti(j - 3, 'nca', trans);1813}1814else if (i > 1 &&1815this.str[i] == 'ꦗ' &&1816this.str[i - 1] == '꧀' &&1817this.str[i - 2] == 'ꦚ') {1818// nyj & nyc1819trans = ganti(j - 3, 'nja', trans);1820}1821else if (this.str[i] == 'ꦲ' &&1822(i == 0 ||1823[1824' ',1825'',1826'꧀',1827'꦳',1828'ꦴ',1829'ꦶ',1830'ꦷ',1831'ꦸ',1832'ꦹ',1833'ꦺ',1834'ꦻ',1835'ꦼ',1836'ꦽ',1837'ꦾ',1838'ꦿ'1839].indexOf(this.str[i - 1]) >= 0)) {1840// ha, preceeded by space or zws or open vowel1841trans = ganti(j, '_a', trans);1842j += 2;1843}1844else if (this.str[i] == 'ꦑ' ||1845this.str[i] == 'ꦓ' ||1846this.str[i] == 'ꦖ' ||1847this.str[i] == 'ꦙ' ||1848this.str[i] == 'ꦡ' ||1849this.str[i] == 'ꦣ' ||1850this.str[i] == 'ꦦ' ||1851this.str[i] == 'ꦨ') {1852// bha, cha, dha, dll.1853trans = ganti(j, regexp_file[this.str[i]], trans);1854j += 3;1855}1856else {1857// ba, ca, da, dll.1858trans = ganti(j, regexp_file[this.str[i]], trans);1859j += 2;1860}1861}1862else if (this.str[i] == 'ꦔ' ||1863this.str[i] == 'ꦘ' ||1864this.str[i] == 'ꦚ' ||1865this.str[i] == 'ꦛ' ||1866this.str[i] == 'ꦜ' ||1867this.str[i] == 'ꦝ' ||1868this.str[i] == 'ꦞ' ||1869this.str[i] == 'ꦋ') {1870// nga, nya, tha, dha1871if (i > 0 && this.str[i - 1] == '꧊') {1872if (this.str[i] == 'ꦔ') {1873trans = ganti(j, 'Nga', trans);1874j += 3;1875}1876else if (this.str[i] == 'ꦚ' || this.str[i] == 'ꦘ') {1877trans = ganti(j, 'Nya', trans);1878j += 3;1879}1880else if (this.str[i] == 'ꦛ' || this.str[i] == 'ꦜ') {1881trans = ganti(j, 'Tha', trans);1882j += 3;1883}1884else if (this.str[i] == 'ꦝ' || this.str[i] == 'ꦞ') {1885trans = ganti(j, 'Dha', trans);1886j += 3;1887}1888else {1889ganti(j, regexp_file[this.str[i]], trans);1890j += 3;1891}1892}1893else if (i > 0 && this.str[i] == 'ꦘ') {1894trans = ganti(j, regexp_file[this.str[i]], trans);1895j += 4;1896}1897else {1898trans = ganti(j, regexp_file[this.str[i]], trans);1899j += 3;1900}1901}1902else if (this.str[i] == '꧊') {1903// penanda nama diri -- made up for Latin back-compat1904trans = ganti(j, '', trans);1905}1906else if ((this.str[i] == ' ', trans)) {1907if (i > 0 && this.str[i - 1] == '꧀') {1908// pangkon diikuti regular space = koma1909trans = ganti(j, ', ', trans);1910j += 2;1911}1912else {1913trans = ganti(j, ' ', trans);1914j++;1915}1916}1917else if ((this.str[i] == '꧈', trans)) {1918if (i > 0 && this.str[i - 1] == '꧀') {1919// pangkon diikuti pada lingsa = titik1920trans = ganti(j, '.', trans);1921j++;1922}1923else {1924// pada lingsa saja = koma1925trans = ganti(j, ',', trans);1926j++;1927}1928}1929else {1930trans = ganti(j, regexp_file[this.str[i]], trans);1931j++;1932}1933}1934}1935trans = trans1936.split(' ')1937.map((v) => v.startsWith('_') ? v.replace('_', this.isHVokal ? '' : 'h') : v)1938.join(' ');1939return trans.toString();1940}1941aksara2Latin() {1942return {1943ꦏ: 'ka',1944ꦐ: 'qa',1945ꦑ: 'kʰa',1946ꦒ: 'ga',1947ꦓ: 'gʰa',1948ꦔ: 'nga',1949ꦕ: 'ca',1950ꦖ: 'cʰa',1951ꦗ: 'ja',1952ꦘ: 'jnya',1953ꦙ: 'jʰa',1954ꦚ: 'nya',1955ꦛ: 'tha',1956ꦜ: 'ṭʰa',1957ꦝ: 'dha',1958ꦞ: 'ḍʰa',1959ꦟ: 'ṇa',1960ꦠ: 'ta',1961ꦡ: 'ṭa',1962ꦢ: 'da',1963ꦣ: 'ḍa',1964ꦤ: 'na',1965ꦥ: 'pa',1966ꦦ: 'pʰa',1967ꦧ: 'ba',1968ꦨ: 'bʰa',1969ꦩ: 'ma',1970ꦪ: 'ya',1971ꦫ: 'ra',1972ꦬ: 'ṛa',1973ꦭ: 'la',1974ꦮ: 'wa',1975ꦯ: 'śa',1976ꦰ: 'ṣa',1977ꦱ: 'sa',1978ꦲ: 'ha',1979'ꦁ': 'ng',1980'ꦂ': 'r',1981'ꦃ': 'h',1982ꦄ: 'A',1983ꦅ: 'I',1984ꦆ: 'I',1985ꦇ: 'Ii',1986ꦈ: 'U',1987ꦉ: 'rê',1988ꦊ: 'lê',1989ꦋ: 'lêu',1990ꦌ: 'E',1991ꦍ: 'Ai',1992ꦎ: 'O',1993'ꦺꦴ': 'o',1994'ꦴ': 'a',1995'ꦶ': 'i',1996'ꦷ': 'ii',1997'ꦸ': 'u',1998'ꦹ': 'uu',1999'ꦺ': 'e',2000'ꦻ': 'ai',2001'ꦼ': 'ê',2002'ꦽ': 'rê',2003'ꦾ': 'ya',2004'ꦿ': 'ra',2005'ꦀ': '',2006'꦳': '',2007'꧀': '',2008'꧇': '',2009'꧁': '—',2010'꧂': '—',2011'꧃': '–',2012'꧄': '–',2013'꧅': '–',2014'꧆': '',2015'꧈': ',',2016'꧉': '.',2017'꧊': 'qqq',2018'꧋': '–',2019'꧌': '–',2020'꧍': '–',2021ꧏ: '²',2022'꧐': '0',2023'꧑': '1',2024'꧒': '2',2025'꧓': '3',2026'꧔': '4',2027'꧕': '5',2028'꧖': '6',2029'꧗': '7',2030'꧘': '8',2031'꧙': '9',2032'꧞': '—',2033'꧟': '—',2034// "": '#',//zero-width joiner2035'': ' ',2036' ': ' ' // regular space2037};2038}2039}2040//# sourceMappingURL=aksarajawa.js.map20412042