(onload = function(){var lt=String.fromCharCode(0x3c), gt=String.fromCharCode(0x3e), gl=gt+lt, amp=String.fromCharCode(0x26);var s0 = ' :'+lt+'br /'+gl+'input id=\'n\''+gl+'br /'+gl+'br /'+gt;var s1 = ' : '+lt+'a id=\'a';var s2 = '\' target=\'_blank\''+gt+'Play'+lt+'/a'+gl+'br /'+gl+'textarea id=\'t';var s3 = '\' readonly'+gl+'/textarea'+gl+'br /'+gt;document.getElementById('i').innerHTML = 'Number'+s0+'Japanese'+s1+'j'+s2+'j'+s3+'English'+s1+'e'+s2+'e'+s3+'French'+s1+'f'+s2+'f'+s3+'German'+s1+'g'+s2+'g'+s3+'Chinese'+s1+'c'+s2+'c'+s3+'Korean'+s1+'k'+s2+'k'+s3;function japanese(i){var a = new Array('零', '一', '二', '三', '四', '五', '六', '七', '八', '九');var b = new Array('十', '百', '千');var c = new Array('', '万', '億', '兆', '京' ,'垓');var k, s='';if ( i == 0 ) s = ja[0];k = 0;while ( i ) {if ( k*(i%10000) ) s = c[k]+s;if ( i%10 ) s = a[i%10]+s;i = Math.floor(i/10);for (var j=0; j!=3; j++) {if ( i%10 ) {s = b[j]+s;if ( k*(j==2) || Math.min(i%10,2)==2 ) s = a[i%10]+s;}i = Math.floor(i/10);}k++ ;}document.getElementById('tj').value = s;document.getElementById('aj').href = 'http://translate.google.com/translate_tts?tl=ja'+amp+'q='+s;}function english(i){var a = new Array('zero ', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ','ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen ');var b = new Array('', '', 'twenty ', 'thirty ', 'fourty ', 'fifty ', 'sixty ', 'seventy ', 'eighty ', 'ninety ');var c = new Array('hundred ', 'thousand ', 'million ', 'billion ', 'trillion ', 'quadrillion ', 'quintillion ', 'sextillion ');var k, s='';if ( i == 0 ) s = en[0];k = 0;while ( i ) {if ( k*(i%1000) ) s = c[k]+s;if ( Math.min(i%100,20)==20 ) {if ( i%10 ) s = a[i%10]+s;s = b[Math.floor(i%100/10)]+s;} else if ( i%100 ) {s = a[i%100]+s;}i = Math.floor(i/100);if ( i%10 ) s = a[i%10]+c[0]+s;i = Math.floor(i/10);k ++;}s = s.replace(/\s+$/g,'');document.getElementById('te').innerHTML = s;document.getElementById('ae').href = 'http://translate.google.com/translate_tts?tl=en'+amp+'q='+s.replace(/ /g,'+');}function french(i){var a = new Array('zéro ', 'un ', 'deux ', 'trois ', 'quatre ', 'cinq ', 'six ', 'sept ', 'huit ', 'neuf ', 'dix ', 'onze ', 'douze ', 'treize ', 'quatorze ', 'quinze ', 'seize ', 'dix-sept ', 'dix-huit ', 'dix-neuf ');var b = new Array('et ', '', 'vingt ', 'trente ', 'quarante ', 'cinquante ', 'soixante ', 'soixante ', 'quatre-vingts ', 'quatre-vingt ');var c = new Array('et ', '', 'vingt-', 'trente-', 'quarante-', 'cinquante-', 'soixante-', 'soixante-', 'quatre-vingt-', 'quatre-vingt-');var d = new Array('cent ', 'mille ', 'million ', 'milliard ', 'trillion ', 'quadrillion ', 'quintillion ', 'sextillion ');var e = new Array('cents ', 'mille ', 'millions ', 'milliards ', 'trillions ', 'quadrillions ', 'quintillions ', 'sextillions ');var k, s='';if ( i == 0 ) s = fr[0];k = 0;while ( i ) {if ( k*(i%1000) ) {if ( i%1000==1 ) {s = d[k]+s;} else {s = e[k]+s;}}if ( Math.min(i%100,80)==80 ) {if ( i%20 ) {s = c[8]+a[i%20]+s;} else if ( k!=1 ) {s = b[8]+s;} else {s = b[9]+s;}} else if ( Math.min(i%100,60)==60 ) {if ( i%20 ) s = a[i%20]+s;if ( i%10==1 ) s = b[0]+s;if ( (i%20)*(i%10!=1) ) {s = c[6]+s;} else {s = b[6]+s;}} else if ( Math.min(i%100,20)==20 ) {if ( i%10 ) s = a[i%10]+s;if ( i%10==1 ) s = b[0]+s;if ( (i%10)*(i%10!=1) ) {s = c[Math.floor(i%100/10)]+s;} else {s = b[Math.floor(i%100/10)]+s;}} else if ( i%100 ) {if ( k!=1 || i%20!=1 ) s = a[i%100]+s;}if ( (k!=1)*(i%100==0)*(Math.min(Math.floor(i/100)%10,2)==2) ) {s = a[Math.floor(i/100)%10]+e[0]+s;} else if ( Math.floor(i/100)%10 ) {s = d[0]+s;if ( Math.min(Math.floor(i/100)%10,2)==2 ) s = a[Math.floor(i/100)%10]+s;}i = Math.floor(i/1000);k ++;}s = s.replace(/\s+$/g,'');document.getElementById('tf').innerHTML = s;document.getElementById('af').href = 'http://translate.google.com/translate_tts?tl=fr'+amp+'q='+s.replace(/ /g,'+');}function german(i){var a = new Array('null', 'eins', 'zwei', 'drei', 'vier', 'fünf', 'sechs', 'sieben', 'acht', 'neun', 'zehn', 'elf', 'zwölf', 'dreizehn', 'vierzehn', 'fünfzehn', 'sechzehn', 'siebzehn', 'achtzehn', 'neunzehn');var b = new Array('und', 'ein', 'zwei', 'drei', 'vier', 'fünf', 'sechs', 'sieben', 'acht', 'neun');var c = new Array( '', '', 'zwanzig', 'dreißig', 'vierzig', 'fünfzig', 'sechzig', 'siebzig', 'achtzig', 'neunzig');var d = new Array( 'hundert', 'tausend', 'e Million ', 'e Milliarde ', 'e Billion ', 'e Billiarde ', 'e Trillion ', 'e Trilliarde ');var e = new Array('hundert', 'tausend', ' Millionen ', ' Milliarden ', ' Billionen ', ' Billiarden ', ' Trillionen ', ' Trilliarden ');var k, s='';if ( i == 0 ) s = a[0];k = 0;while ( i ) {if ( k*(i%1000) ) {if ( i%1000==1 ) {s = d[k]+s;} else {s = e[k]+s;}}if ( k*(i%100==1) ) {s = b[1]+s;} else if ( Math.min(i%100,20)==20 ) {s = c[Math.floor(i%100/10)]+s;if ( i%10 ) s = b[i%10]+b[0]+s;} else if ( i%100 ) {s = a[i%100]+s;}i = Math.floor(i/100);if ( i%10 ) s = b[i%10]+e[0]+s;i = Math.floor(i/10);k ++;}s = s.replace(/\s+$/g,'');document.getElementById('tg').innerHTML = s;document.getElementById('ag').href = 'http://translate.google.com/translate_tts?tl=de'+amp+'q='+s.replace(/ /g,'+');}function chinese(i){var a = new Array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖');var b = new Array('拾', '佰', '仟');var c = new Array('', '萬', '亿', '兆', '京' ,'垓');var k, s='';if ( i == 0 ) s = ja[0];k = 0;while ( i ) {if ( k*(i%10000) ) s = c[k]+s;if ( i%10 ) s = a[i%10]+s;i = Math.floor(i/10);for (var j=0; j!=3; j++) {if ( i%10 ) {s = a[i%10]+b[j]+s;}i = Math.floor(i/10);}k++ ;}document.getElementById('tc').value = s;document.getElementById('ac').href = 'http://translate.google.com/translate_tts?tl=zh-CN'+amp+'q='+s;}function korean(i){var a = new Array('영', '일', '이', '삼', '사', '오', '육', '칠', '팔', '구');var b = new Array('십', '백', '천');var c = new Array('', '만', '억', '조', '쿄' ,'해', '자', '양', '구', '간', '정', '재', '극');var k, s='';if ( i == 0 ) s = ja[0];k = 0;while ( i ) {if ( k*(i%10000) ) s = c[k]+s;if ( i%10 ) s = a[i%10]+s;i = Math.floor(i/10);for (var j=0; j!=3; j++) {if ( i%10 ) {s = b[j]+s;if ( i%10!=1 ) s = a[i%10]+s;}i = Math.floor(i/10);}k++ ;}document.getElementById('tk').value = s;document.getElementById('ak').href = 'http://translate.google.com/translate_tts?tl=ko'+amp+'q='+s;}function test(){var i = document.getElementById('n').value;japanese(i);english(i);french(i);german(i);chinese(i);korean(i)}document.getElementById('n').value = 12345;test();onchange = function() { test(); };})();
表示されなければ未対応な環境です。
とりあえず、0を含む自然数を、日本語、英語、フランス語、ドイツ語、中国語、ハングルなど、自作JavaScriptで翻訳させてみた。
結果をGoogle TTSで喋らそうと思っているのだが、audioタグでも、iframeタグでも上手くいかないので、aタグで普通にリンクしましたので、Playを押してください。
また、Playを押して行った先でもネットワークエラーとかで喋らないケースが多々有りますが、URLをクリックしてEnterをすることで上手くいく場合もあります。
今回もゴリゴリにハードコーディングしているので、ソースは見ないほうがよいw。
当然だが、このプログラムは正確性を保証するものではないので、このプログラムを使ったいかなるトラブルにも当方は一切の関係がないものとする。
おかしい値など有りましたら、コメントで指摘して頂ければ、修正するかもしれません。