├── jtrans.png ├── jtrans.css ├── manifest.json ├── .gitattributes ├── jtrans.html ├── README.md ├── .gitignore └── jtrans.js /jtrans.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/adhocore/crx-jtrans/HEAD/jtrans.png -------------------------------------------------------------------------------- /jtrans.css: -------------------------------------------------------------------------------- 1 | body{min-width:500px;overflow-x:hidden} 2 | textarea{margin:5px;border:1px solid#ddd;vertical-align:middle;width:485px;height:150px;resize:none} 3 | p{margin:0 0 0 6px} 4 | .jtrans-action{float:right;width:50px;margin-left:5px;text-decoration:underline;cursor:pointer;text-align:left;} 5 | #jtrans-help{width:35px;} 6 | table{border-collapse:collapse;background:#f2f2f2;margin:5px} 7 | td{padding:3px 0;border:1px solid#ccc;width:50px;text-align:center} 8 | .lt,.rt{font-family:sans-serif;font-size:14px;margin:0 3px} -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "jTransliter by Jitendra", 4 | "description": "Translits romanised Nepali input to Unicode Nepali.", 5 | "version": "1.0", 6 | "browser_action": { 7 | "default_icon": "jtrans.png", 8 | "default_popup": "jtrans.html" 9 | }, 10 | "commands": { 11 | "_execute_browser_action": { 12 | "suggested_key": { 13 | "default": "Alt+N", 14 | "linux": "Alt+N", 15 | "mac": "Alt+N", 16 | "windows": "Alt+N" 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /jtrans.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | jTransliter - Translits Romanised Nepali input to Unicode Nepali 5 | 6 | 7 | 8 |

jTransliter - Translits Romanised Nepali input to Unicode Nepali.

9 | 10 |

11 | Active. Ctrl = Pause | Esc = Close. 12 | Help 13 | Clear 14 | Copy 15 |

16 |
17 | 18 |

© 2013 - 2014 — Jitendra Adhikari

19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## crx-jtrans 2 | 3 | - it is a browser extension for Google chrome 4 | - it has another name: jTransliter 5 | - it is totally offline (hence always accessible) 6 | - it requires no special permission (hence safe, doesnot scan your browsing) 7 | - it requires no another library (hence standalone and reliable) 8 | 9 | 10 | ## installation 11 | 12 | - clone or [download](https://github.com/adhocore/crx-jtrans/archive/master.zip) this repo to your machine 13 | - unzip as the folder `crx-jtrans` 14 | - open up your Google chrome browser and type `chrome://extensions/` at Address bar 15 | - or go to Chrome Settings > Extensions 16 | - check/select the `Developer Mode` checkbox on top 17 | - then click `Load unpacked extension` and browse file system and the select `crx-jtrans` folder recently unzipped 18 | - if you see the button [unicode a](http://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Devanagari_a.svg/220px-Devanagari_a.svg.png) at the top-right of the chrome browser beside the Address bar, you are Done ! 19 | 20 | 21 | ## features 22 | 23 | - comes with usage help (though you might only need it for first few uses) 24 | - easy usage: type in roman and press `Space` or `Enter` key 25 | - reversible (back to roman for correction) translitered words: just press `Backspace` key 26 | - enable or disable the transliteration simply pressing `Ctrl` key 27 | - see change logs below for more 28 | 29 | ## change logs 30 | 31 | #### 2014-03-19 32 | 33 | - added hotkey- Press Alt+N to launch 34 | - fixed reversal issue with some of the characters 35 | - added a semi-permanent save of latest text 36 | - more awesomeness ;) 37 | 38 | Thats all ! 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | 46 | [Dd]ebug/ 47 | [Rr]elease/ 48 | x64/ 49 | build/ 50 | [Bb]in/ 51 | [Oo]bj/ 52 | 53 | # MSTest test Results 54 | [Tt]est[Rr]esult*/ 55 | [Bb]uild[Ll]og.* 56 | 57 | *_i.c 58 | *_p.c 59 | *.ilk 60 | *.meta 61 | *.obj 62 | *.pch 63 | *.pdb 64 | *.pgc 65 | *.pgd 66 | *.rsp 67 | *.sbr 68 | *.tlb 69 | *.tli 70 | *.tlh 71 | *.tmp 72 | *.tmp_proj 73 | *.log 74 | *.vspscc 75 | *.vssscc 76 | .builds 77 | *.pidb 78 | *.log 79 | *.scc 80 | 81 | # Visual C++ cache files 82 | ipch/ 83 | *.aps 84 | *.ncb 85 | *.opensdf 86 | *.sdf 87 | *.cachefile 88 | 89 | # Visual Studio profiler 90 | *.psess 91 | *.vsp 92 | *.vspx 93 | 94 | # Guidance Automation Toolkit 95 | *.gpState 96 | 97 | # ReSharper is a .NET coding add-in 98 | _ReSharper*/ 99 | *.[Rr]e[Ss]harper 100 | 101 | # TeamCity is a build add-in 102 | _TeamCity* 103 | 104 | # DotCover is a Code Coverage Tool 105 | *.dotCover 106 | 107 | # NCrunch 108 | *.ncrunch* 109 | .*crunch*.local.xml 110 | 111 | # Installshield output folder 112 | [Ee]xpress/ 113 | 114 | # DocProject is a documentation generator add-in 115 | DocProject/buildhelp/ 116 | DocProject/Help/*.HxT 117 | DocProject/Help/*.HxC 118 | DocProject/Help/*.hhc 119 | DocProject/Help/*.hhk 120 | DocProject/Help/*.hhp 121 | DocProject/Help/Html2 122 | DocProject/Help/html 123 | 124 | # Click-Once directory 125 | publish/ 126 | 127 | # Publish Web Output 128 | *.Publish.xml 129 | *.pubxml 130 | 131 | # NuGet Packages Directory 132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 133 | #packages/ 134 | 135 | # Windows Azure Build Output 136 | csx 137 | *.build.csdef 138 | 139 | # Windows Store app package directory 140 | AppPackages/ 141 | 142 | # Others 143 | sql/ 144 | *.Cache 145 | ClientBin/ 146 | [Ss]tyle[Cc]op.* 147 | ~$* 148 | *~ 149 | *.dbmdl 150 | *.[Pp]ublish.xml 151 | *.pfx 152 | *.publishsettings 153 | 154 | # RIA/Silverlight projects 155 | Generated_Code/ 156 | 157 | # Backup & report files from converting an old project file to a newer 158 | # Visual Studio version. Backup files are not needed, because we have git ;-) 159 | _UpgradeReport_Files/ 160 | Backup*/ 161 | UpgradeLog*.XML 162 | UpgradeLog*.htm 163 | 164 | # SQL Server files 165 | App_Data/*.mdf 166 | App_Data/*.ldf 167 | 168 | ############# 169 | ## Windows detritus 170 | ############# 171 | 172 | # Windows image file caches 173 | Thumbs.db 174 | ehthumbs.db 175 | 176 | # Folder config file 177 | Desktop.ini 178 | 179 | # Recycle Bin used on file shares 180 | $RECYCLE.BIN/ 181 | 182 | # Mac crap 183 | .DS_Store 184 | 185 | 186 | ############# 187 | ## Python 188 | ############# 189 | 190 | *.py[co] 191 | 192 | # Packages 193 | *.egg 194 | *.egg-info 195 | dist/ 196 | build/ 197 | eggs/ 198 | parts/ 199 | var/ 200 | sdist/ 201 | develop-eggs/ 202 | .installed.cfg 203 | 204 | # Installer logs 205 | pip-log.txt 206 | 207 | # Unit test / coverage reports 208 | .coverage 209 | .tox 210 | 211 | #Translations 212 | *.mo 213 | 214 | #Mr Developer 215 | .mr.developer.cfg 216 | -------------------------------------------------------------------------------- /jtrans.js: -------------------------------------------------------------------------------- 1 | /** 2 | * JavaScript Plugin - jTransliter 3 | * Translits Roman To Nepali Unicode Live 4 | * 5 | * @author adhocore | Jitendra Adhikari 6 | * @email jiten.adhikary@gmail.com 7 | */ 8 | 9 | ; 10 | var jTransliter = jTransliter || { 11 | mod: {"a": "", "aa": "\u093e", "A": "\u093e", "i": "\u093f", "ii": "\u0940", "ee": "\u0940", "I": "\u0940", "u": "\u0941", "uu": "\u0942", "oo": "\u0942", "U": "\u0942", "R": "\u0943", "e": "\u0947", "ai": "\u0948", "ei": "\u0948", "o": "\u094b", "ou": "\u094c", "au": "\u094c", ".": "\u094d", "Om": "\u0950", "OM": "\u0950", "Ri": "\u0943", "Rh": "\u0943", "^": "\u0902", "*": "\u0901"}, 12 | num: {"0": "\u0966", "1": "\u0967", "2": "\u0968", "3": "\u0969", "4": "\u096a", "5": "\u096b", "6": "\u096c", "7": "\u096d", "8": "\u096e", "9": "\u096f", ".": ".", "-": "-"}, 13 | chr: {"^": "\u0902", "*": "\u0901", "a": "\u0905", "aa": "\u0906", "ai": "\u0910", "au": "\u0914", "b": "\u092c", "B": "\u092c", "bh": "\u092d", "Bh": "\u092d", "ch": "\u091a", "x": "\u091b", "X": "\u091b", "chh": "\u091b", "cH": "\u091b", "CH": "\u091b", "Ch": "\u091a", "Chh": "\u091b", "d": "\u0926", "dh": "\u0927", "e": "\u090f", "f": "\u092b", "F": "\u092b", "g": "\u0917", "gh": "\u0918", "G": "\u0917", "Gh": "\u0918", "h": "\u0939", "i": "\u0907", "ee": "\u0907", "ii": "\u0908", "j": "\u091c", "J": "\u091c", "jh": "\u091d", "Jh": "\u091d", "k": "\u0915", "K": "\u0915", "c": "\u0915", "C": "\u0915", "kh": "\u0916", "Kh": "\u0916", "l": "\u0932", "L": "\u0932", "m": "\u092e", "n": "\u0928", "ng": "\u0919", "o": "\u0913", "oo": "\u090a", "ou": "\u0914", "p": "\u092a", "P": "\u092a", "ph": "\u092b", "q": "\u0915", "Q": "\u0915", "r": "\u0930", "RH": "\u090b", "s": "\u0938", "sh": "\u0937", "t": "\u0924", "th": "\u0925", "u": "\u0909", "uu": "\u090a", "v": "\u092d", "V": "\u092d", "w": "\u0935", "W": "\u0935", "y": "\u092f", "Y": "\u092f", "yn": "\u091e", "z": "\u091c", "Z": "\u091c", "Gy": "\u091c\u094d\u091e", "Gn": "\u091c\u094d\u091e",".": "\u0964", "..": "\u0965", "A": "\u0906", "D": "\u0921", "Dh": "\u0922", "E": "\u0908", "H": "\u0903", "I": "\u0908", "Lr": "\u090c", "M": "\u0902", "MM": "\u0901", "N": "\u0923", "O": "\u0911", "R": "\u0943", "Ri": "\u090b", "S": "\u0936", "T": "\u091f", "Th": "\u0920", "U": "\u090a"}, 14 | type: function(t) { 15 | if (!t) 16 | return'X'; 17 | if (t.match(/[0-9]/)) 18 | return'N'; 19 | else if (t.match(/[aeiuo]/i)) 20 | return'V'; 21 | else if (t.match(/[bcdfghj-np-tv-z]+/i)) 22 | return'C'; 23 | else if (t.match(/[.]/)) 24 | return'D'; 25 | else 26 | return'X'; 27 | }, 28 | char: function(t) { 29 | return this.chr.hasOwnProperty(t) ? this.chr[t] : ''; 30 | }, 31 | modifier: function(t) { 32 | return this.mod.hasOwnProperty(t) ? this.mod[t] : ''; 33 | }, 34 | number: function(n) { 35 | nn = ''; 36 | for (var k = 0; k < n.length; k++) { 37 | nn += this.num[n.substr(k, 1)]; 38 | } 39 | return nn; 40 | }, 41 | unicode: function(a) { 42 | var b = a.length; 43 | var c = ''; 44 | var d = false; 45 | for (i = 0; i < b; i++) { 46 | v0 = (i === 0) ? '' : a[i - 1]; 47 | v = a[i]; 48 | v1 = (i < b - 1) ? a[i + 1] : ''; 49 | t0 = this.type(v0); 50 | t = this.type(v); 51 | t1 = this.type(v1); 52 | if (t === 'C') { 53 | if (d && (v0 && t0 === 'C')) { 54 | if ((v1 !== 'R' && v1 !== 'H' && v1 !== 'M') && (v !== 'R' && v !== 'H' && v !== 'M')); 55 | c += "\u094d"; 56 | d = false; 57 | } else { 58 | d = false; 59 | } 60 | if (((v === 'R' && v1 !== 'i') || v === 'H' || v === 'M') && (t0 !== 'C' && t0 !== 'V')) { 61 | c += char(v.toLowerCase()); 62 | if ((v1 && t1 === 'C') && (v1 !== 'R' && v1 !== 'H' && v1 !== 'M')) 63 | c += "\u094d"; 64 | continue; 65 | } 66 | if (t1 === 'C') { 67 | try_ = this.char(v + v1); 68 | if (try_) { 69 | c += try_; 70 | i++; 71 | d = true; 72 | continue; 73 | }; 74 | c += this.char(v); 75 | if ((v1 !== 'R' && v1 !== 'H' && v1 !== 'M') && (v !== 'R' && v !== 'H' && v !== 'M')) 76 | c += "\u094d"; 77 | } else { 78 | try_ = this.char(v + v1); 79 | if (try_) { 80 | c += try_; 81 | i++; 82 | d = true; 83 | continue; 84 | }; 85 | c += this.char(v); 86 | } 87 | } else if (t === 'V') { 88 | if (t1 === 'V') { 89 | try_ = (t0 === 'C') ? this.modifier(v + v1) : this.char(v + v1); 90 | if (try_) { 91 | c += try_; 92 | i++; 93 | continue; 94 | } 95 | c += ((v0 && t0 !== 'C') || !v0) ? this.char(v) : this.modifier(v); 96 | } else { 97 | c += ((v0 && t0 !== 'C') || !v0) ? this.char(v) : this.modifier(v); 98 | } 99 | } else if (t === 'N') { 100 | c += this.number(v); 101 | } else if (t === 'D') { 102 | c += (t1 === 'N') ? this.number(v) : this.char(v); 103 | } else if ((v === '^' || v === '*') && (v0 && (t0 === 'V' || t0 === 'C'))) { 104 | c += this.modifier(v) 105 | } else if (v === '_' && (v0 && t0 === 'C')) { 106 | c += "\u094d"; 107 | } else 108 | c += v; 109 | }; 110 | return c; 111 | }, 112 | roman: function(a) { 113 | var b = a.split(''), out = ''; 114 | for (var i = 0; i < b.length; i++) { 115 | curr = this.getMapper(b[i]); 116 | next = (i < b.length) ? this.getMapper(b[i + 1]) : false; 117 | if (this.type(curr) == 'C' && next && next != '.' && this.type(next) == 'C') 118 | out += curr + (this.type(curr[curr.length - 1]) == 'C' ? 'a' : ''); 119 | else 120 | out += ((curr == '.') ? '' : (curr == '?' ? '.' : curr)); 121 | }; 122 | return out; 123 | }, 124 | getPos: function(a) { 125 | return a.selectionStart; 126 | }, 127 | setPos: function(a, b) { 128 | a.setSelectionRange(b, b); 129 | }, 130 | translit: function(a) { 131 | that = a.target || a.srcElement || a.currentTarget; 132 | k = ('which'in a) ? a.which : a.keyCode; 133 | if (k == 32 || k == 13 || k == 8) { 134 | if (that.getAttribute('data-transliter') == 'pause') 135 | return; 136 | var b = jTransliter.getPos(that), string = that.value, subs = string.substr(0, b), parts = subs.split(/[\s]+/), last = parts[parts.length - 1], before = ''; 137 | if (k != 8 && last.match(/[a-z0-9.]+/i)) { 138 | before = string.substr(0, b - last.length) + jTransliter.unicode(last); 139 | }; 140 | if (k == 8 && last) { 141 | if (last.match(/^[a-z0-9.]+$/i)) 142 | return; 143 | before = string.substr(0, b - last.length) + jTransliter.roman(last); 144 | }; 145 | if (before) { 146 | that.value = before + string.substr(b, string.length); 147 | jTransliter.setPos(that, before.length); 148 | } 149 | } 150 | }, 151 | getMapper: function(a) { 152 | for (var b in this.chr) { 153 | if (this.chr[b] == a) 154 | return b == '.' ? '_' : b; 155 | }; 156 | for (var b in this.mod) { 157 | if (this.mod[b] == a) 158 | return b; 159 | }; 160 | for (var b in this.num) { 161 | if (this.num[b] == a) 162 | return b; 163 | }; 164 | return a; 165 | } 166 | }; 167 | 168 | // Handy wrapper 169 | function dgi(i) { 170 | return document.getElementById(i); 171 | }; 172 | 173 | // live translit 174 | dgi('jtrans-area').addEventListener('keydown', jTransliter.translit); 175 | 176 | // HotKey actions 177 | document.addEventListener('keydown', function(a) { 178 | var b = dgi('jtrans-area'), c = dgi('jtrans-info'); 179 | var k = ('which'in event) ? event.which : event.keyCode; 180 | if (k == 17) { 181 | if (b.getAttribute('data-transliter') == 'resume') { 182 | b.setAttribute('data-transliter', 'pause'); 183 | c.innerHTML = 'Paused. Ctrl = Resume | Esc = Close.'; 184 | } else { 185 | b.setAttribute('data-transliter', 'resume'); 186 | c.innerHTML = 'Active. Ctrl = Pause | Esc = Close.'; 187 | } 188 | } 189 | }); 190 | 191 | // copy and save 192 | dgi("jtrans-copy").addEventListener('click', function(c) { 193 | dgi('jtrans-area').focus(); 194 | dgi('jtrans-area').select(); 195 | document.execCommand("Copy"); 196 | if (window.localStorage) { 197 | localStorage.setItem('latestText', dgi('jtrans-area').value); 198 | } 199 | dgi("jtrans-copy").innerHTML = 'Copied'; 200 | var cp = setTimeout(function(){ 201 | dgi("jtrans-copy").innerHTML = 'Copy'; 202 | window.clearInterval(cp); 203 | }, 1000); 204 | }, false); 205 | 206 | // clear and delete 207 | dgi("jtrans-clear").addEventListener('click', function(c) { 208 | dgi('jtrans-area').focus(); 209 | dgi('jtrans-area').value = ''; 210 | if (window.localStorage) { 211 | localStorage.setItem('latestText', dgi('jtrans-area').value); 212 | } 213 | dgi("jtrans-clear").innerHTML = 'Cleared'; 214 | var cl = setTimeout(function(){ 215 | dgi("jtrans-clear").innerHTML = 'Clear'; 216 | window.clearInterval(cl); 217 | }, 1000); 218 | }, false); 219 | 220 | // load latest text and build usage help 221 | document.addEventListener('DOMContentLoaded', function(l) { 222 | if (window.localStorage) { 223 | dgi('jtrans-area').value = localStorage.getItem('latestText'); 224 | } 225 | var a = ['a', 'aa', 'i', 'ii', 'u', 'uu', 'e', 'ai', 'o', 'au', 'a*', 'aH', '', 'k', 'kh', 'g', 'gh', 'ng', 'ch', 'x', 'j', 'jh', 'yn', 'T', 'Th', 'D', 'Dh', 'N', 't', 'th', 'd', 'dh', 'n', 'p', 'f', 'b', 'v', 'm', 'y', 'r', 'l', 'w', 's', 'S', 'sh', 'h', 'ksh', 'tr', 'Gy']; 226 | var b = ''; 227 | for (var i = 0; i < a.length; i++) { 228 | if (a[i]) 229 | b += '' + jTransliter.unicode(a[i]) + '' + a[i] + ''; 230 | if (i && i % 12 == 0) { 231 | b += ''; 232 | } 233 | } 234 | dgi("jtrans-help-text").innerHTML = b; 235 | }); 236 | 237 | // toggle help 238 | dgi("jtrans-help").addEventListener('click', function(c) { 239 | dgi("jtrans-help-text").style.display = dgi("jtrans-help-text").style.display == 'none' ? 'block' : 'none'; 240 | }); 241 | 242 | // save on collapse 243 | window.addEventListener('unload', function() { 244 | if (window.localStorage && dgi('jtrans-area').value) { 245 | localStorage.setItem('latestText', dgi('jtrans-area').value); 246 | } 247 | }); 248 | 249 | // type just readily ! 250 | dgi('jtrans-area').focus(); --------------------------------------------------------------------------------