Last active
August 29, 2015 14:13
-
-
Save CTimmerman/2d0eeb2c7acf91b9628c to your computer and use it in GitHub Desktop.
Romaji
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bookmarklet to convert hiragana and katatana to romanji (Latin characters) | |
// Based on Hiragana, Katakana, Hepburn, Nihon-shiki, Kunrei-shiki table of http://en.wikipedia.org/wiki/Romanization_of_Japanese | |
javascript:(function(){function t(s){var n="";var i=-1;while(++i<s.length){var c=s[i];c=d[c]||c;n+=d2[c]||c};return n}function A2L(e){if(e.nodeType==3&&e.nodeValue.trim()!=""){e.nodeValue=t(e.nodeValue)}else{var i=e.childNodes.length;while(i--){A2L(e.childNodes[i])}}}var HKH=["あ:ア:a","い:イ:i","う:ウ:u","え:エ:e","お:オ:o","や:ャ:ya","ゆ:ュ:yu","よ:ョ:yo","か:カ:ka","き:キ:ki","く:ク:ku","け:ケ:ke","こ:コ:ko","ゃ:ャ:a","ゅ:ュ:u","ょ:ョ:o","さ:サ:sa","し:シ:shi:si","す:ス:su","せ:セ:se","そ:ソ:so","た:タ:ta","ち:チ:chi:ti","つ:ツ:tsu:tu","て:テ:te","と:ト:to","な:ナ:na","に:ニ:ni","ぬ:ヌ:nu","ね:ネ:ne","の:ノ:no","は:ハ:ha","ひ:ヒ:hi","ふ:フ:fu:hu","へ:ヘ:he","ほ:ホ:ho","ま:マ:ma","み:ミ:mi","む:ム:mu","め:メ:me","も:モ:mo","や:ヤ:ya","ゆ:ユ:yu","よ:ヨ:yo","ら:ラ:ra","り:リ:ri","る:ル:ru","れ:レ:re","ろ:ロ:ro","わ:ワ:wa","ゐ:ヰ:i:wi:i","ゑ:ヱ:e:we:e","を:ヲ:o:wo:o","ん:ン:n-n'(-m):n-n'","が:ガ:ga","ぎ:ギ:gi","ぐ:グ:gu","げ:ゲ:ge","ご:ゴ:go","ざ:ザ:za","じ:ジ:ji:zi","ず:ズ:zu","ぜ:ゼ:ze","ぞ:ゾ:zo","だ:ダ:da","ぢ:ヂ:ji:di:zi","づ:ヅ:zu:du:zu","で:デ:de","ど:ド:do","ば:バ:ba","び:ビ:bi","ぶ:ブ:bu","べ:ベ:be","ぼ:ボ:bo","ぱ:パ:pa","ぴ:ピ:pi","ぷ:プ:pu","ぺ:ペ:pe","ぽ:ポ:po"];var d={};var d2={};var i=HKH.length;while(i--){var a=HKH[i].split(":");d[a[0]]=a[1];d2[a[1]]=a[2]}A2L(document)})() | |
// More accurate version that's less accurate according to "Chiyo Mihama (Japanese: 美浜 ちよ), also known as Chiyo-chan, is a child prodigy in the Azumanga Daioh series." - http://azumanga.wikia.com/wiki/Chiyo_Mihama | |
javascript:(function(){function t(s){var i=HKH.length;while(i--){var a=HKH[i].split(":");s=s.replace(new RegExp(a[0],'g'),a[2]).replace(new RegExp(a[1],'g'),a[2])};return s}function A2L(e){if(e.nodeType==3&&e.nodeValue.trim()!=""){e.nodeValue=t(e.nodeValue)}else{var i=e.childNodes.length;while(i--){A2L(e.childNodes[i])}}}var HKH=["あ:ア:a","い:イ:i","う:ウ:u","え:エ:e","お:オ:o","や:ャ:ya","ゆ:ュ:yu","よ:ョ:yo","か:カ:ka","き:キ:ki","く:ク:ku","け:ケ:ke","こ:コ:ko","きゃ:キャ:kya","きゅ:キュ:kyu","きょ:キョ:kyo","さ:サ:sa","し:シ:shi:si","す:ス:su","せ:セ:se","そ:ソ:so","しゃ:シャ:sha:sya","しゅ:シュ:shu:syu","しょ:ショ:sho:syo","た:タ:ta","ち:チ:chi:ti","つ:ツ:tsu:tu","て:テ:te","と:ト:to","ちゃ:チャ:cha:tya","ちゅ:チュ:chu:tyu","ちょ:チョ:cho:tyo","な:ナ:na","に:ニ:ni","ぬ:ヌ:nu","ね:ネ:ne","の:ノ:no","にゃ:ニャ:nya","にゅ:ニュ:nyu","にょ:ニョ:nyo","は:ハ:ha","ひ:ヒ:hi","ふ:フ:fu:hu","へ:ヘ:he","ほ:ホ:ho","ひゃ:ヒャ:hya","ひゅ:ヒュ:hyu","ひょ:ヒョ:hyo","ま:マ:ma","み:ミ:mi","む:ム:mu","め:メ:me","も:モ:mo","みゃ:ミャ:mya","みゅ:ミュ:myu","みょ:ミョ:myo","や:ヤ:ya","ゆ:ユ:yu","よ:ヨ:yo","ら:ラ:ra","り:リ:ri","る:ル:ru","れ:レ:re","ろ:ロ:ro","りゃ:リャ:rya","りゅ:リュ:ryu","りょ:リョ:ryo","わ:ワ:wa","ゐ:ヰ:i:wi:i","ゑ:ヱ:e:we:e","を:ヲ:o:wo:o","ん:ン:n-n'(-m):n-n'","が:ガ:ga","ぎ:ギ:gi","ぐ:グ:gu","げ:ゲ:ge","ご:ゴ:go","ぎゃ:ギャ:gya","ぎゅ:ギュ:gyu","ぎょ:ギョ:gyo","ざ:ザ:za","じ:ジ:ji:zi","ず:ズ:zu","ぜ:ゼ:ze","ぞ:ゾ:zo","じゃ:ジャ:ja:zya","じゅ:ジュ:ju:zyu","じょ:ジョ:jo:zyo","だ:ダ:da","ぢ:ヂ:ji:di:zi","づ:ヅ:zu:du:zu","で:デ:de","ど:ド:do","ぢゃ:ヂャ:ja:dya:zya","ぢゅ:ヂュ:ju:dyu:zyu","ぢょ:ヂョ:jo:dyo:zyo","ば:バ:ba","び:ビ:bi","ぶ:ブ:bu","べ:ベ:be","ぼ:ボ:bo","びゃ:ビャ:bya","びゅ:ビュ:byu","びょ:ビョ:byo","ぱ:パ:pa","ぴ:ピ:pi","ぷ:プ:pu","ぺ:ペ:pe","ぽ:ポ:po","ぴゃ:ピャ:pya","ぴゅ:ピュ:pyu","ぴょ:ピョ:pyo"];var d={};var d2={};var i=HKH.length;while(i--){var a=HKH[i].split(":");d[a[0]]=a[1];d2[a[1]]=a[2]}A2L(document)})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on http://ceestimmerman.blogspot.nl/2014/11/cyrillic-to-latin.html